use of org.nextprot.api.core.domain.CvTerm in project nextprot-api by calipho-sib.
the class TerminologyServiceTest method shouldReturnAUniprotSubcell.
@Test
public void shouldReturnAUniprotSubcell() {
CvTerm term = this.terminologyService.findCvTermByAccession("SL-0276");
assertEquals("UniprotSubcellularLocationCv", term.getOntology());
}
use of org.nextprot.api.core.domain.CvTerm in project nextprot-api by calipho-sib.
the class TerminologyUtils method populateTree.
static void populateTree(Tree.Node<CvTerm> currentNode, Map<String, CvTerm> termMap, int depth, final int maxDepth) {
if (depth > maxDepth)
return;
if (depth > 100)
throw new NextProtException("Getting stuck in building graph");
if (currentNode.getValue() == null || currentNode.getValue().getChildAccession() == null || currentNode.getValue().getChildAccession().isEmpty()) {
return;
}
for (String childAccession : currentNode.getValue().getChildAccession()) {
CvTerm childTerm = termMap.get(childAccession);
if (childTerm != null) {
if (currentNode.getChildren() == null) {
currentNode.setChildren(new ArrayList<Tree.Node<CvTerm>>());
}
Tree.Node<CvTerm> childNode = new Tree.Node<CvTerm>(childTerm);
childNode.setParents(Arrays.asList(currentNode));
currentNode.getChildren().add(childNode);
populateTree(childNode, termMap, depth + 1, maxDepth);
}
}
}
use of org.nextprot.api.core.domain.CvTerm in project nextprot-api by calipho-sib.
the class TerminologyServiceImpl method getAllAncestorTerms.
@Override
public List<CvTerm> getAllAncestorTerms(String cvTermAccession) {
CvTerm cvTerm = terminologyDao.findTerminologyByAccession(cvTermAccession);
CvTermGraph graph = cvTermGraphService.findCvTermGraph(TerminologyCv.valueOf(cvTerm.getOntology()));
return Arrays.stream(graph.getAncestors(cvTerm.getId().intValue())).boxed().map(graph::getCvTermAccessionById).map(terminologyDao::findTerminologyByAccession).collect(Collectors.toList());
}
use of org.nextprot.api.core.domain.CvTerm in project nextprot-api by calipho-sib.
the class SolrIndexingServiceImpl method indexTerminologies.
@Override
public String indexTerminologies() {
long seconds = System.currentTimeMillis() / 1000;
StringBuilder info = new StringBuilder();
logAndCollect(info, "terms indexing...STARTING at " + new Date());
String serverUrl = getServerUrl(CvIndex.NAME);
logAndCollect(info, "Solr server: " + serverUrl);
logAndCollect(info, "clearing term index");
SolrIndexer<CvTerm> indexer = new CvTermSolrIndexer(serverUrl);
List<CvTerm> allterms;
indexer.clearDatabase("");
logAndCollect(info, "getting terms for all terminologies");
allterms = terminologyService.findAllCVTerms();
logAndCollect(info, "start indexing of " + allterms.size() + " terms");
int termcnt = 0;
for (CvTerm term : allterms) {
indexer.add(term);
termcnt++;
if ((termcnt % 3000) == 0)
logAndCollect(info, termcnt + "/" + allterms.size() + " cv terms done");
}
indexer.addRemaing();
logAndCollect(info, "comitting");
indexer.commit();
seconds = (System.currentTimeMillis() / 1000 - seconds);
logAndCollect(info, termcnt + " terms indexed in " + seconds + " seconds ...END at " + new Date());
return info.toString();
}
use of org.nextprot.api.core.domain.CvTerm in project nextprot-api by calipho-sib.
the class GenerateSolrTerminologyIndex method start.
@Override
public void start(String[] args) {
TerminologyService terminologyService = getBean(TerminologyService.class);
int termcnt = 0;
String solrServer = System.getProperty("solr.server");
NPreconditions.checkNotNull(solrServer, "Please set solr.server variable. For example: java -Dsolr.server=\"http://localhost:8983/solr/npcvs1\"");
logger.info("Solr server: " + solrServer);
// eg: java -Dsolr.ontology="UniprotFamilyCv" (don't forget CamelCasing)
String ontologyToReindex = System.getProperty("solr.ontology");
SolrIndexer<CvTerm> indexer = new CvTermSolrIndexer(solrServer);
List<CvTerm> allterms;
if (ontologyToReindex == null) {
// No arg: index all ontologies
System.err.println("indexing: all ontologies");
logger.info("indexing all terminologies");
indexer.clearDatabase("");
allterms = terminologyService.findAllCVTerms();
} else {
// Index ontology given as VM argument
System.err.println("indexing: " + ontologyToReindex);
logger.info("indexing terminology: " + ontologyToReindex);
indexer.clearDatabase("filters:" + ontologyToReindex);
allterms = terminologyService.findCvTermsByOntology(ontologyToReindex);
}
for (CvTerm term : allterms) {
indexer.add(term);
termcnt++;
if ((termcnt % 3000) == 0)
logger.info(termcnt + "/" + allterms.size() + " cv terms done");
}
indexer.addRemaing();
logger.info("comitting");
indexer.commit();
logger.info(termcnt + " terms indexed...END");
}
Aggregations