Skip to content

Commit

Permalink
handle null locus
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhayhurst committed Nov 22, 2024
1 parent 1dd1311 commit dfe3b40
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/models/Backend.scala
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,14 @@ class Backend @Inject() (implicit
retriever.map {
case (Seq(), _, _) => None
case (credset, _, _) =>
val loci = credset.flatMap(cs => (cs \ "locus").as[Seq[Locus]])
val loci = credset.flatMap(cs => (cs \ "locus").asOpt[Seq[Locus]].getOrElse(Seq()))
logger.info(s"loci: $loci")
val count = loci.size
val filteredLoci = variantIds match {
case Some(variantIds) => loci.filter(l => variantIds.contains(l.variantId.getOrElse("")))
case None => loci
}
Some(Loci(count, filteredLoci.take(sizeLimit.getOrElse(Pagination.sizeDefault))))
Some(Loci(count, Some(filteredLoci.take(sizeLimit.getOrElse(Pagination.sizeDefault)))))
}
}

Expand Down
4 changes: 2 additions & 2 deletions app/models/entities/CredibleSet.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ case class Locus(

case class Loci(
count: Long,
rows: Seq[Locus]
rows: Option[Seq[Locus]]
)

case class LdSet(
Expand Down Expand Up @@ -116,7 +116,7 @@ object CredibleSet extends Logging {

implicit val lociR: Reads[Loci] = (
(JsPath \ "count").read[Long] and
(JsPath \ "locus").read[Seq[Locus]]
(JsPath \ "locus").readNullable[Seq[Locus]]
)(Loci.apply _)

val credibleSetFields: Seq[Field[Backend, JsValue]] = Seq(
Expand Down

0 comments on commit dfe3b40

Please sign in to comment.