@Test public void parseTaxa() throws IOException, StudyImporterException { String someTaxaRows = "Oid\tName\tRank\tParent\tKingdom\tPhylum\tClass\tOrder\tSuborder\tFamily\tGenus\tSpecies\tFullName\tAuthor\tYear\tSaproxylicStatus\tNorway\tSweden\tFinland\tDenmark\tEstonia\tLatvia\tLithuania\tPoland\tEngland\tScotland\tFrance\tRealSpecies\tSpeciesName\tSynonyms\tComment\tOtherDistribution\tOptimisticLockField\tGCRecord\tObjectType\n" + "{DCCD2CFE-D002-40AB-B93B-000DD0B62999}\tDrosophilidae\t{4665ED8F-3734-406C-8987-E01B25E7D917}\t{A2ECAD2A-6B0A-4BED-B475-6E27D1BA2275}\t{775D6D50-1B93-42CF-9411-9573DDA4CD33}\t{ACDD42F9-63A4-4736-A1A3-66A4A515AC23}\t{A36FF57C-6577-4E1F-89D2-6788F9273E9F}\t{4442B3BF-4756-4258-8AF1-7F5B951346EF}\t{A2ECAD2A-6B0A-4BED-B475-6E27D1BA2275}\t{DCCD2CFE-D002-40AB-B93B-000DD0B62999}\t\t\tDrosophilidae\t\t0\t0\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t0\t\t13\n" + "{2F6610B4-7BC7-486F-B877-00484DC6AD2F}\tcinnabarinus\t{F4EB5A5C-34D0-4849-AC4F-FB2081067DF2}\t{1A72333E-92BB-40CC-A1DB-48302794436B}\t{BD93BDBC-8F91-44E2-BE59-9772B3EDB4B4}\t{3F1C39CD-FBBA-42B0-BC7C-028234A2AF4F}\t{F3BD253F-A0C7-440C-A5E0-51ECAA478978}\t{D8C4799E-A6B8-43B6-A0AC-7A01408D77FD}\t{91B32813-913B-4E34-9B2A-1A46F36EE91D}\t{F2E073EF-F4EB-4019-A29A-4B8A776E58EF}\t{1A72333E-92BB-40CC-A1DB-48302794436B}\t{2F6610B4-7BC7-486F-B877-00484DC6AD2F}\tPycnoporus cinnabarinus\t\t0\t2\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t\tPycnoporus cinnabarinus\t\t\t\t0\t\t15\n"; final Set<Triple<String, String, String>> triples = new TreeSet<>(); DatasetImporterForSaproxylic.parseTaxa(triples::add, IOUtils.toInputStream(someTaxaRows, StandardCharsets.UTF_8)); assertThat(triples, hasItem(DatasetImporterForSaproxylic.asTriple("{DCCD2CFE-D002-40AB-B93B-000DD0B62999}", "hasName", "Drosophilidae"))); assertThat(triples, hasItem(DatasetImporterForSaproxylic.asTriple("{DCCD2CFE-D002-40AB-B93B-000DD0B62999}", "hasRank", "{4665ED8F-3734-406C-8987-E01B25E7D917}"))); }
static void parseTaxa(Tripler tripler, InputStream is) throws IOException, StudyImporterException { handleLines(parser -> { String taxonId = parser.getValueByLabel("Oid"); String kingdomId = parser.getValueByLabel(KINGDOM); String phylumId = parser.getValueByLabel(PHYLUM); String classId = parser.getValueByLabel(CLASS); String orderId = parser.getValueByLabel(ORDER); String subOrderId = parser.getValueByLabel(SUB_ORDER); String familyId = parser.getValueByLabel(FAMILY); String genusId = parser.getValueByLabel(GENUS); String speciesId = parser.getValueByLabel(SPECIES); String rankId = parser.getValueByLabel("Rank"); String nameString = parser.getValueByLabel("FullName"); List<String> ts = Arrays.asList(kingdomId, phylumId, classId, orderId, subOrderId, familyId, genusId, speciesId); String pathIds = StringUtils.join(ts, CharsetConstant.SEPARATOR); List<String> pathNames = Arrays.asList(KINGDOM, PHYLUM, CLASS, ORDER, SUB_ORDER, FAMILY, GENUS, SPECIES); String pathNamesJoined = StringUtils.join(pathNames, CharsetConstant.SEPARATOR); tripler.on(asTriple(taxonId, HAS_NAME, nameString)); tripler.on(asTriple(taxonId, HAS_RANK, rankId)); tripler.on(asTriple(taxonId, HAS_PATH_IDS, pathIds)); tripler.on(asTriple(taxonId, HAS_PATH_NAMES, pathNamesJoined)); }, is); }
DatasetImporterForSaproxylic extends DatasetImporterWithListener { static void parseTaxa(Tripler tripler, InputStream is) throws IOException, StudyImporterException { handleLines(parser -> { String taxonId = parser.getValueByLabel("Oid"); String kingdomId = parser.getValueByLabel(KINGDOM); String phylumId = parser.getValueByLabel(PHYLUM); String classId = parser.getValueByLabel(CLASS); String orderId = parser.getValueByLabel(ORDER); String subOrderId = parser.getValueByLabel(SUB_ORDER); String familyId = parser.getValueByLabel(FAMILY); String genusId = parser.getValueByLabel(GENUS); String speciesId = parser.getValueByLabel(SPECIES); String rankId = parser.getValueByLabel("Rank"); String nameString = parser.getValueByLabel("FullName"); List<String> ts = Arrays.asList(kingdomId, phylumId, classId, orderId, subOrderId, familyId, genusId, speciesId); String pathIds = StringUtils.join(ts, CharsetConstant.SEPARATOR); List<String> pathNames = Arrays.asList(KINGDOM, PHYLUM, CLASS, ORDER, SUB_ORDER, FAMILY, GENUS, SPECIES); String pathNamesJoined = StringUtils.join(pathNames, CharsetConstant.SEPARATOR); tripler.on(asTriple(taxonId, HAS_NAME, nameString)); tripler.on(asTriple(taxonId, HAS_RANK, rankId)); tripler.on(asTriple(taxonId, HAS_PATH_IDS, pathIds)); tripler.on(asTriple(taxonId, HAS_PATH_NAMES, pathNamesJoined)); }, is); } }
DatasetImporterForSaproxylic extends DatasetImporterWithListener { static void parseTaxa(Tripler tripler, InputStream is) throws IOException, StudyImporterException { handleLines(parser -> { String taxonId = parser.getValueByLabel("Oid"); String kingdomId = parser.getValueByLabel(KINGDOM); String phylumId = parser.getValueByLabel(PHYLUM); String classId = parser.getValueByLabel(CLASS); String orderId = parser.getValueByLabel(ORDER); String subOrderId = parser.getValueByLabel(SUB_ORDER); String familyId = parser.getValueByLabel(FAMILY); String genusId = parser.getValueByLabel(GENUS); String speciesId = parser.getValueByLabel(SPECIES); String rankId = parser.getValueByLabel("Rank"); String nameString = parser.getValueByLabel("FullName"); List<String> ts = Arrays.asList(kingdomId, phylumId, classId, orderId, subOrderId, familyId, genusId, speciesId); String pathIds = StringUtils.join(ts, CharsetConstant.SEPARATOR); List<String> pathNames = Arrays.asList(KINGDOM, PHYLUM, CLASS, ORDER, SUB_ORDER, FAMILY, GENUS, SPECIES); String pathNamesJoined = StringUtils.join(pathNames, CharsetConstant.SEPARATOR); tripler.on(asTriple(taxonId, HAS_NAME, nameString)); tripler.on(asTriple(taxonId, HAS_RANK, rankId)); tripler.on(asTriple(taxonId, HAS_PATH_IDS, pathIds)); tripler.on(asTriple(taxonId, HAS_PATH_NAMES, pathNamesJoined)); }, is); } DatasetImporterForSaproxylic(ParserFactory parserFactory, NodeFactory nodeFactory); }
DatasetImporterForSaproxylic extends DatasetImporterWithListener { static void parseTaxa(Tripler tripler, InputStream is) throws IOException, StudyImporterException { handleLines(parser -> { String taxonId = parser.getValueByLabel("Oid"); String kingdomId = parser.getValueByLabel(KINGDOM); String phylumId = parser.getValueByLabel(PHYLUM); String classId = parser.getValueByLabel(CLASS); String orderId = parser.getValueByLabel(ORDER); String subOrderId = parser.getValueByLabel(SUB_ORDER); String familyId = parser.getValueByLabel(FAMILY); String genusId = parser.getValueByLabel(GENUS); String speciesId = parser.getValueByLabel(SPECIES); String rankId = parser.getValueByLabel("Rank"); String nameString = parser.getValueByLabel("FullName"); List<String> ts = Arrays.asList(kingdomId, phylumId, classId, orderId, subOrderId, familyId, genusId, speciesId); String pathIds = StringUtils.join(ts, CharsetConstant.SEPARATOR); List<String> pathNames = Arrays.asList(KINGDOM, PHYLUM, CLASS, ORDER, SUB_ORDER, FAMILY, GENUS, SPECIES); String pathNamesJoined = StringUtils.join(pathNames, CharsetConstant.SEPARATOR); tripler.on(asTriple(taxonId, HAS_NAME, nameString)); tripler.on(asTriple(taxonId, HAS_RANK, rankId)); tripler.on(asTriple(taxonId, HAS_PATH_IDS, pathIds)); tripler.on(asTriple(taxonId, HAS_PATH_NAMES, pathNamesJoined)); }, is); } DatasetImporterForSaproxylic(ParserFactory parserFactory, NodeFactory nodeFactory); @Override void importStudy(); void toInteractions(ResultSet results); }
DatasetImporterForSaproxylic extends DatasetImporterWithListener { static void parseTaxa(Tripler tripler, InputStream is) throws IOException, StudyImporterException { handleLines(parser -> { String taxonId = parser.getValueByLabel("Oid"); String kingdomId = parser.getValueByLabel(KINGDOM); String phylumId = parser.getValueByLabel(PHYLUM); String classId = parser.getValueByLabel(CLASS); String orderId = parser.getValueByLabel(ORDER); String subOrderId = parser.getValueByLabel(SUB_ORDER); String familyId = parser.getValueByLabel(FAMILY); String genusId = parser.getValueByLabel(GENUS); String speciesId = parser.getValueByLabel(SPECIES); String rankId = parser.getValueByLabel("Rank"); String nameString = parser.getValueByLabel("FullName"); List<String> ts = Arrays.asList(kingdomId, phylumId, classId, orderId, subOrderId, familyId, genusId, speciesId); String pathIds = StringUtils.join(ts, CharsetConstant.SEPARATOR); List<String> pathNames = Arrays.asList(KINGDOM, PHYLUM, CLASS, ORDER, SUB_ORDER, FAMILY, GENUS, SPECIES); String pathNamesJoined = StringUtils.join(pathNames, CharsetConstant.SEPARATOR); tripler.on(asTriple(taxonId, HAS_NAME, nameString)); tripler.on(asTriple(taxonId, HAS_RANK, rankId)); tripler.on(asTriple(taxonId, HAS_PATH_IDS, pathIds)); tripler.on(asTriple(taxonId, HAS_PATH_NAMES, pathNamesJoined)); }, is); } DatasetImporterForSaproxylic(ParserFactory parserFactory, NodeFactory nodeFactory); @Override void importStudy(); void toInteractions(ResultSet results); static final String CLASSIFIED_AS; static final String IN_STAGE; static final String FOUND_AT; static final String MENTIONED_BY; static final String PARTICIPATES_IN; static final String HAS_NAME; static final String HAS_RANK; static final String HAS_PATH_IDS; static final String HAS_PATH_NAMES; }