use of org.eol.globi.process.InteractionListener in project eol-globi-data by jhpoelen.
the class DatasetImporterForSPIRETest method phytoplanktonUnlikelyPredators.
@Test
public void phytoplanktonUnlikelyPredators() throws IOException, StudyImporterException {
RDFDefaultErrorHandler.silent = true;
DatasetImporterForSPIRE importer = createImporter();
final List<String> predators = new ArrayList<String>();
importer.setInteractionListener(new InteractionListener() {
@Override
public void on(Map<String, String> interaction) {
if (!DatasetImporterForSPIRE.isValid(interaction)) {
predators.add(interaction.get(DatasetImporterForSPIRE.PREDATOR_NAME));
}
}
});
importStudy(importer);
assertThat(predators, hasItem("phytoplankton"));
}
use of org.eol.globi.process.InteractionListener in project eol-globi-data by jhpoelen.
the class DatasetImporterForGrayTest method importLines.
@Test
public void importLines() throws IOException, StudyImporterException {
DatasetImporterForGray gray = createImporter(nodeFactory);
final List<Map<String, String>> maps = new ArrayList<Map<String, String>>();
gray.importLinks(IOUtils.toInputStream(firstFewLines(), StandardCharsets.UTF_8), new InteractionListener() {
@Override
public void on(final Map<String, String> interaction) {
maps.add(interaction);
}
}, null);
resolveNames();
assertThat(maps.size(), is(4));
Map<String, String> firstLink = maps.get(0);
assertThat(firstLink.get(TaxonUtil.SOURCE_TAXON_NAME), is("Ancylus fluviatilis"));
assertThat(firstLink.get(DatasetImporterForTSV.SOURCE_LIFE_STAGE_NAME), is(nullValue()));
assertThat(firstLink.get(TaxonUtil.TARGET_TAXON_NAME), is("FPOM"));
assertThat(firstLink.get(DatasetImporterForTSV.TARGET_LIFE_STAGE_NAME), is(nullValue()));
assertThat(firstLink.get(DatasetImporterForTSV.REFERENCE_CITATION), is("Ledger, M.E., Brown, L.E., Edwards, F., Milner, A.M. & Woodward, G. (2012) Drought alters the structure and functioning of complex food webs. Nature Climate Change."));
assertThat(firstLink.get(DatasetImporterForTSV.REFERENCE_ID), is("10.5281/zenodo.13751/source.id/50"));
assertStaticInfo(firstLink);
Map<String, String> secondLink = maps.get(1);
assertThat(secondLink.get(TaxonUtil.SOURCE_TAXON_NAME), is("Ancylus fluviatilis"));
assertThat(secondLink.get(TaxonUtil.TARGET_TAXON_NAME), is("CPOM"));
assertThat(secondLink.get(DatasetImporterForTSV.BASIS_OF_RECORD_NAME), is("observed"));
assertStaticInfo(secondLink);
}
use of org.eol.globi.process.InteractionListener in project eol-globi-data by jhpoelen.
the class DatasetImporterForDBatVirTest method parseInteractionsFull.
@Test
public void parseInteractionsFull() throws IOException, StudyImporterException {
InputStream first2 = new GZIPInputStream(getClass().getResourceAsStream("/org/eol/globi/data/dbatvir/dbatvir.json.gz"));
List<Map<String, String>> links = new ArrayList<>();
InteractionListener interactionListener = links::add;
DatasetImporterForDBatVir.parseInteractions(first2, interactionListener);
assertThat(links.size(), Is.is(11164));
assertThat(links.get(0).get(SOURCE_TAXON_NAME), Is.is("Eptesicus nilssoni"));
assertThat(links.get(0).get(SOURCE_TAXON_ID), Is.is("NCBI:59451"));
assertThat(links.get(0).get(INTERACTION_TYPE_ID), Is.is("http://purl.obolibrary.org/obo/RO_0002453"));
assertThat(links.get(0).get(INTERACTION_TYPE_NAME), Is.is("hostOf"));
assertThat(links.get(0).get(TARGET_TAXON_NAME), Is.is("ZV2011"));
assertThat(links.get(0).get(TARGET_TAXON_ID), Is.is("NCBI:2706560"));
assertThat(links.get(0).get(TARGET_TAXON_PATH), Is.is("Phenuiviridae | Zwiesel bat banyangvirus | ZV2011"));
assertThat(links.get(0).get(TARGET_TAXON_PATH_IDS), Is.is(" | NCBI:2706560 | "));
assertThat(links.get(0).get(TARGET_TAXON_PATH_NAMES), Is.is("family | species | strain"));
assertThat(links.get(0).get(DatasetImporterForMetaTable.EVENT_DATE), Is.is("2011"));
assertThat(links.get(0).get(LOCALITY_NAME), Is.is("Germany"));
assertThat(links.get(0).get(REFERENCE_ID), Is.is("http://www.ncbi.nlm.nih.gov/pubmed/31992832"));
assertThat(links.get(0).get(REFERENCE_URL), Is.is("http://www.ncbi.nlm.nih.gov/pubmed/31992832"));
assertThat(links.get(0).get(REFERENCE_CITATION), Is.is("Kohl C, Brinkmann A, Radonic A, Dabrowski PW, Nitsche A, Muhldorfer K, Wibbelt G, Kurth A, Zwiesel bat banyangvirus, a potentially zoonotic Huaiyangshan banyangvirus (Formerly known as SFTS)-like banyangvirus in Northern bats from Germany. Sci Rep 2020, 10(1):1370."));
}
use of org.eol.globi.process.InteractionListener in project eol-globi-data by jhpoelen.
the class DatasetImporterForGlobalWebDbTest method dietMatrices.
@Test
public void dietMatrices() throws StudyImporterException {
final AtomicInteger count = new AtomicInteger();
DatasetImporterForGlobalWebDb importer = new DatasetImporterForGlobalWebDb(null, null);
importer.setDataset(new DatasetLocal(inStream -> inStream));
importer.importDietMatrices(URI.create("classpath:/org/eol/globi/data/globalwebdb-test.zip"), matrixString -> {
try {
DatasetImporterForGlobalWebDb.parseDietMatrix(new InteractionListener() {
@Override
public void on(Map<String, String> interaction) throws StudyImporterException {
count.incrementAndGet();
}
}, matrixString, "a source citation");
} catch (IOException e) {
throw new StudyImporterException(e);
}
});
assertThat(count.get(), is(207));
}
use of org.eol.globi.process.InteractionListener in project eol-globi-data by jhpoelen.
the class DatasetImporterForMangalIT method importAll.
@Test
public void importAll() throws StudyImporterException {
AtomicInteger counter = new AtomicInteger(0);
DatasetImporterForMangal importer = new DatasetImporterForMangal(null, null);
importer.setDataset(new DatasetLocal(inStream -> inStream));
importer.setInteractionListener(new InteractionValidator(new InteractionListener() {
@Override
public void on(Map<String, String> interaction) throws StudyImporterException {
counter.incrementAndGet();
}
}, new NullImportLogger() {
@Override
public void warn(LogContext ctx, String message) {
fail("unexpected warning: [" + message + "]");
}
}));
importer.importStudy();
assertThat(counter.get() > 0, Is.is(true));
}
Aggregations