MPOntologyFileParser implements ResourceParser { @Override public void parseResource(Resource resource, Path inDir, Path outDir) { Path inFile = inDir.resolve(resource.getExtractedFileName()); Path outFile = outDir.resolve(resource.getParsedFileName()); logger.info("Parsing {} file: {}. Writing out to: {}", resource.getName(), inFile, outFile); OboOntology oboOntology = OboOntologyParser.parseOboFile(inFile); resource.setVersion(oboOntology.getDataVersion()); logger.info("MP version: {}", oboOntology.getDataVersion()); int currPlusObs = oboOntology.getCurrentOntologyTerms().size() + oboOntology.getObsoleteOntologyTerms().size(); List<OboOntologyTerm> allTerms = new ArrayList<>(currPlusObs); allTerms.addAll(oboOntology.getCurrentOntologyTerms()); allTerms.addAll(oboOntology.getObsoleteOntologyTerms()); allTerms.sort(Comparator.comparing(OboOntologyTerm::getId)); for (OboOntologyTerm ontologyTerm : allTerms) { mpId2termMap.put(ontologyTerm.getId(), ontologyTerm.getLabel()); } ResourceOperationStatus status = writeMpFile(outDir.resolve("mp.pg"), allTerms); resource.setParseStatus(status); logger.info("{}", status); } MPOntologyFileParser(Map<String, String> mpId2termMap); @Override void parseResource(Resource resource, Path inDir, Path outDir);  }
@Test @ExtendWith(TempDirectory.class) public void testParseHPO(@TempDirectory.TempDir Path tempDir) throws Exception { Resource testResource = new Resource("MP"); testResource.setExtractedFileName("mp.obo"); testResource.setParsedFileName("mp.pg"); Map<String, String> mpId2termMap = new HashMap<>(); MPOntologyFileParser instance = new MPOntologyFileParser(mpId2termMap); instance.parseResource(testResource, Paths.get("src/test/resources/data"), tempDir); assertFalse(mpId2termMap.isEmpty()); Path mpPath = tempDir.resolve("mp.pg"); assertTrue(mpPath.toFile().exists()); List<String> lines = Files.readAllLines(mpPath); assertFalse(lines.isEmpty()); }