Skip to content

Commit

Permalink
fix: reduce data size
Browse files Browse the repository at this point in the history
  • Loading branch information
markwoon committed Jul 26, 2024
1 parent 286b76d commit 5bdcc49
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,26 @@
public class GenePhenotype {
public static final String UNASSIGNED_FUNCTION = "Unassigned function";

@SerializedName("gene")
@Expose
@SerializedName("gene")
private String m_gene;
@SerializedName("haplotypes")
@Expose
@SerializedName("haplotypes")
private Map<String, String> m_haplotypes;
@SerializedName("activityValues")
@Expose
@SerializedName("activityValues")
private Map<String,String> m_activityValues = new HashMap<>();
@SerializedName("diplotypes")
@Expose
@SerializedName("diplotypes")
private SortedSet<DiplotypeRecord> m_diplotypes;
@SerializedName("namedAlleles")
@Expose
@SerializedName("namedAlleles")
private List<HaplotypeRecord> m_namedAlleles;
@SerializedName(value = "version")
@Expose
@SerializedName(value = "version")
private String m_version;
@Expose(serialize = false)
@SerializedName("diplotypeFunctions")
@Expose
private List<DiplotypeFunction> m_diplotypeFunctions;

// only used by Subsetter
Expand Down Expand Up @@ -163,6 +163,9 @@ public String getVersion() {
}


/**
* This is only available during data ingestion.
*/
public List<DiplotypeFunction> getDiplotypeFunctions() {
return this.m_diplotypeFunctions;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,25 @@
import java.util.stream.Collectors;
import com.google.common.collect.SortedSetMultimap;
import com.google.common.collect.TreeMultimap;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import org.pharmgkb.common.util.PathUtils;
import org.pharmgkb.pharmcat.reporter.model.DataSource;
import org.pharmgkb.pharmcat.reporter.model.PrescribingGuidanceSource;
import org.pharmgkb.pharmcat.reporter.model.cpic.Publication;
import org.pharmgkb.pharmcat.reporter.model.pgkb.AccessionObject;
import org.pharmgkb.pharmcat.reporter.model.pgkb.GuidelinePackage;
import org.pharmgkb.pharmcat.reporter.model.pgkb.PrescribingGuidanceDataset;
import org.pharmgkb.pharmcat.reporter.model.pgkb.Publication;
import org.pharmgkb.pharmcat.util.DataSerializer;


public class PgkbGuidelineCollection {
private static final Path GUIDANCE_DATA_PATH =
PathUtils.getPathToResource("org/pharmgkb/pharmcat/reporter/prescribing_guidance.json");
public static final String PRESCRIBING_GUIDANCE_FILE_NAME = "prescribing_guidance.json";
public static final Path GUIDANCE_DATA_PATH =
PathUtils.getPathToResource("org/pharmgkb/pharmcat/reporter/" + PRESCRIBING_GUIDANCE_FILE_NAME);

@Expose
@SerializedName("guidelines")
private final List<GuidelinePackage> f_guidelinePackages = new ArrayList<>();
private final SortedSetMultimap<String,GuidelinePackage> f_guidelineMap = TreeMultimap.create(String::compareToIgnoreCase, Comparator.naturalOrder());
private SortedSet<String> m_genes;
Expand Down Expand Up @@ -112,4 +117,9 @@ public SortedSet<String> getGenesUsedInSource(DataSource source) {
.filter(Objects::nonNull)
.collect(Collectors.toCollection(TreeSet::new));
}


public void serializeToJson(Path file) throws IOException {
DataSerializer.serializeToJson(this, file);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.pharmgkb.pharmcat.reporter.caller.LowestFunctionGeneCaller;
import org.pharmgkb.pharmcat.reporter.model.MessageAnnotation;
import org.pharmgkb.pharmcat.reporter.model.PrescribingGuidanceSource;
import org.pharmgkb.pharmcat.reporter.model.cpic.Publication;
import org.pharmgkb.pharmcat.reporter.model.pgkb.Publication;
import org.pharmgkb.pharmcat.reporter.model.result.AnnotationReport;
import org.pharmgkb.pharmcat.reporter.model.result.Diplotype;
import org.pharmgkb.pharmcat.reporter.model.result.DrugReport;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.pharmgkb.pharmcat.reporter.model.MessageAnnotation;
import org.pharmgkb.pharmcat.reporter.model.PrescribingGuidanceSource;
import org.pharmgkb.pharmcat.reporter.model.VariantReport;
import org.pharmgkb.pharmcat.reporter.model.cpic.Publication;
import org.pharmgkb.pharmcat.reporter.model.pgkb.Publication;
import org.pharmgkb.pharmcat.reporter.model.result.AnnotationReport;
import org.pharmgkb.pharmcat.reporter.model.result.CallSource;
import org.pharmgkb.pharmcat.reporter.model.result.Diplotype;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import org.pharmgkb.pharmcat.reporter.model.PrescribingGuidanceSource;
import org.pharmgkb.pharmcat.reporter.model.cpic.Publication;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class PrescribingGuidanceDataset {
@SerializedName("guidelines")
private List<GuidelinePackage> m_guidelinePackages;


public String getVersion() {
return m_version;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.pharmgkb.pharmcat.reporter.model.cpic;
package org.pharmgkb.pharmcat.reporter.model.pgkb;

import java.util.List;
import java.util.Map;
Expand All @@ -18,9 +18,6 @@ public class Publication implements Comparable<Publication> {
@SerializedName("title")
private String m_title;
@Expose
@SerializedName("authors")
private List<String> m_authors;
@Expose
@SerializedName("journal")
private String m_journal;
@Expose
Expand All @@ -43,10 +40,6 @@ public String getTitle() {
return m_title;
}

public List<String> getAuthors() {
return m_authors;
}

public String getJournal() {
return m_journal;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import org.pharmgkb.pharmcat.reporter.ReportContext;
import org.pharmgkb.pharmcat.reporter.model.MessageAnnotation;
import org.pharmgkb.pharmcat.reporter.model.PrescribingGuidanceSource;
import org.pharmgkb.pharmcat.reporter.model.cpic.Publication;
import org.pharmgkb.pharmcat.reporter.model.pgkb.GuidelinePackage;
import org.pharmgkb.pharmcat.reporter.model.pgkb.Publication;


/**
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/pharmgkb/pharmcat/util/DataManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public class DataManager {
public static final String POSITIONS_VCF = "pharmcat_positions.vcf";
public static final String UNIALLELIC_POSITIONS_VCF = "pharmcat_positions.uniallelic.vcf";
private static final String ALLELES_FILE_NAME = "allele_translations.json";
private static final String PRESCRIBING_GUIDANCE_FILE_NAME = "prescribing_guidance.json";
private static final String sf_zipFileName = "pharmcat.zip";
private static final String sf_googleDocUrlFmt = "https://docs.google.com/spreadsheets/d/%s/export?format=tsv";

Expand Down Expand Up @@ -216,11 +215,12 @@ private Path transformGuidelines(Path downloadDir, Path guidelinesDir) throws IO
Files.createDirectories(guidelinesDir);
}

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

FileUtils.copyFile(downloadedGuidanceFile.toFile(), destinationGuidanceFile.toFile());
PgkbGuidelineCollection pgkbGuidelineCollection = new PgkbGuidelineCollection(downloadedGuidanceFile);
pgkbGuidelineCollection.serializeToJson(destinationGuidanceFile);
return destinationGuidanceFile;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class DataSerializer {



public void serializeToJson(Object data, Path jsonFile) throws IOException {
public static void serializeToJson(Object data, Path jsonFile) throws IOException {
Preconditions.checkNotNull(jsonFile);
Preconditions.checkArgument(jsonFile.toString().endsWith(".json"), "Invalid format: %s does not end with .json", jsonFile);

Expand Down

0 comments on commit 5bdcc49

Please sign in to comment.