Search in sources :

Example 36 with VocabCharacteristic

use of ubic.gemma.model.common.description.VocabCharacteristic in project Gemma by PavlidisLab.

the class OntologyServiceImpl method convert.

/**
 * Given a collection of ontology terms converts them to a collection of VocabCharacteristics
 */
private Collection<VocabCharacteristic> convert(final Collection<OntologyResource> resources) {
    Collection<VocabCharacteristic> converted = new HashSet<>();
    if ((resources == null) || (resources.isEmpty()))
        return converted;
    for (OntologyResource res : resources) {
        VocabCharacteristic vc = VocabCharacteristic.Factory.newInstance();
        // If there is no URI we don't want to send it back (ie useless)
        if ((res.getUri() == null) || StringUtils.isEmpty(res.getUri()))
            continue;
        if (res instanceof OntologyTerm) {
            OntologyTerm term = (OntologyTerm) res;
            vc.setValue(term.getTerm());
            vc.setValueUri(term.getUri());
            vc.setDescription(term.getComment());
        }
        if (res instanceof OntologyIndividual) {
            OntologyIndividual indi = (OntologyIndividual) res;
            vc.setValue(indi.getLabel());
            vc.setValueUri(indi.getUri());
            vc.setDescription("Individual");
        }
        converted.add(vc);
    }
    return converted;
}
Also used : VocabCharacteristic(ubic.gemma.model.common.description.VocabCharacteristic) OntologyIndividual(ubic.basecode.ontology.model.OntologyIndividual) OntologyTerm(ubic.basecode.ontology.model.OntologyTerm) OntologyResource(ubic.basecode.ontology.model.OntologyResource) ConcurrentHashSet(org.compass.core.util.concurrent.ConcurrentHashSet)

Example 37 with VocabCharacteristic

use of ubic.gemma.model.common.description.VocabCharacteristic in project Gemma by PavlidisLab.

the class GeneOntologyServiceImpl method getGOTerms.

@Override
public Collection<OntologyTerm> getGOTerms(Gene gene, boolean includePartOf, GOAspect goAspect) {
    Collection<OntologyTerm> cachedTerms = goTerms.get(gene);
    if (GeneOntologyServiceImpl.log.isTraceEnabled() && cachedTerms != null) {
        this.logIds("found cached GO terms for " + gene.getOfficialSymbol(), goTerms.get(gene));
    }
    if (cachedTerms == null) {
        Collection<OntologyTerm> allGOTermSet = new HashSet<>();
        Collection<VocabCharacteristic> annotations = gene2GOAssociationService.findByGene(gene);
        for (VocabCharacteristic c : annotations) {
            if (!GeneOntologyServiceImpl.uri2Term.containsKey(c.getValueUri())) {
                GeneOntologyServiceImpl.log.warn("Term " + c.getValueUri() + " not found in term list cant add to results");
                continue;
            }
            allGOTermSet.add(GeneOntologyServiceImpl.uri2Term.get(c.getValueUri()));
        }
        allGOTermSet.addAll(this.getAllParents(allGOTermSet, includePartOf));
        cachedTerms = Collections.unmodifiableCollection(allGOTermSet);
        if (GeneOntologyServiceImpl.log.isTraceEnabled())
            this.logIds("caching GO terms for " + gene.getOfficialSymbol(), allGOTermSet);
        goTerms.put(gene, cachedTerms);
    }
    if (goAspect != null) {
        Collection<OntologyTerm> finalTerms = new HashSet<>();
        for (OntologyTerm ontologyTerm : cachedTerms) {
            GOAspect term = this.getTermAspect(ontologyTerm);
            if (term != null && term.equals(goAspect)) {
                finalTerms.add(ontologyTerm);
            }
        }
        return finalTerms;
    }
    return cachedTerms;
}
Also used : VocabCharacteristic(ubic.gemma.model.common.description.VocabCharacteristic) OntologyTerm(ubic.basecode.ontology.model.OntologyTerm)

Example 38 with VocabCharacteristic

use of ubic.gemma.model.common.description.VocabCharacteristic in project Gemma by PavlidisLab.

the class GeneDifferentialExpressionServiceImpl method configExperimentalFactorValueObject.

@Override
public ExperimentalFactorValueObject configExperimentalFactorValueObject(ExperimentalFactor ef) {
    ExperimentalFactorValueObject efvo = new ExperimentalFactorValueObject(ef.getId());
    efvo.setName(ef.getName());
    efvo.setDescription(ef.getDescription());
    Characteristic category = ef.getCategory();
    if (category != null) {
        efvo.setCategory(category.getCategory());
        if (category instanceof VocabCharacteristic) {
            efvo.setCategoryUri(category.getCategoryUri());
        }
    }
    Collection<FactorValue> fvs = ef.getFactorValues();
    StringBuilder factorValuesAsString = new StringBuilder(StringUtils.EMPTY);
    for (FactorValue fv : fvs) {
        String fvName = fv.toString();
        if (StringUtils.isNotBlank(fvName)) {
            factorValuesAsString.append(fvName).append(GeneDifferentialExpressionServiceImpl.FV_SEP);
        }
    }
    /* clean up the start and end of the string */
    factorValuesAsString = new StringBuilder(StringUtils.remove(factorValuesAsString.toString(), ef.getName() + ":"));
    factorValuesAsString = new StringBuilder(StringUtils.removeEnd(factorValuesAsString.toString(), GeneDifferentialExpressionServiceImpl.FV_SEP));
    /*
         * Preformat the factor name; due to Ext PropertyGrid limitations we can't do this on the client.
         */
    efvo.setName(ef.getName() + " (" + StringUtils.abbreviate(factorValuesAsString.toString(), 50) + ")");
    efvo.setFactorValues(factorValuesAsString.toString());
    return efvo;
}
Also used : Characteristic(ubic.gemma.model.common.description.Characteristic) VocabCharacteristic(ubic.gemma.model.common.description.VocabCharacteristic) VocabCharacteristic(ubic.gemma.model.common.description.VocabCharacteristic)

Example 39 with VocabCharacteristic

use of ubic.gemma.model.common.description.VocabCharacteristic in project Gemma by PavlidisLab.

the class PhenotypeAssoOntologyHelperImpl method valueUri2Characteristic.

@Override
public Characteristic valueUri2Characteristic(String valueUri) {
    try {
        OntologyTerm o = findOntologyTermByUri(valueUri);
        if (o == null)
            return null;
        VocabCharacteristic myPhenotype = VocabCharacteristic.Factory.newInstance();
        myPhenotype.setValueUri(o.getUri());
        myPhenotype.setValue(o.getLabel());
        myPhenotype.setCategory(PhenotypeAssociationConstants.PHENOTYPE);
        myPhenotype.setCategoryUri(PhenotypeAssociationConstants.PHENOTYPE_CATEGORY_URI);
        return myPhenotype;
    } catch (EntityNotFoundException e) {
        e.printStackTrace();
        return null;
    }
}
Also used : VocabCharacteristic(ubic.gemma.model.common.description.VocabCharacteristic) OntologyTerm(ubic.basecode.ontology.model.OntologyTerm) EntityNotFoundException(ubic.gemma.core.association.phenotype.PhenotypeExceptions.EntityNotFoundException)

Example 40 with VocabCharacteristic

use of ubic.gemma.model.common.description.VocabCharacteristic in project Gemma by PavlidisLab.

the class GeneSetServiceTest method testFindByGoId.

@Test
public void testFindByGoId() {
    VocabCharacteristic oe = VocabCharacteristic.Factory.newInstance();
    oe.setValueUri(GeneOntologyService.BASE_GO_URI + GeneSetServiceTest.GOTERM_INDB);
    oe.setValue(GeneSetServiceTest.GOTERM_INDB);
    Gene2GOAssociation g2Go1 = Gene2GOAssociation.Factory.newInstance(g, oe, GOEvidenceCode.EXP);
    gene2GoService.create(g2Go1);
    oe = VocabCharacteristic.Factory.newInstance();
    oe.setValueUri(GeneOntologyService.BASE_GO_URI + GeneSetServiceTest.GOTERM_INDB);
    oe.setValue(GeneSetServiceTest.GOTERM_INDB);
    Gene2GOAssociation g2Go2 = Gene2GOAssociation.Factory.newInstance(g3, oe, GOEvidenceCode.EXP);
    gene2GoService.create(g2Go2);
    GeneSet gset = this.geneSetSearch.findByGoId(GeneSetServiceTest.GOTERM_QUERY, g3.getTaxon());
    assertEquals(2, gset.getMembers().size());
}
Also used : VocabCharacteristic(ubic.gemma.model.common.description.VocabCharacteristic) Gene2GOAssociation(ubic.gemma.model.association.Gene2GOAssociation) Test(org.junit.Test) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest)

Aggregations

VocabCharacteristic (ubic.gemma.model.common.description.VocabCharacteristic)44 Characteristic (ubic.gemma.model.common.description.Characteristic)15 OntologyTerm (ubic.basecode.ontology.model.OntologyTerm)10 FactorValue (ubic.gemma.model.expression.experiment.FactorValue)7 Test (org.junit.Test)6 AnnotationValueObject (ubic.gemma.model.common.description.AnnotationValueObject)4 Gene (ubic.gemma.model.genome.Gene)4 HashSet (java.util.HashSet)3 Gene2GOAssociation (ubic.gemma.model.association.Gene2GOAssociation)3 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)3 GZIPOutputStream (java.util.zip.GZIPOutputStream)2 StopWatch (org.apache.commons.lang3.time.StopWatch)2 ConcurrentHashSet (org.compass.core.util.concurrent.ConcurrentHashSet)2 OntologyIndividual (ubic.basecode.ontology.model.OntologyIndividual)2 OntologyResource (ubic.basecode.ontology.model.OntologyResource)2 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)2 BioMaterial (ubic.gemma.model.expression.biomaterial.BioMaterial)2 CharacteristicValueObject (ubic.gemma.model.genome.gene.phenotype.valueObject.CharacteristicValueObject)2 AclObjectIdentity (gemma.gsec.acl.domain.AclObjectIdentity)1 InputStream (java.io.InputStream)1