Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle null locus #241

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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