HPOOntologyFileParser 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: {}.", resource.getName(), inFile); OboOntology oboOntology = OboOntologyParser.parseOboFile(inFile); resource.setVersion(oboOntology.getDataVersion()); logger.info("HPO version: {}", oboOntology.getDataVersion()); for (OboOntologyTerm ontologyTerm : oboOntology.getCurrentOntologyTerms()) { hpId2termMap.put(ontologyTerm.getId(), ontologyTerm.getLabel()); } ResourceOperationStatus hpStatus = writeHpFile(outFile, oboOntology); logger.info("{} Writing hp to: {}", hpStatus, outFile); Path hpAltIdFile = outDir.resolve("hp_alt_ids.pg"); ResourceOperationStatus hpAltIdStatus = writeHpAltIdFile(hpAltIdFile, oboOntology); logger.info("{} Writing hp_alt_ids to: {}", hpAltIdStatus, hpAltIdFile); ResourceOperationStatus status = hpStatus == FAILURE ? FAILURE : hpAltIdStatus; resource.setParseStatus(status); logger.info("{}", status); } HPOOntologyFileParser(Map<String, String> hpId2termMap); @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("HPO"); testResource.setExtractedFileName("hp.obo"); testResource.setParsedFileName("hpo.pg"); Map<String, String> hpId2termMap = new HashMap<>(); HPOOntologyFileParser instance = new HPOOntologyFileParser(hpId2termMap); instance.parseResource(testResource, Paths.get("src/test/resources/data"), tempDir); assertFalse(hpId2termMap.isEmpty()); assertTrue(tempDir.resolve("hp_alt_ids.pg").toFile().exists()); assertTrue(tempDir.resolve("hpo.pg").toFile().exists()); }