Search in sources :

Example 21 with OntologyTerm

use of ubic.basecode.ontology.model.OntologyTerm in project Gemma by PavlidisLab.

the class GeneOntologyServiceTest method testGetChildrenPartOf.

// latest versions do not have definitions included.
// public final void testGetDefinition() {
// String id = "GO:0000007";
// String definition = gos.getTermDefinition( id );
// assertNotNull( definition );
// assertTrue( definition.startsWith( "I am a test definition" ) );
// }
@Test
public final void testGetChildrenPartOf() {
    String id = "GO:0023025";
    OntologyTerm termForId = GeneOntologyServiceTest.gos.getTermForId(id);
    assertNotNull(termForId);
    Collection<OntologyTerm> terms = GeneOntologyServiceTest.gos.getAllChildren(termForId, true);
    // has a part.
    assertEquals(1, terms.size());
}
Also used : OntologyTerm(ubic.basecode.ontology.model.OntologyTerm) Test(org.junit.Test)

Example 22 with OntologyTerm

use of ubic.basecode.ontology.model.OntologyTerm in project Gemma by PavlidisLab.

the class GeneOntologyServiceTest method testAsRegularGoId.

@Test
public final void testAsRegularGoId() {
    String id = "GO:0000107";
    OntologyTerm termForId = GeneOntologyServiceTest.gos.getTermForId(id);
    assertNotNull(termForId);
    String formatedId = GeneOntologyServiceTest.gos.asRegularGoId(termForId);
    assertEquals(id, formatedId);
}
Also used : OntologyTerm(ubic.basecode.ontology.model.OntologyTerm) Test(org.junit.Test)

Example 23 with OntologyTerm

use of ubic.basecode.ontology.model.OntologyTerm in project Gemma by PavlidisLab.

the class GeneOntologyServiceTest method testGetAllChildren.

@Test
public final void testGetAllChildren() {
    String id = "GO:0016791";
    OntologyTerm termForId = GeneOntologyServiceTest.gos.getTermForId(id);
    assertNotNull(termForId);
    Collection<OntologyTerm> terms = GeneOntologyServiceTest.gos.getAllChildren(termForId);
    assertEquals(136, terms.size());
}
Also used : OntologyTerm(ubic.basecode.ontology.model.OntologyTerm) Test(org.junit.Test)

Example 24 with OntologyTerm

use of ubic.basecode.ontology.model.OntologyTerm in project Gemma by PavlidisLab.

the class GeneOntologyServiceTest method testGetChildren.

@Test
public final void testGetChildren() {
    String id = "GO:0016791";
    OntologyTerm termForId = GeneOntologyServiceTest.gos.getTermForId(id);
    assertNotNull(termForId);
    Collection<OntologyTerm> terms = GeneOntologyServiceTest.gos.getChildren(termForId);
    assertEquals(65, terms.size());
}
Also used : OntologyTerm(ubic.basecode.ontology.model.OntologyTerm) Test(org.junit.Test)

Example 25 with OntologyTerm

use of ubic.basecode.ontology.model.OntologyTerm in project Gemma by PavlidisLab.

the class ArrayDesignAnnotationServiceImpl method generateAnnotationFile.

@Override
public int generateAnnotationFile(Writer writer, Map<CompositeSequence, Collection<BioSequence2GeneProduct>> genesWithSpecificity, OutputType ty) throws IOException {
    int compositeSequencesProcessed = 0;
    int simple = 0;
    int empty = 0;
    int complex = 0;
    // we used LinkedHasSets to keep everything in a predictable order - this is important for the gene symbols,
    // descriptions and NCBIIds (but not important for GO terms). When a probe maps to multiple genes, we list those
    // three items for the genes in the same order. There is a feature request to make
    // the order deterministic (i.e.,lexicographic sort), this could be done by using little gene objects or whatever.
    Collection<OntologyTerm> goTerms = new LinkedHashSet<>();
    Set<String> genes = new LinkedHashSet<>();
    Set<String> geneDescriptions = new LinkedHashSet<>();
    Set<String> geneIds = new LinkedHashSet<>();
    Set<String> ncbiIds = new LinkedHashSet<>();
    Map<Gene, Collection<VocabCharacteristic>> goMappings = this.getGOMappings(genesWithSpecificity);
    for (CompositeSequence cs : genesWithSpecificity.keySet()) {
        Collection<BioSequence2GeneProduct> geneclusters = genesWithSpecificity.get(cs);
        if (++compositeSequencesProcessed % 2000 == 0 && ArrayDesignAnnotationServiceImpl.log.isInfoEnabled()) {
            ArrayDesignAnnotationServiceImpl.log.info("Processed " + compositeSequencesProcessed + "/" + genesWithSpecificity.size() + " compositeSequences " + empty + " empty; " + simple + " simple; " + complex + " complex;");
        }
        if (geneclusters.isEmpty()) {
            this.writeAnnotationLine(writer, cs.getName(), "", "", null, "", "");
            empty++;
            continue;
        }
        if (geneclusters.size() == 1) {
            // common case, do it quickly.
            BioSequence2GeneProduct b2g = geneclusters.iterator().next();
            Gene g = b2g.getGeneProduct().getGene();
            goTerms = this.getGoTerms(goMappings.get(g), ty);
            String gemmaId = g.getId() == null ? "" : g.getId().toString();
            String ncbiId = g.getNcbiGeneId() == null ? "" : g.getNcbiGeneId().toString();
            this.writeAnnotationLine(writer, cs.getName(), g.getOfficialSymbol(), g.getOfficialName(), goTerms, gemmaId, ncbiId);
            simple++;
            continue;
        }
        goTerms.clear();
        genes.clear();
        geneDescriptions.clear();
        geneIds.clear();
        ncbiIds.clear();
        for (BioSequence2GeneProduct bioSequence2GeneProduct : geneclusters) {
            Gene g = bioSequence2GeneProduct.getGeneProduct().getGene();
            genes.add(g.getOfficialSymbol());
            geneDescriptions.add(g.getOfficialName());
            geneIds.add(g.getId().toString());
            Integer ncbiGeneId = g.getNcbiGeneId();
            if (ncbiGeneId != null) {
                ncbiIds.add(ncbiGeneId.toString());
            }
            goTerms.addAll(this.getGoTerms(goMappings.get(g), ty));
        }
        String geneString = StringUtils.join(genes, "|");
        String geneDescriptionString = StringUtils.join(geneDescriptions, "|");
        String geneIdsString = StringUtils.join(geneIds, "|");
        String ncbiIdsString = StringUtils.join(ncbiIds, "|");
        this.writeAnnotationLine(writer, cs.getName(), geneString, geneDescriptionString, goTerms, geneIdsString, ncbiIdsString);
        complex++;
    }
    writer.close();
    return compositeSequencesProcessed;
}
Also used : BioSequence2GeneProduct(ubic.gemma.model.association.BioSequence2GeneProduct) OntologyTerm(ubic.basecode.ontology.model.OntologyTerm) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence) Gene(ubic.gemma.model.genome.Gene)

Aggregations

OntologyTerm (ubic.basecode.ontology.model.OntologyTerm)73 Test (org.junit.Test)13 VocabCharacteristic (ubic.gemma.model.common.description.VocabCharacteristic)13 Gene (ubic.gemma.model.genome.Gene)11 OntologyResource (ubic.basecode.ontology.model.OntologyResource)8 HashSet (java.util.HashSet)6 StopWatch (org.apache.commons.lang3.time.StopWatch)6 CharacteristicValueObject (ubic.gemma.model.genome.gene.phenotype.valueObject.CharacteristicValueObject)6 BufferedReader (java.io.BufferedReader)3 ConcurrentHashSet (org.compass.core.util.concurrent.ConcurrentHashSet)3 Element (org.w3c.dom.Element)3 OntologyIndividual (ubic.basecode.ontology.model.OntologyIndividual)3 EntityNotFoundException (ubic.gemma.core.association.phenotype.PhenotypeExceptions.EntityNotFoundException)3 Characteristic (ubic.gemma.model.common.description.Characteristic)3 GeneEvidenceValueObject (ubic.gemma.model.genome.gene.phenotype.valueObject.GeneEvidenceValueObject)3 Resource (com.hp.hpl.jena.rdf.model.Resource)2 FileReader (java.io.FileReader)2 SocketException (java.net.SocketException)2 Collection (java.util.Collection)2 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)2