use of ubic.basecode.ontology.ncbo.AnnotatorResponse in project Gemma by PavlidisLab.
the class ExternalDatabaseEvidenceImporterAbstractCLI method findWithAnnotator.
// step 3
private boolean findWithAnnotator(String meshOrOmimId, String keywordSearchAnnotator, String externalDatabase, boolean modifySearch, Collection<OntologyTerm> onParents, String child) throws Exception {
String usedChild = "";
if (child == null) {
usedChild = null;
}
if (onParents != null) {
for (OntologyTerm o : onParents) {
boolean found = this.findWithAnnotator(o.getLabel(), keywordSearchAnnotator, externalDatabase, modifySearch, null, meshOrOmimId);
if (found) {
return true;
}
}
return false;
}
String searchTerm = keywordSearchAnnotator.toLowerCase();
Collection<AnnotatorResponse> annotatorResponses = null;
String key = meshOrOmimId;
// we are not dealing with an omim identifier, gwas using this case for example
if (key == null) {
key = keywordSearchAnnotator;
}
if (modifySearch) {
searchTerm = ExternalDatabaseEvidenceImporterAbstractCLI.removeSpecificKeywords(keywordSearchAnnotator.toLowerCase());
}
if (!descriptionToIgnore.contains(searchTerm)) {
// we already know the answer for this term
if (cacheAnswerFromAnnotator.containsKey(searchTerm)) {
return false;
}
// search with the annotator and filter result to take out obsolete terms given
try {
annotatorResponses = this.removeNotExistAndObsolete(AnnotatorClient.findTerm(searchTerm));
} catch (SocketException e1) {
Thread.sleep(10000);
try {
annotatorResponses = this.removeNotExistAndObsolete(AnnotatorClient.findTerm(searchTerm));
} catch (SocketException e2) {
Thread.sleep(10000);
try {
annotatorResponses = this.removeNotExistAndObsolete(AnnotatorClient.findTerm(searchTerm));
} catch (SocketException e3) {
AbstractCLI.log.error("connection problem");
return false;
}
}
}
cacheAnswerFromAnnotator.put(searchTerm, annotatorResponses);
if (annotatorResponses != null && !annotatorResponses.isEmpty()) {
AnnotatorResponse annotatorResponse = annotatorResponses.iterator().next();
String condition = annotatorResponse.findCondition(modifySearch);
if (condition != null) {
OntologyTerm on = this.findOntologyTermExistAndNotObsolote(annotatorResponse.getValueUri());
if (on != null) {
searchTerm = AnnotatorClient.removeSpecialCharacters(searchTerm).replaceAll("\\+", " ");
if (modifySearch) {
searchTerm = searchTerm + " (" + keywordSearchAnnotator + ")";
}
String lineToWrite = key + "\t" + on.getUri() + "\t" + on.getLabel() + "\t" + searchTerm + "\t" + usedChild + "\t" + condition + "\t" + externalDatabase + "\n";
outMappingFoundBuffer.add(lineToWrite);
return true;
}
}
}
}
logRequestAnnotator.write(AnnotatorClient.removeSpecialCharacters(searchTerm).replaceAll("\\+", " ") + " (" + keywordSearchAnnotator + ")\t");
if (annotatorResponses != null && !annotatorResponses.isEmpty()) {
for (AnnotatorResponse ar : annotatorResponses) {
logRequestAnnotator.write(ar.getTxtMatched() + "; ");
}
}
logRequestAnnotator.write("\n");
logRequestAnnotator.flush();
return false;
}
Aggregations