use of org.eol.globi.domain.TaxonNode in project eol-globi-data by jhpoelen.
the class NodeUtil method connectTaxa.
public static void connectTaxa(Taxon taxon, TaxonNode taxonNode, GraphDatabaseService graphDb, RelTypes relType) {
Transaction tx = graphDb.beginTx();
try {
TaxonNode sameAsTaxon = new TaxonNode(graphDb.createNode());
TaxonUtil.copy(taxon, sameAsTaxon);
taxonNode.getUnderlyingNode().createRelationshipTo(sameAsTaxon.getUnderlyingNode(), asNeo4j(relType));
tx.success();
} finally {
tx.finish();
}
}
use of org.eol.globi.domain.TaxonNode in project eol-globi-data by jhpoelen.
the class ExporterSiteMapForNames method export.
@Override
public void export(GraphDatabaseService graphDatabase, String baseDir) throws StudyImporterException {
Set<String> names = new HashSet<String>();
names.add("Homo sapiens");
// just do it once
final List<Study> allStudies = NodeUtil.findAllStudies(graphDatabase);
for (Study allStudy : allStudies) {
final Iterable<Relationship> specimens = NodeUtil.getSpecimens(allStudy);
for (Relationship specimen : specimens) {
final Iterable<Relationship> relationships = specimen.getEndNode().getRelationships(Direction.OUTGOING, NodeUtil.asNeo4j(RelTypes.CLASSIFIED_AS));
if (relationships.iterator().hasNext()) {
final Node endNode = relationships.iterator().next().getEndNode();
final TaxonNode taxonNode = new TaxonNode(endNode);
names.add(taxonNode.getName());
}
}
}
final String queryParamName = "interactionType=interactsWith&sourceTaxon=";
final String siteMapLocation = "https://depot.globalbioticinteractions.org/snapshot/target/data/sitemap/names/";
SiteMapUtils.generateSiteMap(names, baseDir, queryParamName, siteMapLocation);
}
use of org.eol.globi.domain.TaxonNode in project eol-globi-data by jhpoelen.
the class StudyImporterForGeminaTest method importFewLines.
@Test
public void importFewLines() throws StudyImporterException {
StudyImporterForGemina importer = new StudyImporterForGemina(new TestParserFactory(firstFewLines), nodeFactory);
importStudy(importer);
assertHuman();
Taxon taxon = taxonIndex.findTaxonByName("Bacillus anthracis");
assertThat(taxon, is(notNullValue()));
assertThat(taxon.getExternalId(), is("NCBI:1392"));
List<String> antraxHosts = new ArrayList<String>();
Iterable<Relationship> relationships = ((NodeBacked) taxon).getUnderlyingNode().getRelationships(NodeUtil.asNeo4j(RelTypes.CLASSIFIED_AS), Direction.INCOMING);
for (Relationship rel : relationships) {
Node specimen = rel.getStartNode();
Iterable<Relationship> pathogenRels = specimen.getRelationships(Direction.OUTGOING, NodeUtil.asNeo4j(InteractType.PATHOGEN_OF));
for (Relationship pathogenRel : pathogenRels) {
Relationship singleRelationship = pathogenRel.getEndNode().getSingleRelationship(NodeUtil.asNeo4j(RelTypes.CLASSIFIED_AS), Direction.OUTGOING);
antraxHosts.add(new TaxonNode(singleRelationship.getEndNode()).getName());
}
}
assertThat(antraxHosts, hasItem("Equus caballus"));
}
use of org.eol.globi.domain.TaxonNode in project eol-globi-data by jhpoelen.
the class LinkerTaxonIndexTest method assertSingleHit.
protected void assertSingleHit(String query) {
IndexHits<Node> hits;
Node next;
hits = getGraphDb().index().forNodes(LinkerTaxonIndex.INDEX_TAXON_NAMES_AND_IDS).query(query);
next = hits.next();
assertThat(new TaxonNode(next).getName(), is("Homo sapiens"));
assertThat(hits.hasNext(), is(false));
hits.close();
}
use of org.eol.globi.domain.TaxonNode in project eol-globi-data by jhpoelen.
the class LinkerTestUtil method assertHasOther.
public static Collection<String> assertHasOther(String name, int expectedCount, TaxonIndex taxonIndex, RelTypes relType) throws NodeFactoryException {
Set<String> externalIds = new HashSet<>();
Taxon taxon1 = taxonIndex.findTaxonByName(name);
assertThat(taxon1, is(notNullValue()));
assertThat(taxon1.getName(), is(name));
Iterable<Relationship> rels = ((NodeBacked) taxon1).getUnderlyingNode().getRelationships(NodeUtil.asNeo4j(relType), Direction.OUTGOING);
for (Relationship rel : rels) {
externalIds.add(new TaxonNode(rel.getEndNode()).getExternalId());
}
assertThat("expected [" + expectedCount + "] relationships for [" + name + "]: [" + externalIds.toString() + "]", externalIds.size(), is(expectedCount));
return externalIds;
}
Aggregations