use of ubic.gemma.core.genome.gene.service.GeneService in project Gemma by PavlidisLab.
the class ArrayDesignAnnotationFileCli method processGeneList.
private void processGeneList() throws IOException {
AbstractCLI.log.info("Loading genes to annotate from " + geneFileName);
InputStream is = new FileInputStream(geneFileName);
try (BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
String line;
GeneService geneService = this.getBean(GeneService.class);
TaxonService taxonService = this.getBean(TaxonService.class);
Taxon taxon = taxonService.findByCommonName(taxonName);
if (taxon == null) {
throw new IllegalArgumentException("Unknown taxon: " + taxonName);
}
Collection<Gene> genes = new HashSet<>();
while ((line = br.readLine()) != null) {
if (StringUtils.isBlank(line)) {
continue;
}
String[] arguments = StringUtils.split(line, '\t');
String gene = arguments[0];
Gene g = geneService.findByOfficialSymbol(gene, taxon);
if (g == null) {
AbstractCLI.log.info("Gene: " + gene + " not found.");
continue;
}
genes.add(g);
}
AbstractCLI.log.info("File contained " + genes.size() + " potential gene symbols");
int numProcessed = arrayDesignAnnotationService.generateAnnotationFile(new PrintWriter(System.out), genes, OutputType.SHORT);
AbstractCLI.log.info("Processed " + numProcessed + " genes that were found");
}
}
use of ubic.gemma.core.genome.gene.service.GeneService in project Gemma by PavlidisLab.
the class GenericGenelistDesignGenerator method processOptions.
@Override
protected void processOptions() {
super.processOptions();
geneService = this.getBean(GeneService.class);
arrayDesignAnnotationService = this.getBean(ArrayDesignAnnotationService.class);
TaxonService taxonService = this.getBean(TaxonService.class);
bioSequenceService = this.getBean(BioSequenceService.class);
arrayDesignService = this.getBean(ArrayDesignService.class);
compositeSequenceService = this.getBean(CompositeSequenceService.class);
annotationAssociationService = this.getBean(AnnotationAssociationService.class);
externalDatabaseService = this.getBean(ExternalDatabaseService.class);
arrayDesignReportService = this.getBean(ArrayDesignReportService.class);
if (this.hasOption('t')) {
this.taxon = this.setTaxonByName(taxonService);
}
if (this.hasOption("ncbiids")) {
this.useNCBIIds = true;
} else if (this.hasOption("ensembl")) {
this.useEnsemblIds = true;
}
if (useNCBIIds && useEnsemblIds) {
throw new IllegalArgumentException("Choose one of ensembl or ncbi ids or gene symbols");
}
}
use of ubic.gemma.core.genome.gene.service.GeneService in project Gemma by PavlidisLab.
the class ArrayDesignAnnotationFileCli method processGenesForTaxon.
private void processGenesForTaxon() {
GeneService geneService = this.getBean(GeneService.class);
TaxonService taxonService = this.getBean(TaxonService.class);
Taxon taxon = taxonService.findByCommonName(taxonName);
if (taxon == null) {
throw new IllegalArgumentException("Unknown taxon: " + taxonName);
}
AbstractCLI.log.info("Processing all genes for " + taxon);
Collection<Gene> genes = geneService.loadAll(taxon);
AbstractCLI.log.info("Taxon has " + genes.size() + " 'known' genes");
int numProcessed = arrayDesignAnnotationService.generateAnnotationFile(new PrintWriter(System.out), genes, type);
AbstractCLI.log.info("Processed " + numProcessed + " genes that were found");
}
use of ubic.gemma.core.genome.gene.service.GeneService in project Gemma by PavlidisLab.
the class StringProteinLoadCli method loadProteinProteinInteractions.
/**
* Method to wrap call to loader. Ensures that all spring beans are configured.
*
* @throws IOException IO problems
*/
// Possible external use
@SuppressWarnings({ "unused", "WeakerAccess" })
public void loadProteinProteinInteractions() throws IOException {
StringProteinInteractionLoader loader = new StringProteinInteractionLoader();
GeneService geneService = this.getBean(GeneService.class);
ExternalDatabaseService externalDatabaseService = this.getBean(ExternalDatabaseService.class);
// set all the loaders
if (this.getPersisterHelper() == null || geneService == null || externalDatabaseService == null) {
throw new RuntimeException("Spring configuration problem");
}
loader.setPersisterHelper(this.getPersisterHelper());
loader.setGeneService(geneService);
loader.setExternalDatabaseService(externalDatabaseService);
Collection<Taxon> taxa = this.getValidTaxon();
// some of these parameters can be null
loader.load(stringProteinProteinFileNameLocal, stringProteinProteinFileNameRemote, biomartFileName, taxa);
}
Aggregations