Search in sources :

Example 26 with Taxon

use of ubic.gemma.model.genome.Taxon in project Gemma by PavlidisLab.

the class PhenotypeAssociationManagerServiceImpl method findGenesWithEvidence.

@Override
@Transactional(readOnly = true)
public Collection<GeneEvidenceValueObject> findGenesWithEvidence(String query, Long taxonId) {
    if (query == null || query.length() == 0) {
        throw new IllegalArgumentException("No search query provided");
    }
    // make sure it does an inexact search
    String newQuery = query + "%";
    Taxon taxon = null;
    if (taxonId != null) {
        taxon = this.taxonService.load(taxonId);
    }
    SearchSettings settings = SearchSettingsImpl.geneSearch(newQuery, taxon);
    List<SearchResult> geneSearchResults = this.searchService.search(settings).get(Gene.class);
    Collection<Gene> genes = new HashSet<>();
    if (geneSearchResults == null || geneSearchResults.isEmpty()) {
        return new HashSet<>();
    }
    for (SearchResult sr : geneSearchResults) {
        genes.add((Gene) sr.getResultObject());
    }
    Collection<GeneEvidenceValueObject> geneEvidenceValueObjects = new HashSet<>();
    for (Gene g : genes) {
        GeneEvidenceValueObject geneEvidenceValueObject = new GeneEvidenceValueObject(g, this.convert2ValueObjects(g.getPhenotypeAssociations()));
        geneEvidenceValueObjects.add(geneEvidenceValueObject);
    }
    Collection<GeneEvidenceValueObject> geneValueObjectsFilter = new ArrayList<>();
    for (GeneEvidenceValueObject gene : geneEvidenceValueObjects) {
        if (gene.getEvidence() != null && gene.getEvidence().size() != 0) {
            geneValueObjectsFilter.add(gene);
        }
    }
    return geneValueObjectsFilter;
}
Also used : Gene(ubic.gemma.model.genome.Gene) Taxon(ubic.gemma.model.genome.Taxon) SearchSettings(ubic.gemma.model.common.search.SearchSettings) SearchResult(ubic.gemma.core.search.SearchResult) Transactional(org.springframework.transaction.annotation.Transactional)

Example 27 with Taxon

use of ubic.gemma.model.genome.Taxon in project Gemma by PavlidisLab.

the class PhenotypeAssociationManagerServiceImpl method findCandidateGenes.

@Override
@Transactional(readOnly = true)
public Collection<GeneEvidenceValueObject> findCandidateGenes(EvidenceFilter evidenceFilter, Set<String> phenotypesValuesUri) {
    this.addDefaultExcludedDatabases(evidenceFilter);
    if (phenotypesValuesUri == null || phenotypesValuesUri.isEmpty()) {
        throw new IllegalArgumentException("No phenotypes values uri provided");
    }
    Taxon taxon = null;
    boolean showOnlyEditable = false;
    Collection<Long> externalDatabaseIds = null;
    if (evidenceFilter != null) {
        taxon = this.checkAndGetTaxon(evidenceFilter);
        showOnlyEditable = evidenceFilter.isShowOnlyEditable();
        externalDatabaseIds = evidenceFilter.getExternalDatabaseIds();
    }
    Set<String> usedPhenotypes = this.phenoAssocService.loadAllUsedPhenotypeUris();
    // map query phenotypes given to the set of possible children phenotypes in the database + query phenotype
    Map<String, Set<String>> phenotypesWithChildren = this.findChildrenForEachPhenotype(phenotypesValuesUri, usedPhenotypes);
    Set<String> possibleChildrenPhenotypes = this.findAllPossibleChildren(phenotypesWithChildren);
    Collection<GeneEvidenceValueObject> genesPhenotypeHelperObject = this.phenoAssocService.findGenesWithPhenotypes(possibleChildrenPhenotypes, taxon, showOnlyEditable, externalDatabaseIds);
    return this.filterGenesWithPhenotypes(genesPhenotypeHelperObject, phenotypesWithChildren);
}
Also used : Taxon(ubic.gemma.model.genome.Taxon) Transactional(org.springframework.transaction.annotation.Transactional)

Example 28 with Taxon

use of ubic.gemma.model.genome.Taxon 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 29 with Taxon

use of ubic.gemma.model.genome.Taxon in project Gemma by PavlidisLab.

the class ArrayDesignAnnotationFileCli method processAllADs.

/**
 * Goes over all the AD's in the database (possibly limited by taxon) and creates annotation 3 annotation files for
 * each AD that is not merged into or subsumed by another AD. Uses the Accession ID (GPL???) for the name of the
 * annotation file. Appends noParents, bioProcess, allParents to the file name.
 */
private void processAllADs() throws IOException {
    Collection<ArrayDesign> allADs = this.arrayDesignService.loadAll();
    for (ArrayDesign ad : allADs) {
        ad = arrayDesignService.thawLite(ad);
        if (ad.getCurationDetails().getTroubled()) {
            AbstractCLI.log.warn("Troubled: " + ad + " (skipping)");
            continue;
        }
        Taxon taxon = null;
        if (this.taxonName != null) {
            TaxonService taxonService = this.getBean(TaxonService.class);
            taxon = taxonService.findByCommonName(taxonName);
            if (taxon == null) {
                throw new IllegalArgumentException("Unknown taxon: " + taxonName);
            }
        }
        Collection<Taxon> adTaxa = arrayDesignService.getTaxa(ad.getId());
        /*
             * If using taxon, check it.
             */
        if (taxon != null && !adTaxa.contains(taxon)) {
            continue;
        }
        this.processOneAD(ad);
    }
}
Also used : TaxonService(ubic.gemma.persistence.service.genome.taxon.TaxonService) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) Taxon(ubic.gemma.model.genome.Taxon)

Example 30 with Taxon

use of ubic.gemma.model.genome.Taxon in project Gemma by PavlidisLab.

the class LoadSimpleExpressionDataCli method configureTaxon.

private void configureTaxon(String[] fields, SimpleExpressionExperimentMetaData metaData) {
    Taxon existing = taxonService.findByCommonName(fields[LoadSimpleExpressionDataCli.SPECIES_I]);
    if (existing == null) {
        throw new IllegalArgumentException("There is no taxon with scientific name " + fields[LoadSimpleExpressionDataCli.SPECIES_I] + " in the system; please add it first before loading data.");
    }
    metaData.setTaxon(existing);
}
Also used : Taxon(ubic.gemma.model.genome.Taxon)

Aggregations

Taxon (ubic.gemma.model.genome.Taxon)161 Gene (ubic.gemma.model.genome.Gene)34 Test (org.junit.Test)31 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)29 HashSet (java.util.HashSet)23 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)23 InputStream (java.io.InputStream)17 Before (org.junit.Before)16 BioSequence (ubic.gemma.model.genome.biosequence.BioSequence)15 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)14 CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)12 StopWatch (org.apache.commons.lang3.time.StopWatch)11 Transactional (org.springframework.transaction.annotation.Transactional)11 ArrayList (java.util.ArrayList)10 File (java.io.File)9 SimpleExpressionExperimentMetaData (ubic.gemma.core.loader.expression.simple.model.SimpleExpressionExperimentMetaData)9 Chromosome (ubic.gemma.model.genome.Chromosome)8 Collection (java.util.Collection)7 Element (org.w3c.dom.Element)7 PhysicalLocation (ubic.gemma.model.genome.PhysicalLocation)7