Skip to content

Commit

Permalink
Issue #77: Top exomiser hits now uses the variant display table from …
Browse files Browse the repository at this point in the history
…variant store application

Conflicts:
	similarity-data-impl/src/main/java/org/phenotips/data/similarity/script/ExomiserViewScriptService.java
  • Loading branch information
mjshepherd authored and Orion Buske committed Jan 18, 2017
1 parent c68c88c commit 563df98
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 316 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,15 @@ public boolean hasGenotype(Patient patient)
*/
public JSONArray getTopGenesAsJSON(Patient patient, int g, int v)
{
JSONArray result = new JSONArray();
JSONArray variantsJSON = new JSONArray();

if (patient == null || g <= 0) {
return result;
return variantsJSON;
}

Exome patientExome = this.exomeManager.getExome(patient);
if (patientExome == null) {
return result;
return variantsJSON;
}

int maxGenes = g;
Expand All @@ -107,21 +108,34 @@ public JSONArray getTopGenesAsJSON(Patient patient, int g, int v)
}

for (String geneName : patientExome.getTopGenes(maxGenes)) {
JSONObject geneJSON = new JSONObject();
geneJSON.put("name", geneName);
geneJSON.put("score", patientExome.getGeneScore(geneName));

JSONArray variantsJSON = new JSONArray();
Double geneScore = patientExome.getGeneScore(geneName);
List<Variant> topVariants = patientExome.getTopVariants(geneName, maxVars);
for (int i = 0; i < Math.min(maxVars, topVariants.size()); i++) {
Variant variant = topVariants.get(i);
if (variant != null) {
variantsJSON.put(variant.toJSON());
variantsJSON.put(this.mapToGAVariantJSON(variant, geneName, geneScore));
}
}
geneJSON.put("variants", variantsJSON);
result.put(geneJSON);
}
return result;
return variantsJSON;
}

private JSONObject mapToGAVariantJSON(Variant variant, String geneName, Double geneScore)
{
JSONObject resultJson = new JSONObject();
resultJson.put("start", variant.getPosition());
resultJson.put("referenceBases", variant.getRef());
resultJson.put("alternateBases", variant.getAlt());
resultJson.put("referenceName", variant.getChrom());
resultJson.put("end", variant.getPosition() + variant.getAlt().length());

JSONObject infoJson = new JSONObject();
infoJson.put("EXOMISER_VARIANT_SCORE", variant.getScore());
infoJson.put("EXOMISER_GENE_VARIANT_SCORE", geneScore);
infoJson.put("GENE_EFFECT", variant.getAnnotation("FUNCTIONAL_CLASS"));
infoJson.put("GENE", geneName);

resultJson.put("info", infoJson);
return resultJson;
}
}
Loading

0 comments on commit 563df98

Please sign in to comment.