use of com.Ostermiller.util.LabeledCSVParser in project eol-globi-data by jhpoelen.
the class LengthRangeParserImplTest method parse.
@Test
public void parse() throws IOException, StudyImporterException {
LengthRangeParserImpl parser = new LengthRangeParserImpl("johnny");
LabeledCSVParser csvParser = initParser();
assertEquals((146d + 123d) / 2d, parser.parseLengthInMm(csvParser));
}
use of com.Ostermiller.util.LabeledCSVParser in project eol-globi-data by jhpoelen.
the class LengthRangeParserImplTest method initParser.
private LabeledCSVParser initParser() throws IOException {
LabeledCSVParser csvParser = new TestParserFactory("\"johnny\"\n123-146\n324-345\n").createParser("aStudy", "UTF-8");
csvParser.getLine();
return csvParser;
}
use of com.Ostermiller.util.LabeledCSVParser in project eol-globi-data by jhpoelen.
the class LengthRangeParserImplTest method parseNoLengthUnavailable.
@Test
public void parseNoLengthUnavailable() throws IOException, StudyImporterException {
LengthRangeParserImpl parser = new LengthRangeParserImpl("bla");
LabeledCSVParser csvParser = initParser();
assertNull(parser.parseLengthInMm(csvParser));
}
use of com.Ostermiller.util.LabeledCSVParser in project eol-globi-data by jhpoelen.
the class LengthParserImplTest method initParser.
private LabeledCSVParser initParser() throws IOException {
LabeledCSVParser csvParser = new TestParserFactory("\"johnny\"\n123\n324\n").createParser("aStudy", "UTF-8");
csvParser.getLine();
return csvParser;
}
use of com.Ostermiller.util.LabeledCSVParser in project eol-globi-data by jhpoelen.
the class StudyImporterForRoopnarineTest method importLine.
@Test
public void importLine() throws StudyImporterException, NodeFactoryException {
// note that this test data is a modified version of the actual data - please don't use this data for actual analysis purposes
final String trophicGuildsToSpeciesLookup = "\"Guild Number\",\"Taxa\",\"Fish Body Length\",\"Cayman Islands\",\"Cuba\",\"Jamaica\"\n" + "1,\"something something\",,,,\n" + "2,\"Skeletonema tropicum \",,,,\n" + "3,\"Something else \",,,,\n" + "11,\" Epinephelus striatus \",122,\"x \",\"x\",\"x\"\n" + "12,\" Negaprion brevirostris \",240,\"x \",\" \",\" \"\n" + "13,\" Carcharhinus perezi \",300,\"x \",\"x\",\"x\"\n" + "14,\" Rhizoprionodon porosus \",75,\"x \",\"x\",\" \"\n" + "14,\" Sphyrna tiburo \",80,\"x \",\" \",\" \"\n" + "14,\" Galeocerdo cuvieri \",500,\" \",,";
final String trophicInteractions = "\"Guild Number\",\"Guild Description\",\"Foraging Habitat\",\"Number of Prey\",\"Prey\"\n" + "1,\"Planktonic bacteria \",\".\",0,\".\"\n" + "2,\"Phytoplankton \",\".\",0,\".\"\n" + "3,\"Nanno-zooplankton \",\".\",30,\"1, 2\"\n" + "4,\"Filamentous macroalgae\",\".\",0,\".\"\n" + "5,\"Sheet macroalgae \",\".\",0,\".\"\n" + "6,\"Coarsely branched macroalgae \",\".\",0,\".\"\n" + "7,\"Jointed calcareous macroalgae \",\".\",0,\".\"\n" + "8,\"Thick leathery macroalgae \",\".\",0,\".\"\n" + "9,\"Crustose coralline algae \",\".\",0,\".\"\n" + "10,\"Seagrasses \",\".\",0,\".\"\n" + "11,\"Epibenthic sponges \",\".\",30,\"1, 2\"\n" + "12,\"Endolithic sponges \",\".\",30,\"1, 2\"\n" + "13,\"Ahermatypic benthic corals\",\".\",35,\"1\"\n" + "14,\"Hermatypic corals\",\".\",36,\"2\"";
StudyImporterForRoopnarine importer = new StudyImporterForRoopnarine(new ParserFactory() {
@Override
public LabeledCSVParser createParser(String studyResource, String characterEncoding) throws IOException {
ParserFactory factory;
if (studyResource.contains("4.csv")) {
factory = new TestParserFactory(trophicGuildsToSpeciesLookup);
} else {
factory = new TestParserFactory(trophicInteractions);
}
return factory.createParser("", characterEncoding);
}
}, nodeFactory);
importStudy(importer);
Study study = getStudySingleton(getGraphDb());
assertNotNull(taxonIndex.findTaxonByName("Negaprion brevirostris"));
assertNotNull(taxonIndex.findTaxonByName("Carcharhinus perezi"));
assertNotNull(taxonIndex.findTaxonByName("Galeocerdo cuvieri"));
Iterable<Relationship> collectedRels = NodeUtil.getSpecimens(study);
int totalRels = validateSpecimen(collectedRels);
assertThat(totalRels, Is.is(51));
}
Aggregations