use of ubic.gemma.core.loader.association.NCBIGene2GOAssociationParser in project Gemma by PavlidisLab.
the class NCBIGene2GOAssociationLoaderCLI method doWork.
@Override
protected Exception doWork(String[] args) {
Exception e = this.processCommandLine(args);
if (e != null) {
AbstractCLI.log.error(e);
return e;
}
TaxonService taxonService = this.getBean(TaxonService.class);
NCBIGene2GOAssociationLoader gene2GOAssLoader = new NCBIGene2GOAssociationLoader();
gene2GOAssLoader.setPersisterHelper(this.getPersisterHelper());
Collection<Taxon> taxa = taxonService.loadAll();
gene2GOAssLoader.setParser(new NCBIGene2GOAssociationParser(taxa));
HttpFetcher fetcher = new HttpFetcher();
Collection<LocalFile> files;
if (filePath != null) {
File f = new File(filePath);
if (!f.canRead()) {
return new IOException("Cannot read from " + filePath);
}
files = new HashSet<>();
LocalFile lf = LocalFile.Factory.newInstance();
try {
lf.setLocalURL(f.toURI().toURL());
} catch (MalformedURLException e1) {
return e1;
}
files.add(lf);
} else {
files = fetcher.fetch("ftp://ftp.ncbi.nih.gov/gene/DATA/" + NCBIGene2GOAssociationLoaderCLI.GENE2GO_FILE);
}
assert files.size() == 1;
LocalFile gene2Gofile = files.iterator().next();
Gene2GOAssociationService ggoserv = this.getBean(Gene2GOAssociationService.class);
AbstractCLI.log.info("Removing all old GO associations");
ggoserv.removeAll();
AbstractCLI.log.info("Done, loading new ones");
gene2GOAssLoader.load(gene2Gofile);
AbstractCLI.log.info("Don't forget to update the annotation files for platforms.");
return null;
}
Aggregations