Skip to content

Commit

Permalink
fix(data): fix downloading new guidance data
Browse files Browse the repository at this point in the history
  • Loading branch information
whaleyr committed Jul 18, 2024
1 parent 47da939 commit a1007c0
Show file tree
Hide file tree
Showing 3 changed files with 40,200 additions and 37,079 deletions.
17 changes: 15 additions & 2 deletions src/main/java/org/pharmgkb/pharmcat/util/DataManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ public static void main(String[] args) {
PgkbGuidelineCollection pgkbGuidelineCollection;
if (!skipGuidelines) {
Path drugsDir = cliHelper.getValidDirectory("g", true);
Path guidanceFile = drugsDir.resolve(PRESCRIBING_GUIDANCE_FILE_NAME);
pgkbGuidelineCollection = new PgkbGuidelineCollection(guidanceFile);
Path updatedGuidancePath = manager.transformGuidelines(downloadDir, drugsDir);
pgkbGuidelineCollection = new PgkbGuidelineCollection(updatedGuidancePath);
} else {
// if we're skipping new drug data, then use the default data
pgkbGuidelineCollection = new PgkbGuidelineCollection();
Expand Down Expand Up @@ -209,6 +209,19 @@ public static void main(String[] args) {
}
}

private Path transformGuidelines(Path downloadDir, Path guidelinesDir) throws IOException {
if (!Files.exists(guidelinesDir)) {
Files.createDirectories(guidelinesDir);
}

Path downloadedGuidanceFile = downloadDir.resolve(PRESCRIBING_GUIDANCE_FILE_NAME);
Path destinationGuidanceFile = guidelinesDir.resolve(PRESCRIBING_GUIDANCE_FILE_NAME);
System.out.println("Saving guidelines to " + destinationGuidanceFile);

FileUtils.copyFile(downloadedGuidanceFile.toFile(), destinationGuidanceFile.toFile());
return destinationGuidanceFile;
}


private DefinitionFile[] parseDefinitionFiles(Path downloadDir) throws IOException {
Path definitionsFile = downloadDir.resolve(ALLELES_FILE_NAME);
Expand Down
Loading

0 comments on commit a1007c0

Please sign in to comment.