Search in sources :

Example 41 with OntologyTerm

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

the class GeneOntologyServiceTest method testGetTermForId.

@Test
public final void testGetTermForId() {
    String id = "GO:0000310";
    OntologyTerm termForId = GeneOntologyServiceTest.gos.getTermForId(id);
    assertNotNull(termForId);
    assertEquals("xanthine phosphoribosyltransferase activity", termForId.getTerm());
}
Also used : OntologyTerm(ubic.basecode.ontology.model.OntologyTerm) Test(org.junit.Test)

Example 42 with OntologyTerm

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

the class GeneOntologyServiceTest method testAllParents.

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

Example 43 with OntologyTerm

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

the class GeneOntologyServiceTest method testGetParents.

@Test
public final void testGetParents() {
    String id = "GO:0000014";
    OntologyTerm termForId = GeneOntologyServiceTest.gos.getTermForId(id);
    assertNotNull(termForId);
    Collection<OntologyTerm> terms = GeneOntologyServiceTest.gos.getParents(termForId);
    for (OntologyTerm term : terms) {
        GeneOntologyServiceTest.log.info(term);
    }
    assertEquals(1, terms.size());
}
Also used : OntologyTerm(ubic.basecode.ontology.model.OntologyTerm) Test(org.junit.Test)

Example 44 with OntologyTerm

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

the class GeneOntologyServiceTest method testAllParents2.

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

Example 45 with OntologyTerm

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

the class DgaDatabaseImporter method processDGAFile.

private void processDGAFile() throws Exception {
    this.initFinalOutputFile(false, true);
    try (BufferedReader dgaReader = new BufferedReader(new FileReader(dgaFile))) {
        String line;
        while ((line = dgaReader.readLine()) != null) {
            // found a term
            if (line.contains("DOID")) {
                // this being of the url could change make sure its still correct if something doesn't work
                String valueUri = "http://purl.obolibrary.org/obo/DOID_" + this.findStringBetweenSpecialCharacter(line);
                String geneId = this.findStringBetweenSpecialCharacter(dgaReader.readLine(), "GeneID");
                String pubMedID = this.findStringBetweenSpecialCharacter(dgaReader.readLine(), "PubMedID");
                String geneRIF = this.findStringBetweenSpecialCharacter(dgaReader.readLine(), "GeneRIF");
                OntologyTerm o = this.findOntologyTermExistAndNotObsolote(valueUri);
                if (o != null) {
                    String geneSymbol = this.geneToSymbol(new Integer(geneId));
                    // gene do exist
                    if (geneSymbol != null) {
                        String key = geneId + pubMedID + geneRIF + o.getUri();
                        // if deep >3 always keep
                        int howDeepIdTerm = this.findHowManyParents(o, 0);
                        // keep leaf or deep enough or uri=DOID_162(cancer)
                        if (!((o.getChildren(true).size() != 0 && howDeepIdTerm < 2) || o.getUri().contains("DOID_162"))) {
                            // negative
                            if ((geneRIF.contains(" is not ") || geneRIF.contains(" not associated ") || geneRIF.contains(" no significant ") || geneRIF.contains(" no association ") || geneRIF.contains(" not significant ") || geneRIF.contains(" not expressed ")) && !geneRIF.contains("is associated") && !geneRIF.contains("is significant") && !geneRIF.contains("is not only") && !geneRIF.contains("is expressed")) {
                                if (this.lineToInclude(key)) {
                                    outFinalResults.write(geneSymbol + "\t" + geneId + "\t" + pubMedID + "\t" + "IEA" + "\t" + "GeneRIF: " + geneRIF + "\t" + DgaDatabaseImporter.DGA + "\t" + "" + "\t" + "" + "\t" + "" + "\t" + o.getUri() + "\t" + "1" + "\n");
                                }
                            } else // positive
                            {
                                if (this.lineToInclude(key)) {
                                    outFinalResults.write(geneSymbol + "\t" + geneId + "\t" + pubMedID + "\t" + "IEA" + "\t" + "GeneRIF: " + geneRIF + "\t" + DgaDatabaseImporter.DGA + "\t" + "" + "\t" + "" + "\t" + "" + "\t" + o.getUri() + "\t" + "" + "\n");
                                }
                            }
                            outFinalResults.flush();
                        }
                    } else {
                        AbstractCLI.log.info("gene NCBI no found in Gemma discard this eidence: ncbi: " + geneId);
                    }
                } else {
                    AbstractCLI.log.info("Ontology term not found in Ontology or obsolete : " + valueUri + " (normal that this happen sometimes)");
                }
            }
        }
        dgaReader.close();
        outFinalResults.close();
    }
}
Also used : BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) OntologyTerm(ubic.basecode.ontology.model.OntologyTerm)

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