use of org.eol.globi.domain.Study in project eol-globi-data by jhpoelen.
the class StudyImporterForBioInfoTest method importAbout600Records.
@Test
public void importAbout600Records() throws StudyImporterException {
StudyImporter importer = new StudyImporterTestFactory(nodeFactory).instantiateImporter((Class) StudyImporterForBioInfo.class);
final List<String> msgs = new ArrayList<String>();
importer.setLogger(new ImportLogger() {
@Override
public void warn(LogContext study, String message) {
msgs.add(message);
}
@Override
public void info(LogContext study, String message) {
msgs.add(message);
}
@Override
public void severe(LogContext study, String message) {
msgs.add(message);
}
});
// limit the number of line to be imported to make test runs reasonably fast
importer.setFilter(recordNumber -> recordNumber < 1000 || recordNumber == 4585 || (recordNumber > 47310 && recordNumber < 47320) || (recordNumber > 24220 && recordNumber < 24340));
importStudy(importer);
Study vectorStudy = nodeFactory.findStudy(TaxonomyProvider.BIO_INFO + "ref:153303");
assertThat(vectorStudy, is(notNullValue()));
Study study = nodeFactory.findStudy(TaxonomyProvider.BIO_INFO + "ref:60527");
for (Relationship collectedRel : NodeUtil.getSpecimens(study)) {
SpecimenNode specimen = new SpecimenNode(collectedRel.getEndNode());
String externalId = specimen.getExternalId();
assertThat(externalId, is(notNullValue()));
assertThat(externalId, containsString(TaxonomyProvider.BIO_INFO + "rel:"));
}
ExecutionEngine engine = new ExecutionEngine(getGraphDb());
ExecutionResult result = engine.execute("START taxon = node:taxons('*:*') MATCH taxon<-[:CLASSIFIED_AS]-specimen-[r]->targetSpecimen-[:CLASSIFIED_AS]->targetTaxon RETURN taxon.externalId + ' ' + lower(type(r)) + ' ' + targetTaxon.externalId as interaction");
ResourceIterator<Map<String, Object>> iterator = result.iterator();
List<String> interactions = new ArrayList<String>();
while (iterator.hasNext()) {
Map<String, Object> next = iterator.next();
interactions.add((String) next.get("interaction"));
}
assertThat(interactions, hasItem("NBN:NHMSYS0000455771 interacts_with NBN:NBNSYS0000024890"));
assertThat(interactions, hasItem("NBN:NBNSYS0000030148 endoparasitoid_of NBN:NHMSYS0000502366"));
assertThat(interactions, hasItem("NBN:NHMSYS0000500943 has_endoparasitoid NBN:NBNSYS0000030148"));
assertThat(interactions, hasItem("bioinfo:taxon:160260 has_vector bioinfo:taxon:162065"));
assertThat(study.getTitle(), is("bioinfo:ref:60527"));
assertThat(study.getSource(), is("Food Webs and Species Interactions in the Biodiversity of UK and Ireland (Online). 2015. Data provided by Malcolm Storey. Also available from http://bioinfo.org.uk."));
assertThat("found unexpected log messages: [" + StringUtils.join(msgs, "\n") + "]", msgs.size(), is(1));
assertThat(msgs.get(0), is("empty/no taxon name for bioinfo taxon id [149359] on line [4171]"));
}
use of org.eol.globi.domain.Study in project eol-globi-data by jhpoelen.
the class StudyImporterForBlewettTest method importAll.
@Test
public void importAll() throws StudyImporterException {
StudyImporter importer = new StudyImporterTestFactory(nodeFactory).instantiateImporter((Class) StudyImporterForBlewett.class);
importStudy(importer);
Study study = getStudySingleton(getGraphDb());
Iterable<Relationship> specimens = NodeUtil.getSpecimens(study);
int count = 0;
for (Relationship specimen : specimens) {
count++;
}
assertThat(count, is(1824));
assertNotNull(taxonIndex.findTaxonByName("Centropomus undecimalis"));
Taxon taxonOfType = taxonIndex.findTaxonByName("Cal sapidus");
assertThat(taxonOfType.getName(), is("Cal sapidus"));
assertNotNull(taxonIndex.findTaxonByName("Ort chrysoptera"));
}
use of org.eol.globi.domain.Study in project eol-globi-data by jhpoelen.
the class StudyImporterForCruaudTest method importAll.
@Test
public void importAll() throws NodeFactoryException, StudyImporterException {
StudyImporterForCruaud importer = new StudyImporterForCruaud(new ParserFactoryLocal(), nodeFactory);
importer.setGeoNamesService(new GeoNamesService() {
@Override
public boolean hasTermForLocale(String locality) {
return true;
}
@Override
public LatLng findLatLng(String locality) throws IOException {
return new LatLng(0, 0);
}
});
importStudy(importer);
List<Study> allStudies = NodeUtil.findAllStudies(getGraphDb());
assertThat(allStudies.size(), is(1));
assertThat(taxonIndex.findTaxonByName("Agaon sp."), is(notNullValue()));
assertThat(taxonIndex.findTaxonByName("Ficus chapaensis"), is(notNullValue()));
assertThat(allStudies.get(0).getSource(), is(notNullValue()));
}
use of org.eol.globi.domain.Study in project eol-globi-data by jhpoelen.
the class StudyImporterForDunneTest method importStudy.
@Test
public void importStudy() throws StudyImporterException, IOException {
String configJson = "{ \"citation\": \"blabla\",\n" + " \"format\": \"dunne\",\n" + " \"resources\": {\n" + " \"nodes\": \"https://raw.githubusercontent.com/globalbioticinteractions/dunne2016SanakIntertidal/master/nodes.tsv\",\n" + " \"links\": \"https://raw.githubusercontent.com/globalbioticinteractions/dunne2016SanakIntertidal/master/links.tsv\"\n" + " },\n" + " \"location\": {\n" + " \"locality\": {\n" + " \"id\": \"GEONAMES:5873327\",\n" + " \"name\": \"Sanak Island, Alaska, USA\"\n" + " },\n" + " \"latitude\": 60,\n" + " \"longitude\": 60\n" + " }\n" + "}";
JsonNode jsonNode = new ObjectMapper().readTree(configJson);
DatasetImpl dunne2016 = new DatasetImpl("dunne2016", URI.create("http://example.com"));
dunne2016.setConfig(jsonNode);
ParserFactory parserFactory = new ParserFactoryForDataset(dunne2016);
StudyImporterForDunne importer = new StudyImporterForDunne(parserFactory, nodeFactory);
importer.setDataset(dunne2016);
importStudy(importer);
Study study = getStudySingleton(getGraphDb());
assertThat(study, is(notNullValue()));
Iterable<Relationship> specimens = NodeUtil.getSpecimens(study);
int count = 0;
for (Relationship specimen : specimens) {
count++;
}
assertThat(count, is(1804 * 2));
}
use of org.eol.globi.domain.Study in project eol-globi-data by jhpoelen.
the class StudyImporterForDunneTest method importStudy2.
@Test
public void importStudy2() throws StudyImporterException, IOException {
String configJson = "{ \"citation\": \"blabla\",\n" + " \"format\": \"dunne\",\n" + " \"resources\": {\n" + " \"nodes\": \"https://raw.githubusercontent.com/globalbioticinteractions/dunne2016SanakNearshore/master/nodes.tsv\",\n" + " \"links\": \"https://raw.githubusercontent.com/globalbioticinteractions/dunne2016SanakNearshore/master/links.tsv\"\n" + " },\n" + " \"location\": {\n" + " \"locality\": {\n" + " \"id\": \"GEONAMES:5873327\",\n" + " \"name\": \"Sanak Island, Alaska, USA\"\n" + " },\n" + " \"latitude\": 60,\n" + " \"longitude\": 60\n" + " }\n" + "}";
DatasetImpl dunne2016 = new DatasetImpl("dunne2016", URI.create("http://example.com"));
dunne2016.setConfig(new ObjectMapper().readTree(configJson));
ParserFactory parserFactory = new ParserFactoryForDataset(dunne2016);
StudyImporterForDunne importer = new StudyImporterForDunne(parserFactory, nodeFactory);
importer.setDataset(dunne2016);
importStudy(importer);
Study study = getStudySingleton(getGraphDb());
assertThat(study, is(notNullValue()));
assertThat(study.getSource(), containsString("Accessed at "));
Iterable<Relationship> specimens = NodeUtil.getSpecimens(study);
int count = 0;
for (Relationship specimen : specimens) {
count++;
}
assertThat(count, is(6774 * 2));
}
Aggregations