Search in sources :

Example 1 with GeneService

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");
    }
}
Also used : GeneService(ubic.gemma.core.genome.gene.service.GeneService) TaxonService(ubic.gemma.persistence.service.genome.taxon.TaxonService) Taxon(ubic.gemma.model.genome.Taxon) Gene(ubic.gemma.model.genome.Gene) HashSet(java.util.HashSet)

Example 2 with GeneService

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");
    }
}
Also used : GeneService(ubic.gemma.core.genome.gene.service.GeneService) AnnotationAssociationService(ubic.gemma.persistence.service.genome.sequenceAnalysis.AnnotationAssociationService) ExternalDatabaseService(ubic.gemma.persistence.service.common.description.ExternalDatabaseService) TaxonService(ubic.gemma.persistence.service.genome.taxon.TaxonService) ArrayDesignAnnotationService(ubic.gemma.core.analysis.service.ArrayDesignAnnotationService) BioSequenceService(ubic.gemma.persistence.service.genome.biosequence.BioSequenceService) CompositeSequenceService(ubic.gemma.persistence.service.expression.designElement.CompositeSequenceService) ArrayDesignService(ubic.gemma.persistence.service.expression.arrayDesign.ArrayDesignService) ArrayDesignReportService(ubic.gemma.core.analysis.report.ArrayDesignReportService)

Example 3 with GeneService

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");
}
Also used : GeneService(ubic.gemma.core.genome.gene.service.GeneService) TaxonService(ubic.gemma.persistence.service.genome.taxon.TaxonService) Gene(ubic.gemma.model.genome.Gene) Taxon(ubic.gemma.model.genome.Taxon)

Example 4 with GeneService

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);
}
Also used : GeneService(ubic.gemma.core.genome.gene.service.GeneService) ExternalDatabaseService(ubic.gemma.persistence.service.common.description.ExternalDatabaseService) StringProteinInteractionLoader(ubic.gemma.core.loader.protein.StringProteinInteractionLoader) Taxon(ubic.gemma.model.genome.Taxon)

Aggregations

GeneService (ubic.gemma.core.genome.gene.service.GeneService)4 Taxon (ubic.gemma.model.genome.Taxon)3 TaxonService (ubic.gemma.persistence.service.genome.taxon.TaxonService)3 Gene (ubic.gemma.model.genome.Gene)2 ExternalDatabaseService (ubic.gemma.persistence.service.common.description.ExternalDatabaseService)2 HashSet (java.util.HashSet)1 ArrayDesignReportService (ubic.gemma.core.analysis.report.ArrayDesignReportService)1 ArrayDesignAnnotationService (ubic.gemma.core.analysis.service.ArrayDesignAnnotationService)1 StringProteinInteractionLoader (ubic.gemma.core.loader.protein.StringProteinInteractionLoader)1 ArrayDesignService (ubic.gemma.persistence.service.expression.arrayDesign.ArrayDesignService)1 CompositeSequenceService (ubic.gemma.persistence.service.expression.designElement.CompositeSequenceService)1 BioSequenceService (ubic.gemma.persistence.service.genome.biosequence.BioSequenceService)1 AnnotationAssociationService (ubic.gemma.persistence.service.genome.sequenceAnalysis.AnnotationAssociationService)1