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());
}
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);
}
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());
}
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());
}
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;
}
Aggregations