Skip to content

Commit

Permalink
fix: search object mapping to case classes are updated with the new f…
Browse files Browse the repository at this point in the history
…ields populated
  • Loading branch information
mkarmona committed Mar 11, 2019
1 parent a28e088 commit 3c4baf8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
35 changes: 25 additions & 10 deletions app/models/Entities.scala
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,6 @@ object Entities {
else {
val mv = hit.sourceAsMap

// case class Gene(id: String, symbol: Option[String], bioType: Option[String] = None, chromosome: Option[String] = None,
// tss: Option[Long] = None, start: Option[Long] = None, end: Option[Long] = None,
// fwd: Option[Boolean] = None, exons: Seq[Long] = Seq.empty)

Right(Gene(mv("gene_id").toString,
mv.get("gene_name").map(_.toString),
mv.get("biotype").map(_.toString),
Expand All @@ -247,7 +243,7 @@ object Entities {
case 1 => true
case _ => false
}),
mv.get("exons").map(_.asInstanceOf[Seq[Long]]).getOrElse(Seq.empty)
LSeqRep(mv.get("exons").map(_.toString).getOrElse(""))
))
}
}
Expand All @@ -258,11 +254,30 @@ object Entities {
if (hit.isSourceEmpty) Left(new NoSuchFieldError("source object is empty"))
else {
val mv = hit.sourceAsMap

val variant = Variant(mv("chr_id").toString, mv("position").asInstanceOf[Int],
mv("ref_allele").toString, mv("alt_allele").toString, Option(mv("rs_id").toString))

Right(variant)
Right(Variant(mv("chr_id").toString,
mv("position").toString.toLong,
mv("ref_allele").toString,
mv("alt_allele").toString,
mv.get("rs_id").map(_.toString),
Annotation(mv.get("gene_id").map(_.toString),
mv.get("gene_id_distance").map(_.toString.toLong),
mv.get("gene_id_prot_coding").map(_.toString),
mv.get("gene_id_prot_coding_distance").map(_.toString.toLong),
mv.get("most_severe_consequence").map(_.toString)),
CaddAnnotation(mv.get("raw").map(_.toString.toDouble),
mv.get("phred").map(_.toString.toDouble)),
GnomadAnnotation(mv.get("gnomad_afr").map(_.toString.toDouble),
mv.get("gnomad_seu").map(_.toString.toDouble),
mv.get("gnomad_amr").map(_.toString.toDouble),
mv.get("gnomad_asj").map(_.toString.toDouble),
mv.get("gnomad_eas").map(_.toString.toDouble),
mv.get("gnomad_fin").map(_.toString.toDouble),
mv.get("gnomad_nfe").map(_.toString.toDouble),
mv.get("gnomad_nfe_est").map(_.toString.toDouble),
mv.get("gnomad_nfe_seu").map(_.toString.toDouble),
mv.get("gnomad_nfe_onf").map(_.toString.toDouble),
mv.get("gnomad_nfe_nwe").map(_.toString.toDouble),
mv.get("gnomad_oth").map(_.toString.toDouble))))
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions app/models/GQLSchema.scala
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,9 @@ object GQLSchema extends GQLGene with GQLVariant with GQLStudy with GQLIndexVari
arguments = queryString :: pageIndex :: pageSize :: Nil,
resolve = ctx =>
ctx.ctx.getSearchResultSet(ctx.arg(queryString), ctx.arg(pageIndex), ctx.arg(pageSize))),
Field("geneInfo", OptionType(gene),
arguments = geneId :: Nil,
resolve = ctx => genesFetcher.deferOpt(ctx.arg(geneId))),
Field("studyInfo", OptionType(study),
arguments = studyId :: Nil,
resolve = ctx => studiesFetcher.deferOpt(ctx.arg(studyId))),
Expand Down

0 comments on commit 3c4baf8

Please sign in to comment.