use of org.eol.globi.domain.Specimen in project eol-globi-data by jhpoelen.
the class LinkerTrustyNanoPubsTest method populateDataset.
public NodeFactoryWithDatasetContext populateDataset(DatasetImpl dataset) throws NodeFactoryException {
TaxonIndex taxonIndex = getOrCreateTaxonIndex();
// see https://github.com/jhpoelen/eol-globi-data/wiki/Nanopubs
StudyImpl study = new StudyImpl("some study", "some source", "http://doi.org/123.23/222", "some study citation");
NodeFactoryWithDatasetContext factory = new NodeFactoryWithDatasetContext(nodeFactory, dataset);
Interaction interaction = factory.createInteraction(factory.createStudy(study));
TaxonImpl donaldTaxon = new TaxonImpl("donald duck", "NCBI:1234");
Specimen donald = factory.createSpecimen(interaction, donaldTaxon);
donald.classifyAs(taxonIndex.getOrCreateTaxon(donaldTaxon));
Taxon mickeyTaxon = new TaxonImpl("mickey mouse", "NCBI:4444");
Taxon mickeyTaxonEOL = taxonIndex.getOrCreateTaxon(new TaxonImpl("mickey mouse", "EOL:567"));
NodeUtil.connectTaxa(mickeyTaxon, (TaxonNode) mickeyTaxonEOL, getGraphDb(), RelTypes.SAME_AS);
Specimen mickey = factory.createSpecimen(interaction, mickeyTaxonEOL);
mickey.classifyAs(taxonIndex.getOrCreateTaxon(mickeyTaxonEOL));
donald.ate(mickey);
return factory;
}
use of org.eol.globi.domain.Specimen in project eol-globi-data by jhpoelen.
the class NameResolverTest method doNameResolving.
@Test
public void doNameResolving() throws NodeFactoryException, PropertyEnricherException {
Specimen human = nodeFactory.createSpecimen(nodeFactory.createStudy(new StudyImpl("bla", null, null, null)), new TaxonImpl("Homo sapiens", "NCBI:9606"));
Specimen animal = nodeFactory.createSpecimen(nodeFactory.createStudy(new StudyImpl("bla", null, null, null)), new TaxonImpl("Animalia", "WORMS:2"));
human.ate(animal);
Specimen fish = nodeFactory.createSpecimen(nodeFactory.createStudy(new StudyImpl("bla", null, null, null)), new TaxonImpl("Arius felis", "WORMS:158711"));
human.ate(fish);
assertNull(taxonIndex.findTaxonById("NCBI:9606"));
assertNull(taxonIndex.findTaxonByName("Homo sapiens"));
final NameResolver nameResolver = new NameResolver(getGraphDb(), new NonResolvingTaxonIndex(getGraphDb()));
nameResolver.setBatchSize(1L);
nameResolver.resolve();
assertAnimalia(taxonIndex.findTaxonById("WORMS:2"));
assertThat(taxonIndex.findTaxonByName("Arius felis"), is(notNullValue()));
Taxon homoSapiens = taxonIndex.findTaxonByName("Homo sapiens");
assertNotNull(homoSapiens);
assertThat(homoSapiens.getExternalId(), is("NCBI:9606"));
}
use of org.eol.globi.domain.Specimen in project eol-globi-data by jhpoelen.
the class StudyImporterForCruaud method importStudy.
@Override
public void importStudy() throws StudyImporterException {
LabeledCSVParser dataParser;
try {
dataParser = parserFactory.createParser(RESOURCE_PATH, CharsetConstant.UTF8);
} catch (IOException e) {
throw new StudyImporterException("failed to read resource [" + RESOURCE_PATH + "]", e);
}
try {
Study study = nodeFactory.getOrCreateStudy(new StudyImpl("cruaud", SOURCE, "http://dx.doi.org/10.1093/sysbio/sys068", null));
while (dataParser.getLine() != null) {
if (importFilter.shouldImportRecord((long) dataParser.getLastLineNumber())) {
try {
String parasiteName = StringUtils.trim(dataParser.getValueByLabel("Family and Species"));
String hostName = StringUtils.trim(dataParser.getValueByLabel("Natural host Ficus species"));
hostName = StringUtils.replace(hostName, "F.", "Ficus");
if (areNamesAvailable(parasiteName, hostName)) {
Specimen parasite = nodeFactory.createSpecimen(study, new TaxonImpl(parasiteName, null));
Specimen host = nodeFactory.createSpecimen(study, new TaxonImpl(hostName, null));
parasite.interactsWith(host, InteractType.PARASITE_OF);
String samplingLocation = StringUtils.trim(dataParser.getValueByLabel("Sampling location"));
if (getGeoNamesService().hasTermForLocale(samplingLocation)) {
LatLng pointForLocality = getGeoNamesService().findLatLng(samplingLocation);
if (pointForLocality == null) {
LOG.warn("no location associated with locality [" + samplingLocation + "]");
} else {
Location location = nodeFactory.getOrCreateLocation(new LocationImpl(pointForLocality.getLat(), pointForLocality.getLng(), null, null));
parasite.caughtIn(location);
host.caughtIn(location);
}
} else {
LOG.warn("no location associated with locality [" + samplingLocation + "]");
}
}
} catch (NodeFactoryException | NumberFormatException e) {
throw new StudyImporterException("failed to import line [" + (dataParser.lastLineNumber() + 1) + "]", e);
}
}
}
} catch (IOException e) {
throw new StudyImporterException("problem importing [" + RESOURCE_PATH + "]", e);
}
}
use of org.eol.globi.domain.Specimen in project eol-globi-data by jhpoelen.
the class StudyImporterForDunne method addLink.
private void addLink(Study study, Map<Integer, Taxon> taxonForNode, LabeledCSVParser links, Location location) throws StudyImporterException {
Integer consumerNodeID = Integer.parseInt(links.getValueByLabel("Consumer"));
Integer resourceNodeID = Integer.parseInt(links.getValueByLabel("Resource"));
Specimen consumer = nodeFactory.createSpecimen(study, taxonForNode.get(consumerNodeID));
consumer.setExternalId(getNamespace() + ":NodeID:" + consumerNodeID);
consumer.caughtIn(location);
Specimen resource = nodeFactory.createSpecimen(study, taxonForNode.get(resourceNodeID));
resource.setExternalId(getNamespace() + ":NodeID:" + resourceNodeID);
resource.caughtIn(location);
consumer.interactsWith(resource, InteractType.ATE);
}
use of org.eol.globi.domain.Specimen in project eol-globi-data by jhpoelen.
the class StudyImporterForGemina method importStudy.
@Override
public void importStudy() throws StudyImporterException {
String studyResource = "gemina_search_2008-01-03.txt";
try {
String source = "Schriml, L. M., Arze, C., Nadendla, S., Ganapathy, A., Felix, V., Mahurkar, A., … Hall, N. (2009). GeMInA, Genomic Metadata for Infectious Agents, a geospatial surveillance pathogen database. Nucleic Acids Research, 38(Database), D754–D764. doi:10.1093/nar/gkp832";
Study study = nodeFactory.getOrCreateStudy(new StudyImpl(source, source, "doi:10.1093/nar/gkp832", source));
LabeledCSVParser parser = parserFactory.createParser(studyResource, "UTF-8");
parser.changeDelimiter('\t');
String[] line;
while ((line = parser.getLine()) != null) {
if (line.length > 7) {
String pathogenId = parser.getValueByLabel("Pathogen Taxonomy");
String pathogenExternalId = StringUtils.isBlank(pathogenId) ? null : TaxonomyProvider.NCBI.getIdPrefix() + pathogenId;
Specimen pathogen = nodeFactory.createSpecimen(study, new TaxonImpl(parser.getValueByLabel("Pathogen"), pathogenExternalId));
String hostId = line[7];
String hostReservoirExternalId = StringUtils.isBlank(hostId) ? null : TaxonomyProvider.NCBI.getIdPrefix() + hostId;
Specimen host = nodeFactory.createSpecimen(study, new TaxonImpl(parser.getValueByLabel("Host/Reservoir"), hostReservoirExternalId));
pathogen.interactsWith(host, InteractType.PATHOGEN_OF);
}
}
} catch (IOException | NodeFactoryException e) {
throw new StudyImporterException("failed to import [" + studyResource + "]", e);
}
}
Aggregations