use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class DatasetImporterForZOVERTest method importDataset.
@Test
public void importDataset() throws StudyImporterException {
List<Map<String, String>> interactions = new ArrayList<>();
DatasetImporterForZOVER importer = new DatasetImporterForZOVER(null, null);
importer.setDatabases(Collections.singletonList(DatasetImporterForZOVER.ZOVER_CHIROPTERA));
importer.setInteractionListener(new InteractionListener() {
@Override
public void on(Map<String, String> interaction) throws StudyImporterException {
interactions.add(interaction);
}
});
DatasetImpl dataset = new DatasetImpl("some/namespace", new ResourceService() {
@Override
public InputStream retrieve(URI resourceName) throws IOException {
InputStream is = null;
if (StringUtils.equals("http://www.mgc.ac.cn/cgi-bin/ZOVER/lineage2json1.pl?type=viruses&host=chiroptera", resourceName.toString())) {
is = getClass().getResourceAsStream("zover/chiroptera_chopped.json");
} else if (StringUtils.equals("http://www.mgc.ac.cn/ZOVER/json/chiroptera_viruses_363628.json", resourceName.toString())) {
is = getClass().getResourceAsStream("zover/chiroptera_viruses_363628.json");
}
return is;
}
}, URI.create("some:uri")) {
};
importer.setDataset(dataset);
importer.importStudy();
assertThat(interactions.size(), is(1));
Map<String, String> interaction = interactions.get(0);
assertThat(interaction.get(SOURCE_TAXON_NAME), is("Torque teno Tadarida brasiliensis virus"));
assertThat(interaction.get(SOURCE_TAXON_ID), is("NCBI:1543419"));
assertThat(interaction.get(TARGET_TAXON_NAME), is("Tadarida brasiliensis"));
assertThat(interaction.get(TARGET_TAXON_ID), is("NCBI:9438"));
assertThat(interaction.get(INTERACTION_TYPE_NAME), is("pathogenOf"));
assertThat(interaction.get(INTERACTION_TYPE_ID), is("http://purl.obolibrary.org/obo/RO_0002556"));
assertThat(interaction.get(REFERENCE_CITATION), is(nullValue()));
assertThat(interaction.get(REFERENCE_URL), is("https://www.ncbi.nlm.nih.gov/nuccore/KM434181"));
assertThat(interaction.get(REFERENCE_DOI), is(nullValue()));
assertThat(interaction.get(REFERENCE_ID), is("urn:lsid:cn.ac.mgc:tick:363628"));
}
use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class NodeFactoryWithDatasetContextTest method createStudy.
@Test
public void createStudy() {
NodeFactory factory = Mockito.mock(NodeFactory.class);
DatasetImpl dataset = new DatasetImpl("some/namespace", URI.create("some:uri"), inStream -> inStream);
NodeFactoryWithDatasetContext factoryWithDS = new NodeFactoryWithDatasetContext(factory, dataset);
StudyImpl study = new StudyImpl("some title", new DOI("123", "abc"), "some citation");
study.setExternalId("some:id");
factoryWithDS.createStudy(study);
ArgumentCaptor<Study> argument = ArgumentCaptor.forClass(Study.class);
verify(factory).createStudy(argument.capture());
assertEquals("some title", argument.getValue().getTitle());
assertEquals("some citation", argument.getValue().getCitation());
assertEquals("10.123/abc", argument.getValue().getDOI().toString());
assertEquals("some:id", argument.getValue().getExternalId());
}
use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class DatasetImplTest method useCitationFromMultipleTableDefinitions.
@Test
public void useCitationFromMultipleTableDefinitions() throws IOException {
Dataset dataset = new DatasetImpl("some/namespace", URI.create("some:uri"), inStream -> inStream);
dataset.setConfig(new ObjectMapper().readTree(getClass().getResourceAsStream("/org/eol/globi/data/test-meta-globi-default-external-schemas.json")));
assertThat(dataset.getCitation(), is("Seltzer, Carrie; Wysocki, William; Palacios, Melissa; Eickhoff, Anna; Pilla, Hannah; Aungst, Jordan; Mercer, Aaron; Quicho, Jamie; Voss, Neil; Xu, Man; J. Ndangalasi, Henry; C. Lovett, Jon; J. Cordeiro, Norbert (2015): Plant-animal interactions from Africa. figshare. https://dx.doi.org/10.6084/m9.figshare.1526128"));
}
use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class DatasetProxyTest method getMappedResource.
@Test
public void getMappedResource() throws IOException, URISyntaxException {
URL original = getClass().getResource("/org/globalbioticinteractions/content/original.txt");
URL proxied = getClass().getResource("/org/globalbioticinteractions/content/proxied.txt");
JsonNode configProxy = new ObjectMapper().readTree("{ \"resources\": { \"archive\": \"" + proxied.toURI() + "\" } }");
DatasetImpl dataset = new DatasetImpl("some/namespace", URI.create("http://example.com"), inStream -> inStream);
dataset.setConfig(null);
final String hashOfOriginal = "0682c5f2076f099c34cfdd15a9e063849ed437a49677e6fcc5b4198c76575be5";
final String hashOfProxied = "b09f17ea1b5ca77b7a01a3ed62c84b38578817eddb34f827666c898a27504f67";
DatasetProxy datasetProxy = new DatasetProxy(dataset);
datasetProxy.setConfig(configProxy);
DatasetProxy testDataset = datasetProxy;
TestHashUtil.assertContentHash(testDataset.retrieve(URI.create("archive")), hashOfProxied);
JsonNode config = new ObjectMapper().readTree("{ \"resources\": { \"archive\": \"" + original.toURI() + "\" } }");
testDataset = getTestDataset(config, configProxy);
TestHashUtil.assertContentHash(testDataset.retrieve(URI.create("archive")), hashOfProxied);
testDataset = getTestDataset(config, null);
TestHashUtil.assertContentHash(testDataset.retrieve(URI.create("archive")), hashOfOriginal);
}
use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class DatasetImportUtilTest method listDependencies.
@Test
public void listDependencies() throws StudyImporterException, IOException {
String jsonConfig = "{" + " \"format\": \"dwca\", " + " \"citation\": \"The MSB Division of Parasitology Collection\"," + " \"url\": \"http://ipt.vertnet.org:8080/ipt/archive.do?r=msb_para\"," + " \"references\": [" + " {" + " \"format\": \"dwca\"," + " \"url\": \"http://ipt.vertnet.org:8080/ipt/archive.do?r=msb_host\"," + " \"citation\": \"The MSB Division of Host Collection\"" + " }, {" + " \"format\": \"dwca\"," + " \"url\": \"http://ipt.vertnet.org:8080/ipt/archive.do?r=msb_host2\"," + " \"citation\": \"The MSB Division of Host Collection2\"" + " }]" + "}";
final DatasetImpl datasetOrig = new DatasetImpl("name/space", URI.create("some:uri"), in -> in);
JsonNode objectNode = new ObjectMapper().readTree(jsonConfig);
datasetOrig.setConfig(objectNode);
final List<Dataset> references = getReferences(datasetOrig);
assertThat(references.size(), Is.is(2));
}
Aggregations