use of ubic.basecode.ontology.model.OntologyTerm in project Gemma by PavlidisLab.
the class ExperimentalDesignImporterImpl method termForCategoryLookup.
/**
* Does a lookup for the Ontology term to match the category.
*
* @param category category
* @return vocab characteristic
*/
private VocabCharacteristic termForCategoryLookup(String category, Collection<OntologyTerm> terms) {
OntologyTerm t = null;
String lookup = category.replaceAll("_", " ").toLowerCase();
for (OntologyTerm to : terms) {
if (to.getTerm().equals(category) || to.getTerm().equals(lookup)) {
t = to;
break;
}
}
if (t == null) {
throw new IllegalArgumentException("No term matches '" + category + "' - formalized to: " + lookup);
}
VocabCharacteristic vc = VocabCharacteristic.Factory.newInstance();
vc.setCategoryUri(t.getUri());
vc.setCategory(t.getTerm());
vc.setValueUri(t.getUri());
vc.setValue(t.getTerm());
vc.setEvidenceCode(GOEvidenceCode.IC);
return vc;
}
use of ubic.basecode.ontology.model.OntologyTerm in project Gemma by PavlidisLab.
the class ExternalDatabaseEvidenceImporterAbstractCLI method findOmimMeshInDiseaseOntology.
// step 1 using an OMIM or MESH to link to a disease id
private boolean findOmimMeshInDiseaseOntology(String meshOrOmimId, Gene gene, String pubmed, String evidenceCode, String description, String externalDatabase, String databaseLink, Collection<OntologyTerm> onParents) throws Exception {
String mappingType;
StringBuilder valuesUri = new StringBuilder();
StringBuilder originalPhenotype = new StringBuilder(meshOrOmimId);
String meshOrOmimIdValue = this.findDescriptionUsingTerm(meshOrOmimId);
// use the ontology to find description
if (meshOrOmimIdValue != null) {
originalPhenotype.append(" (").append(meshOrOmimIdValue.toLowerCase()).append(")");
}
// using parents
if (onParents != null) {
mappingType = PhenotypeMappingType.INFERRED_XREF.toString();
HashMap<String, Collection<OntologyTerm>> dieaseOn = this.meshToDiseaseTerms(onParents);
originalPhenotype.append(" PARENT: (");
for (String key : dieaseOn.keySet()) {
originalPhenotype.append(key).append(",");
}
originalPhenotype = new StringBuilder(StringUtils.removeEnd(originalPhenotype.toString(), ",") + ")");
for (Collection<OntologyTerm> colOn : dieaseOn.values()) {
for (OntologyTerm o : colOn) {
valuesUri.append(o.getUri()).append(";");
}
}
} else {
mappingType = PhenotypeMappingType.XREF.toString();
Collection<OntologyTerm> ontologyTerms = this.findOntologyTermsUriWithDiseaseId(meshOrOmimId);
for (OntologyTerm ontologyTerm : ontologyTerms) {
valuesUri.append(ontologyTerm.getUri()).append(";");
}
}
if (valuesUri.length() > 0) {
outFinalResults.write(gene.getOfficialSymbol() + "\t" + gene.getNcbiGeneId() + "\t" + pubmed + "\t" + evidenceCode + "\t" + description + "\t" + externalDatabase + "\t" + databaseLink + "\t" + mappingType + "\t" + originalPhenotype + "\t" + valuesUri + "\n");
return true;
}
return false;
}
use of ubic.basecode.ontology.model.OntologyTerm in project Gemma by PavlidisLab.
the class ExternalDatabaseEvidenceImporterAbstractCLI method findMapping.
void findMapping(String meshOrOmimId, Gene gene, String pubmed, String evidenceCode, String description, String annotatorKeyword, String externalDatabase, String databaseLink) throws Exception {
if (gene == null) {
throw new IllegalArgumentException("Called with a gene being null on line pubmed; " + pubmed);
}
boolean mappingFound;
// do without parents
mappingFound = this.findMapping(meshOrOmimId, gene, pubmed, evidenceCode, description, annotatorKeyword, externalDatabase, databaseLink, null);
if (!mappingFound && meshOrOmimId != null) {
OntologyTerm on = this.medicOntologyService.getTerm(this.changeMedicToUri(meshOrOmimId));
if (on != null) {
Collection<OntologyTerm> onParents = on.getParents(true);
// use omim/mesh parents
this.findMapping(meshOrOmimId, gene, pubmed, evidenceCode, description, annotatorKeyword, externalDatabase, databaseLink, onParents);
}
}
}
use of ubic.basecode.ontology.model.OntologyTerm in project Gemma by PavlidisLab.
the class ExternalDatabaseEvidenceImporterAbstractCLI method parseManualMappingFile.
private void parseManualMappingFile() throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(RgdDatabaseImporter.class.getResourceAsStream(ExternalDatabaseEvidenceImporterAbstractCLI.MANUAL_MAPPING)));
String line;
// skip first line, the headers
br.readLine();
// reads the manual file and put the data in a structure
while ((line = br.readLine()) != null) {
HashSet<String> col = new HashSet<>();
String[] tokens = line.split("\t");
String termId = tokens[0].trim().toLowerCase();
String valueUriStaticFile = tokens[1].trim();
String valueStaticFile = tokens[2].trim();
OntologyTerm ontologyTerm = this.findOntologyTermExistAndNotObsolote(valueUriStaticFile);
if (ontologyTerm != null) {
if (ontologyTerm.getLabel().equalsIgnoreCase(valueStaticFile)) {
if (manualDescriptionToValuesUriMapping.get(termId) != null) {
col = manualDescriptionToValuesUriMapping.get(termId);
}
col.add(valueUriStaticFile);
manualDescriptionToValuesUriMapping.put(termId, col);
keyToDescription.put(termId, valueStaticFile);
} else {
this.writeError("MANUAL VALUEURI AND VALUE DOESNT MATCH IN FILE: line" + line + "\t What the value supposed to be:" + ontologyTerm.getLabel());
}
} else {
this.writeError("MANUAL MAPPING FILE TERM OBSOLETE OR NOT EXISTANT: '" + valueUriStaticFile + "' " + " (" + valueStaticFile + ")");
}
}
}
use of ubic.basecode.ontology.model.OntologyTerm in project Gemma by PavlidisLab.
the class ExternalDatabaseEvidenceImporterAbstractCLI method findOntologyTermsUriWithDiseaseId.
private Collection<OntologyTerm> findOntologyTermsUriWithDiseaseId(String diseaseId) {
Collection<OntologyTerm> terms = new HashSet<>();
Collection<String> valuesUri = diseaseFileMappingFound.get(diseaseId);
if (valuesUri != null && !valuesUri.isEmpty()) {
for (String valueUri : valuesUri) {
OntologyTerm on = this.findOntologyTermExistAndNotObsolote(valueUri);
if (on != null) {
terms.add(on);
}
}
}
return terms;
}
Aggregations