Skip to content

Commit

Permalink
Touches #648: add cnv classes to graphql. Some minor formatting and o…
Browse files Browse the repository at this point in the history
…ther changes.
  • Loading branch information
theferrit32 authored and tbl3rd committed Aug 22, 2022
1 parent c1a2bcb commit 628535e
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 78 deletions.
12 changes: 6 additions & 6 deletions resources/class-names.edn
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
[:ga4gh/VariationDescriptor "https://terms.ga4gh.org/VariationDescriptor"]
[:ga4gh/CanonicalReference "https://terms.ga4gh.org/CanonicalReference"]
[:geno/SequenceInterval "http://purl.obolibrary.org/obo/GENO_0000965"]
[:geno/SequenceFeatureLocation"http://purl.obolibrary.org/obo/GENO_0000815"]
[:geno/SequenceFeatureLocation "http://purl.obolibrary.org/obo/GENO_0000815"]
[:geno/SequenceFeatureSet "http://purl.obolibrary.org/obo/GENO_0000659"]
[:geno/PathogenicForCondition "http://purl.obolibrary.org/obo/GENO_0000840"]
[:geno/BenignForCondition "http://purl.obolibrary.org/obo/GENO_0000843"]
Expand Down Expand Up @@ -153,7 +153,7 @@
[:sepio/ClinGenGeneValidityEvaluationCriteriaSOP7 "http://purl.obolibrary.org/obo/SEPIO_0004095"]
[:sepio/ClinGenGeneValidityEvaluationCriteriaSOP8 "http://purl.obolibrary.org/obo/SEPIO_0004096"]
[:sepio/ClinGenGeneValidityEvaluationCriteriaSOP9 "http://purl.obolibrary.org/obo/SEPIO_0004171"]
[:sepio/ClinGenProteinFunctionCriteria
[:sepio/ClinGenProteinFunctionCriteria
"http://purl.obolibrary.org/obo/SEPIO_0004074"]
[:sepio/NonHumanModelOrganismEvidenceItem
"http://purl.obolibrary.org/obo/SEPIO_0004046"]
Expand Down Expand Up @@ -342,9 +342,9 @@
[:sepio/ProbandEvidenceLine "http://purl.obolibrary.org/obo/SEPIO_0004097"]
[:sepio/ProbandScoreCapEvidenceLine "http://purl.obolibrary.org/obo/SEPIO_0004174"]
[:sepio/ProteinInteractionGeneticInteractionEvidenceLine
"http://purl.obolibrary.org/obo/SEPIO_0004182"]
"http://purl.obolibrary.org/obo/SEPIO_0004182"]
[:sepio/ProteinInteractionNegativeGeneticInteractionEvidenceLine
"http://purl.obolibrary.org/obo/SEPIO_0004183"]
"http://purl.obolibrary.org/obo/SEPIO_0004183"]
[:sepio/ProteinInteractionPhysicalAssociationEvidenceLine
"http://purl.obolibrary.org/obo/SEPIO_0004184"]
[:sepio/ProteinInteractionPositiveGeneticInteractionEvidenceLine
Expand All @@ -356,7 +356,7 @@
[:sepio/NullVariantEvidenceItem "http://purl.obolibrary.org/obo/SEPIO_0004117"]
[:sepio/NonNullVariantEvidenceItem "http://purl.obolibrary.org/obo/SEPIO_0004118"]
[:sepio/VariantFunctionalImpactEvidenceItem "http://purl.obolibrary.org/obo/SEPIO_0004119"]

;;
[:sepio/GeneValidityEvidenceLine
"http://purl.obolibrary.org/obo/SEPIO_0004082"]
Expand Down Expand Up @@ -408,6 +408,7 @@
[:vrs/Allele "https://vrs.ga4gh.org/terms/Allele"]
[:vrs/Text "https://vrs.ga4gh.org/terms/Text"]
[:vrs/CanonicalVariation "https://vrs.ga4gh.org/terms/CanonicalVariation"]
[:vrs/AbsoluteCopyNumber "https://vrs.ga4gh.org/terms/AbsoluteCopyNumber"]
[:vrs/TextUtilityVariation "https://vrs.ga4gh.org/terms/TextUtilityVariation"]
[:vrs/VariationDescriptor "https://vrs.ga4gh.org/terms/VariationDescriptor"]
[:vrs/CategoricalVariationDescriptor "https://vrs.ga4gh.org/terms/CategoricalVariationDescriptor"]
Expand All @@ -421,4 +422,3 @@
[:vrs/SequenceInterval "https://vrs.ga4gh.org/terms/SequenceInterval"]
[:chebi/Drug "http://purl.obolibrary.org/obo/CHEBI_23888"]
[:stato/Cohort "http://purl.obolibrary.org/obo/STATO_0000203"]]

6 changes: 4 additions & 2 deletions resources/property-names.edn
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@
[:vrs/end "https://vrs.ga4gh.org/terms/end"]
[:vrs/sequence_id "https://vrs.ga4gh.org/terms/end"]
[:vrs/definition "https://vrs.ga4gh.org/terms/definition"]
[:vrs/subject "https://vrs.ga4gh.org/terms/subject"]
[:vrs/copies "https://vrs.ga4gh.org/terms/copies"]
[:cnt/chars "http://www.w3.org/2011/content#chars"]
[:data/genome-build-identifier "http://edamontology.org/data_2340"]
[:dc/abstract "http://purl.org/dc/terms/abstract"]
Expand Down Expand Up @@ -1267,7 +1269,7 @@
[:sepio/lower-confidence-limit
"http://purl.obolibrary.org/obo/SEPIO_0000306"]
[:sepio/paternity-maternity-confirmed
"http://purl.obolibrary.org/obo/SEPIO_0004161"]
"http://purl.obolibrary.org/obo/SEPIO_0004161"]
[:sepio/measures-parameter
"http://purl.obolibrary.org/obo/SEPIO_0000114"]
[:sepio/meets-inclusion-criteria "http://purl.obolibrary.org/obo/SEPIO_0004126"]
Expand Down Expand Up @@ -1321,7 +1323,7 @@
[:sepio/score-status "http://purl.obolibrary.org/obo/SEPIO_0004130"]
[:sepio/statistical-significance
"http://purl.obolibrary.org/obo/SEPIO_0004164"]
[:sepio/statistical-significance-type
[:sepio/statistical-significance-type
"http://purl.obolibrary.org/obo/SEPIO_0004165"]
[:sepio/statistical-significance-value-type
"http://purl.obolibrary.org/obo/SEPIO_0004166"]
Expand Down
1 change: 1 addition & 0 deletions src/genegraph/source/graphql/experimental_schema.clj
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
model-variation/vrs-allele
model-variation/vrs-text
model-variation/vrs-canonical-variation
model-variation/vrs-absolute-copy-number
model-variation/vrs-literal-sequence-expression
model-variation/vrs-sequence-location
model-variation/vrs-sequence-interval
Expand Down
2 changes: 1 addition & 1 deletion src/genegraph/source/graphql/schema/types.clj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
[:vrs/Allele :Allele]
[:vrs/Text :Text]
[:vrs/CanonicalVariation :CanonicalVariation]
[:vrs/AbsoluteCopyNumber :AbsoluteCopyNumber]
[:vrs/SequenceLocation :SequenceLocation]
[:vrs/SequenceInterval :SequenceInterval]
[:vrs/LiteralSequenceExpression :LiteralSequenceExpression]
Expand All @@ -27,4 +28,3 @@
[:sepio/ValueSet :ValueSet]
[:pco/Family :Family]]
:default-type-mapping :GenericResource})

13 changes: 12 additions & 1 deletion src/genegraph/source/graphql/schema/variation_descriptor.clj
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@
:state {:type :LiteralSequenceExpression
:path [:vrs/state]}}})

(def vrs-absolute-copy-number
{:name :AbsoluteCopyNumber
:graphql-type :object
:description "GA4GH Absolute Copy Number Variation"
:implements [:Resource]
:fields {:subject {:type :SequenceLocation
:path [:vrs/subject]}
:copies {:type :Number
:path [:vrs/copies]}}})

(def vrs-text
{:name :Text
:graphql-type :object
Expand Down Expand Up @@ -119,7 +129,8 @@
:graphql-type :object
:description "Descriptor for a categorical variation"
:implements [:Resource]
:fields {:value {:type :CanonicalVariation
:fields {:value {:type :Resource
:description "CanonicalVariation or AbsoluteCopyNumber variation"
:path [:rdf/value]}
:xrefs {:type '(list String)
:path [:vrs/xrefs]}
Expand Down
120 changes: 56 additions & 64 deletions src/genegraph/transform/clinvar/jsonld/clinical_assertion.clj
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ WHERE {
FILTER(?other_variant_release_date > ?variant_release_date)
}
}
ORDER BY ?s_variant ?gene_id"
)
ORDER BY ?s_variant ?gene_id")

(defn get-genes-for-clinical-assertion
"Returns the genes associated with this clinical assertion through the variation"
Expand Down Expand Up @@ -115,16 +114,14 @@ ORDER BY ?s_variant ?gene_id"
(do (log/info :msg "Assertion classification context is :PHARMACOGENOMIC")
:PHARMACOGENOMIC)

(or (in? ["practice guideline" "reviewed by expert panel"] review-status)
(or (in? review-status ["practice guideline" "reviewed by expert panel"])
(let [{normalized-clinsig :normalized normalized-group :group} (normalize-clinvar-clinsig clinsig)]
(log/debug :msg (format "Normalized clinsig %s to %s" clinsig normalized-clinsig))
(= "path" normalized-group)))
(do (log/info :msg "Assertion classification context is :GERMLINE_DISEASE")
:GERMLINE_DISEASE)

:default :OTHER
))
)
:default :OTHER)))

(defn clinical-assertion-to-jsonld [msg]
(let [id (format (str iri/clinvar-assertion "%s.%s")
Expand All @@ -138,75 +135,70 @@ ORDER BY ?s_variant ?gene_id"
"clinvar" "https://www.ncbi.nlm.nih.gov/clinvar/"
;rdf-type {"@type" "@id"}
;:cg/ClinVarObject {"@type" "@id"}
}
}
msg (assoc msg :cg/classification-context (compute-clingen-classification-context msg))
]
}}
msg (assoc msg :cg/classification-context (compute-clingen-classification-context msg))]
(genegraph-kw-to-iri
(merge
context
(merge
context
; TODO Add @base
{"@type" [:cg/ClinVarObject
(str iri/cgterms "EvidenceLine")],
"@id" evidence-line-id,
{"@type" [:cg/ClinVarObject
(str iri/cgterms "EvidenceLine")],
"@id" evidence-line-id,

:sepio/has-evidence-direction "supports"
:sepio/evidence-line-strength (scv-review-status-to-evidence-strength-map
(:review_status msg))
:sepio/has-evidence-direction "supports"
:sepio/evidence-line-strength (scv-review-status-to-evidence-strength-map
(:review_status msg))
; The SCV itself is an evidence item within an evidence line that pertains to a variant assertion
:sepio/has-evidence-item
(merge
{"@type" [:cg/ClinVarObject
assertion-rdf-type]
"@id" id
:dc/is-version-of {"@id" (str iri/clinvar-assertion (:id msg))}
:dc/has-version (:version msg)
:dc/title (:title msg)
:sepio/has-evidence-item
(merge
{"@type" [:cg/ClinVarObject
assertion-rdf-type]
"@id" id
:dc/is-version-of {"@id" (str iri/clinvar-assertion (:id msg))}
:dc/has-version (:version msg)
:dc/title (:title msg)

:sepio/has-subject {"@id" (str iri/clinvar-variation (:variation_id msg))}
:sepio/has-predicate (:interpretation_description msg)
:sepio/has-object (str iri/trait-set (:trait_set_id msg))
:sepio/date-created (:date_created msg)
:sepio/date-updated (:date_last_updated msg)
:sepio/has-subject {"@id" (str iri/clinvar-variation (:variation_id msg))}
:sepio/has-predicate (:interpretation_description msg)
:sepio/has-object (str iri/trait-set (:trait_set_id msg))
:sepio/date-created (:date_created msg)
:sepio/date-updated (:date_last_updated msg)

:sepio/qualified-contribution {:sepio/activity-date (:interpretation_date_last_evaluated msg)
:sepio/has-role "SubmitterRole"
:sepio/has-agent {"@id" (str iri/submitter (:submitter_id msg))}}
:sepio/qualified-contribution {:sepio/activity-date (:interpretation_date_last_evaluated msg)
:sepio/has-role "SubmitterRole"
:sepio/has-agent {"@id" (str iri/submitter (:submitter_id msg))}}

; ClinGen/ClinVar additional renamed terms (namespaced to @vocab)
"allele_origin" (:allele_origins msg)
"collection_method" (:collection_methods msg)
"submitted_condition" (str iri/clinical-assertion-trait-set (:clinical_assertion_trait_set_id msg))
"allele_origin" (:allele_origins msg)
"collection_method" (:collection_methods msg)
"submitted_condition" (str iri/clinical-assertion-trait-set (:clinical_assertion_trait_set_id msg))
; TODO update field name if change occurs here https://github.com/clingen-data-model/clinvar-streams/issues/3
"submitted_variation" (:clinical_assertion_variations msg)
}
(-> msg (dissoc
:id
:version
:title
:variation_id
:interpretation_description
:trait_set_id
:date_created
:date_last_updated
:interpretation_date_last_evaluated
:submitter_id
:allele_origins
:collection_methods
:clinical_assertion_trait_set_id
:clinical_assertion_variations))), ; End assertion
"submitted_variation" (:clinical_assertion_variations msg)}
(-> msg (dissoc
:id
:version
:title
:variation_id
:interpretation_description
:trait_set_id
:date_created
:date_last_updated
:interpretation_date_last_evaluated
:submitter_id
:allele_origins
:collection_methods
:clinical_assertion_trait_set_id
:clinical_assertion_variations))), ; End assertion

; Reverse relation from evidence line to parent variation archive
"@reverse" {:sepio/has-evidence-line
[{"@id" (let [variation-archive-iri (format (str iri/variation-archive "%s")
(:variation_archive_id msg))]
(if (empty? (:variation_archive_id msg))
(throw (ex-info "Variation archive id was null" {:cause msg})))
(log/debug :msg (format "Evidence line %s has reverse relation to %s"
evidence-line-id variation-archive-iri))
variation-archive-iri)}]}
}
))))
"@reverse" {:sepio/has-evidence-line
[{"@id" (let [variation-archive-iri (format (str iri/variation-archive "%s")
(:variation_archive_id msg))]
(if (empty? (:variation_archive_id msg))
(throw (ex-info "Variation archive id was null" {:cause msg})))
(log/debug :msg (format "Evidence line %s has reverse relation to %s"
evidence-line-id variation-archive-iri))
variation-archive-iri)}]}}))))

(defmethod clinvar-model-to-jsonld :clinical_assertion [msg]
(clinical-assertion-to-jsonld msg))
Expand Down
2 changes: 1 addition & 1 deletion src/genegraph/transform/clinvar/util.clj
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
[a b]
(conditional-join a b "/"))

(defn in? [coll e]
(defn in? [e coll]
(some #(= % e) coll))

(defn simplify-dollar-map [m]
Expand Down
3 changes: 2 additions & 1 deletion src/genegraph/transform/clinvar/variation.clj
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ query($variation_iri:String) {
type: __typename
... on CategoricalVariationDescriptor {
label
object {
value {
id: iri
type: __typename
... on CanonicalVariation {
Expand Down Expand Up @@ -494,6 +494,7 @@ fragment alleleFields on Allele {
}
")


(defmethod common/clinvar-add-event-graphql :variation [event]
(let [iri (:genegraph.annotate/iri event)]
(assoc event :graphql-params {:query variation-descriptor-query
Expand Down
23 changes: 21 additions & 2 deletions test/genegraph/transform/clinvar/variation_transformer_test.clj
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
(ns genegraph.transform.clinvar.variation-transformer-test
(:require [cheshire.core :as json]
[clojure.pprint :refer [pprint]]
[clojure.string :as s]
[clojure.test :refer [use-fixtures]]
[clojure.pprint :refer [pprint]]
[genegraph.annotate.serialization :as ser]
[genegraph.sink.event :as event]
[genegraph.transform.clinvar.core]
[genegraph.transform.clinvar.variation :as variation]
[genegraph.transform.types :as xform-types]
Expand Down Expand Up @@ -30,7 +32,8 @@
(map xform-types/add-model-jsonld events))

(defn get-variant-messages []
(-> "clinvar-raw-testdata_20210412.txt"
(-> "clinvar-raw-filtered.txt"
#_"clinvar-raw-testdata_20210412.txt"
slurp
(clojure.string/split #"\n")
(->> (map #(json/parse-string % true))
Expand Down Expand Up @@ -83,3 +86,19 @@
(log/info :realized realized)
realized))))))))
(#(do (def with-combined-triples %) %))))


(defn test-vrs-normalization-acmg73 []
(let [events (->> (get-variant-messages)
#_(filter #(= "12610" (get-in % [:content :id])))
(take 1)
(map eventify)
(map genegraph.transform.clinvar.core/add-parsed-value)
(map #(xform-types/add-model %))
(map #(event/add-to-db! %))
(map #((:enter ser/add-graphql-params-interceptor) %))
(map #((:enter ser/add-graphql-serialization-interceptor) %))
;; (map #(xform-types/add-event-graphql %))
;; (map #(ser/add-graphql-serialization-interceptor %))
#_(map #(xform-types/add-model-jsonld %)))]
events))

0 comments on commit 628535e

Please sign in to comment.