-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added GeneAlterationReference to allow modelling which gene is …
…the relevant one in the referenced variant object; fix: Corrected linter errors in Tests
- Loading branch information
1 parent
64bbaaf
commit a067fb3
Showing
10 changed files
with
88 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/main/scala/de/dnpm/dip/model/GeneAlterationReference.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package de.dnpm.dip.model | ||
|
||
|
||
import de.dnpm.dip.coding.Coding | ||
import de.dnpm.dip.coding.hgnc.HGNC | ||
import play.api.libs.json.{ | ||
Json, | ||
Reads, | ||
OWrites | ||
} | ||
|
||
/* | ||
* Conceptually equivalent to FHIR "CodeableReference", to specify the | ||
* (clinically) relevant gene in a variant supporting a recommendation | ||
* | ||
* Gene is kept optional because in SNVs it is already implicitly defined, | ||
* and thus needn't be specified again, but for CNVs or Fusions, which can | ||
* affect multiple or 2 genes, respectively, | ||
* it should be specified to remove ambiguity | ||
* | ||
*/ | ||
|
||
final case class GeneAlterationReference[+Variant] | ||
( | ||
gene: Option[Coding[HGNC]], | ||
variant: Reference[Variant], | ||
display: Option[String] | ||
) | ||
|
||
object GeneAlterationReference | ||
{ | ||
|
||
def apply[T <: { def id: Id[T] }]( | ||
gene: Option[Coding[HGNC]], | ||
variant: T | ||
): GeneAlterationReference[T] = | ||
GeneAlterationReference( | ||
gene, | ||
Reference.to(variant), | ||
None | ||
) | ||
|
||
|
||
implicit def reads[T]: Reads[GeneAlterationReference[T]] = | ||
Json.reads[GeneAlterationReference[T]] | ||
// For (temporary) backward compatibility, fall back to parsing as a normal reference | ||
.orElse( | ||
Reads.of[Reference[T]].map(GeneAlterationReference(None,_,None)) | ||
) | ||
|
||
implicit def writes[T: Reference.TypeName]: OWrites[GeneAlterationReference[T]] = | ||
Json.writes[GeneAlterationReference[T]] | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters