-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathObjects.scala
More file actions
3737 lines (3632 loc) · 168 KB
/
Objects.scala
File metadata and controls
3737 lines (3632 loc) · 168 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package models.gql
import models.*
import models.entities.Configuration.*
import models.entities.*
import models.gql.Arguments.*
import models.gql.Fetchers.{diseasesFetcher, *}
import models.Helpers.ComplexityCalculator.*
import models.entities.ClinicalIndications.{
clinicalIndicationsFromDiseaseImp,
clinicalIndicationsFromDrugImp
}
import models.entities.ClinicalTargets.clinicalTargetsImp
import sangria.macros.derive.*
import sangria.schema.*
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.*
import models.entities.Violations.{InputParameterCheckError, InvalidArgValueError}
import net.logstash.logback.argument.StructuredArguments.keyValue
import utils.OTLogging
object Objects extends OTLogging {
implicit val metaDataVersionImp: ObjectType[Backend, DataVersion] =
deriveObjectType[Backend, DataVersion](
ObjectTypeDescription("Data release version information"),
DocumentField("year", "Year of the Platform data release"),
DocumentField("month", "Month of the Platform data release"),
DocumentField("iteration",
"Iteration number of the Platform data release within the year-month period"
)
)
implicit val metaAPIVersionImp: ObjectType[Backend, APIVersion] =
deriveObjectType[Backend, APIVersion](
ObjectTypeDescription("API version information"),
DocumentField("x", "Major version number"),
DocumentField("y", "Minor version number"),
DocumentField("z", "Patch version number"),
DocumentField("suffix", "Optional version suffix (e.g., alpha, beta, rc)")
)
implicit val metaImp: ObjectType[Backend, Meta] = deriveObjectType[Backend, Meta](
ObjectTypeDescription(
"Metadata about the Open Targets Platform API including version information"
),
DocumentField("name", "Name of the platform"),
DocumentField("apiVersion", "API version information"),
DocumentField("dataVersion", "Data release version information"),
DocumentField("product", "Open Targets product"),
DocumentField("enableDataReleasePrefix",
"Flag indicating whether data release prefix is enabled"
),
DocumentField("dataPrefix", "Data release prefix"),
AddFields(
Field(
"downloads",
OptionType(StringType),
description = Some(
"Platform datasets described following MLCroissant metadata format. Datasets are described in a JSONLD file containing extensive metadata including table and column descriptions, schemas, location and relationships."
),
resolve = _.ctx.getDownloads
)
)
)
implicit val geneEssentialityScreenImp: ObjectType[Backend, GeneEssentialityScreen] =
deriveObjectType[Backend, GeneEssentialityScreen](
ObjectTypeDescription(
"CRISPR screening experiments supporting the essentiality assessment. Represents individual cell line assays from DepMap."
),
DocumentField("cellLineName",
"Name of the cancer cell line in which the gene essentiality was assessed"
),
DocumentField("depmapId", "Unique identifier of the assay in DepMap"),
DocumentField("diseaseCellLineId",
"Cell model passport identifier of a cell line modelling a disease"
),
DocumentField("diseaseFromSource",
"Disease associated with the cell line as reported in the source data"
),
DocumentField("expression", "Gene expression level in the corresponding cell line"),
DocumentField("geneEffect", "Gene effect score indicating the impact of gene knockout"),
DocumentField("mutation", "Background mutation the tested cell line have")
)
implicit val depMapEssentialityImp: ObjectType[Backend, DepMapEssentiality] =
deriveObjectType[Backend, DepMapEssentiality](
ObjectTypeDescription(
"Essentiality measurements extracted from DepMap, stratified by tissue or anatomical units. Gene effects below -1 can be considered dependencies."
),
DocumentField("screens",
"List of CRISPR screening experiments supporting the essentiality assessment"
),
DocumentField(
"tissueId",
"Identifier of the tissue from where the cells were sampled for assay [bioregistry:uberon]"
),
DocumentField("tissueName", "Name of the tissue from where the cells were sampled for assay")
)
implicit val targetPrioritisationImp: ObjectType[Backend, TargetPrioritisation] =
deriveObjectType[Backend, TargetPrioritisation](
ObjectTypeDescription(
"Target-specific properties used to prioritise targets for further investigation. Prioritisation factors cover several areas around clinical precedence, tractability, do-ability, and safety of the target. Values range from -1 (unfavourable/deprioritised) to 1 (favourable/prioritised)."
),
DocumentField("items", "List of key-value pairs representing prioritisation factors"),
ExcludeFields("targetId")
)
implicit val publicationImp: ObjectType[Backend, Publication] =
deriveObjectType[Backend, Publication](
ObjectTypeDescription("Referenced publication information"),
DocumentField("pmid", "PubMed identifier [bioregistry:pubmed]"),
DocumentField("pmcid", "PubMed Central identifier (if available) [bioregistry:pmc]"),
DocumentField("date", "Publication date"),
RenameField("date", "publicationDate"),
ExcludeFields("year", "month")
)
implicit val publicationsImp: ObjectType[Backend, Publications] =
deriveObjectType[Backend, Publications](
ObjectTypeDescription(
"List of referenced publications with total counts, earliest year and pagination cursor"
),
DocumentField("count", "Total number of publications matching the query"),
DocumentField("filteredCount", "Number of publications after applying filters"),
DocumentField("earliestPubYear", "Earliest publication year"),
DocumentField(
"cursor",
"Opaque pagination cursor to request the next page of results"
),
DocumentField("rows", "List of publications")
)
implicit val KeyValueImp: ObjectType[Backend, KeyValuePair] =
deriveObjectType[Backend, KeyValuePair](
ObjectTypeDescription(
"A key-value pair"
),
DocumentField("key", "Key or attribute name"),
DocumentField("value", "String representation of the value")
)
implicit val transcriptImp: ObjectType[Backend, Transcript] =
deriveObjectType[Backend, Transcript](
ObjectTypeDescription("Transcript annotation for a target gene"),
DocumentField("transcriptId", "Ensembl transcript identifier"),
DocumentField("biotype", "Biotype classification of the transcript"),
DocumentField("isEnsemblCanonical", "Whether this is the Ensembl canonical transcript"),
DocumentField("uniprotId", "UniProt accession mapped to the transcript"),
DocumentField("isUniprotReviewed", "Whether the UniProt entry is reviewed (Swiss-Prot)"),
DocumentField("translationId", "Ensembl translation identifier"),
DocumentField("alphafoldId", "AlphaFold structure prediction identifier"),
DocumentField("uniprotIsoformId", "UniProt isoform identifier")
)
implicit lazy val targetImp: ObjectType[Backend, Target] = deriveObjectType(
ObjectTypeDescription(
"Core annotation for drug targets (gene/proteins). Targets are defined based on EMBL-EBI Ensembl database and uses the Ensembl gene ID as the primary identifier. An Ensembl gene ID is considered potential drug target if included in the canonical assembly or if present alternative assemblies but encoding for a reviewed protein product according to the UniProt database."
),
DocumentField("id", "Unique identifier for the target [bioregistry:ensembl]"),
DocumentField("approvedSymbol", "Approved gene symbol of the target"),
DocumentField("approvedName", "Approved full name of the target gene"),
DocumentField(
"biotype",
"Biotype classification of the target gene, indicating if the gene is protein coding"
),
DocumentField("canonicalTranscript", "The Ensembl canonical transcript of the target gene"),
DocumentField("alternativeGenes",
"List of alternative Ensembl gene identifiers mapped to non-canonical chromosomes"
),
DocumentField("targetClass", "Target classification categories from ChEMBL"),
DocumentField("chemicalProbes",
"Chemical probes with high selectivity and specificity for the target."
),
DocumentField("dbXrefs", "Database cross-references for the target"),
DocumentField("functionDescriptions",
"Functional descriptions of the target gene sourced from UniProt"
),
DocumentField(
"constraint",
"Constraint scores for the target gene from GnomAD based on loss-of-function intolerance."
),
DocumentField("genomicLocation", "Genomic location information of the target gene"),
DocumentField("go", "List of Gene Ontology (GO) annotations related to the target"),
DocumentField(
"hallmarks",
"Hallmarks related to the target gene sourced from COSMIC"
),
DocumentField("homologues", "Homologues of the target gene in other species"),
DocumentField("proteinIds", "Protein identifiers associated with the target"),
DocumentField(
"safetyLiabilities",
"Known target safety effects and target safety risk information"
),
DocumentField("subcellularLocations",
"List of subcellular locations where the target protein is found"
),
DocumentField("synonyms", "List of synonyms for the target gene"),
DocumentField("obsoleteSymbols",
"List of obsolete symbols previously used for the target gene"
),
DocumentField("obsoleteNames", "List of obsolete names previously used for the target gene"),
DocumentField("nameSynonyms", "List of name-based synonyms for the target gene"),
DocumentField("symbolSynonyms", "List of symbol-based synonyms for the target gene"),
DocumentField("tep", "Target Enabling Package (TEP) information"),
DocumentField("tractability", "Tractability information for the target"),
DocumentField("transcriptIds",
"List of Ensembl transcript identifiers associated with the target"
),
DocumentField(
"transcripts",
"List of transcripts associated with the target including protein and structure annotations"
),
DocumentField("pathways", "Pathway annotations for the target"),
RenameField("go", "geneOntology"),
RenameField("constraint", "geneticConstraint"),
ReplaceField(
"studyLocusIds",
Field(
"credibleSets",
credibleSetsImp,
description = Some(
"95% credible sets for GWAS and molQTL studies. Credible sets include all variants in the credible set as well as the fine-mapping method and statistics used to estimate the credible set."
),
arguments = pageArg :: Nil,
complexity = Some(complexityCalculator(pageArg)),
resolve = ctx =>
if (ctx.value.studyLocusIds.isEmpty) {
Future.successful(CredibleSets.empty)
} else {
val credSetQueryArgs = CredibleSetQueryArgs(
ctx.value.studyLocusIds
)
ctx.ctx.getCredibleSets(credSetQueryArgs, ctx.arg(pageArg))
}
)
),
AddFields(
Field(
"similarEntities",
ListType(similarityGQLImp),
description = Some("Return similar labels using a model Word2CVec trained with PubMed"),
arguments = idsArg :: entityNames :: thresholdArg :: pageSize :: Nil,
complexity = Some(complexityCalculator(pageSize)),
resolve = c => {
val ids = c.arg(idsArg).getOrElse(List.empty)
val thres = c.arg(thresholdArg).getOrElse(0.1)
val cats = c.arg(entityNames).getOrElse(Nil).toList
val n = c.arg(pageSize).getOrElse(10)
c.ctx.getSimilarW2VEntities(c.value.id, ids.toSet, cats, thres, n)
}
),
Field(
"literatureOcurrences",
publicationsImp,
description = Some(
"Return the list of publications that mention the main entity, " +
"alone or in combination with other entities"
),
arguments = idsArg :: startYear :: startMonth :: endYear :: endMonth :: cursor :: Nil,
resolve = c => {
val ids = c.arg(idsArg).getOrElse(List.empty) ++ List(c.value.id)
val filterStartYear = c.arg(startYear)
val filterStartMonth = c.arg(startMonth)
val filterEndYear = c.arg(endYear)
val filterEndMonth = c.arg(endMonth)
val cur = c.arg(cursor)
c.ctx.getLiteratureOcurrences(
ids.toSet,
filterStartYear,
filterStartMonth,
filterEndYear,
filterEndMonth,
cur
)
}
),
Field(
"evidences",
evidencesImp,
description = Some(
"Target-disease evidence from all data sources supporting associations between this target and diseases or phenotypes. Evidence entries are reported and scored according to confidence in the association."
),
arguments = efoIds :: datasourceIdsArg :: pageSize :: cursor :: Nil,
complexity = Some(complexityCalculator(pageSize)),
resolve = ctx =>
ctx.ctx.getEvidencesByEfoId(
ctx arg datasourceIdsArg,
Seq(ctx.value.id),
ctx arg efoIds,
Some(("score", "desc")),
ctx arg pageSize,
ctx arg cursor
)
),
Field(
"interactions",
OptionType(interactionsImp),
description = Some(
"Molecular interactions reporting experimental or functional interactions between this target and other molecules. Interactions are integrated from multiple databases capturing physical interactions (e.g., IntAct), directional interactions (e.g., Signor), pathway relationships (e.g., Reactome), or functional interactions (e.g., STRINGdb)."
),
arguments = scoreThreshold :: databaseName :: pageArg :: Nil,
complexity = Some(complexityCalculator(pageArg)),
resolve = ctx =>
InteractionsDeferred(ctx.value.id,
ctx.arg(scoreThreshold),
ctx.arg(databaseName),
ctx.arg(pageArg)
)
),
Field(
"mousePhenotypes",
ListType(mousePhenotypeImp),
description = Some(
"Mouse phenotype information linking this human target to observed phenotypes in mouse models. Provides data on phenotypes observed when the target gene is modified in mouse models."
),
resolve = r =>
DeferredValue(mousePhenotypesFetcher.deferOpt(r.value.id)).map {
case Some(phenotypes) => phenotypes.rows
case None => Seq.empty
}
),
Field(
"expressions",
ListType(expressionImp),
description = Some(
"Baseline RNA and protein expression data across tissues for this target. Expression data shows how targets are selectively expressed across different tissues and biosamples, combining values from multiple sources including Expression Atlas and Human Protein Atlas."
),
resolve = r =>
DeferredValue(expressionFetcher.deferOpt(r.value.id)).map {
case Some(expressions) => expressions.rows
case None => Seq.empty
}
),
Field(
"baselineExpression",
baselineExpressionImp,
description = Some("Baseline expression"),
arguments = pageArg :: Nil,
complexity = Some(complexityCalculator(pageArg)),
resolve = ctx => ctx.ctx.getBaselineExpression(ctx.value.id, ctx.arg(pageArg))
),
Field(
"associatedDiseases",
associatedOTFDiseasesImp,
description = Some(
"Target-disease associations calculated on-the-fly using configurable data source weights and evidence filters. Returns associations with aggregated scores and evidence counts supporting the target-disease relationship."
),
arguments =
BIds :: indirectTargetEvidences :: datasourceSettingsListArg :: includeMeasurements :: facetFiltersListArg :: BFilterString :: scoreSorting :: pageArg :: Nil,
complexity = Some(complexityCalculator(pageArg)),
resolve = ctx => {
(ctx arg datasourceSettingsListArg) foreach { settingsList =>
val invalidWeights =
for setting <- settingsList if setting.weight > 1 || setting.weight < 0
yield s"The assigned weight for '${setting.id}' was ${setting.weight}"
if invalidWeights.nonEmpty then
val errors = Vector(
invalidWeights.map(invWeight =>
InvalidArgValueError("weight", "between 0 and 1", Some(invWeight))
)*
)
throw InputParameterCheckError(errors)
}
ctx.ctx.getAssociationsTargetFixed(
ctx.value,
ctx arg datasourceSettingsListArg,
ctx arg indirectTargetEvidences getOrElse false,
ctx arg includeMeasurements getOrElse false,
ctx arg facetFiltersListArg getOrElse (Seq.empty),
ctx arg BIds map (_.toSet) getOrElse Set.empty,
ctx arg BFilterString,
(ctx arg scoreSorting) map (_.split(" ").take(2).toList match {
case a :: b :: Nil => (a, b)
case a :: Nil => (a, "desc")
case _ => ("score", "desc")
}),
ctx arg pageArg
)
}
),
Field(
"prioritisation",
OptionType(targetPrioritisationImp),
description = Some(
"Target-specific properties used to prioritise targets for further investigation. Prioritisation factors cover several areas around clinical precedence, tractability, do-ability, and safety of the target. Values range from -1 (unfavourable/deprioritised) to 1 (favourable/prioritised)."
),
arguments = Nil,
resolve = r => targetPrioritisationFetcher.deferOpt(r.value.id)
),
Field(
"isEssential",
OptionType(BooleanType),
description = Some(
"Flag indicating whether this target is essential based on CRISPR screening data from cancer cell line models. Essential genes are those that show dependency when knocked out in cellular models."
),
resolve = ctx =>
DeferredValue(targetEssentialityFetcher.deferOpt(ctx.value.id)).map {
case Some(ess) =>
ess.geneEssentiality.head.isEssential
case None => None
}
),
Field(
"depMapEssentiality",
OptionType(ListType(depMapEssentialityImp)),
description = Some(
"Essentiality measurements extracted from DepMap, stratified by tissue or anatomical units. Gene essentiality is assessed based on dependencies exhibited when knocking out genes in cancer cellular models using CRISPR screenings from the Cancer Dependency Map (DepMap) Project. Gene effects below -1 can be considered dependencies."
),
resolve = ctx =>
DeferredValue(targetEssentialityFetcher.deferOpt(ctx.value.id)).map {
case Some(ess) =>
ess.geneEssentiality.flatMap(_.depMapEssentiality)
case None => None
}
),
Field(
"pharmacogenomics",
ListType(pharmacogenomicsImp),
description = Some(
"Pharmacogenomics data linking genetic variants affecting this target to drug responses. Data is integrated from sources including ClinPGx and describes how genetic variants influence individual drug responses when targeting this gene product."
),
resolve = ctx =>
DeferredValue(pharmacogenomicsByTargetFetcher.deferOpt(ctx.value.id)).map {
case Some(pgByTarget) => pgByTarget.pharmacogenomics
case None => Seq.empty
}
),
Field(
"proteinCodingCoordinates",
proteinCodingCoordinatesImp,
description = Some(
"Protein coding coordinates linking variants affecting this target to their amino acid-level consequences in protein products. Describes variant consequences at the protein level including amino acid changes and their positions for this target."
),
arguments = pageArg :: Nil,
complexity = Some(complexityCalculator(pageArg)),
resolve = ctx => ProteinCodingCoordinatesByTargetDeferred(ctx.value.id, ctx.arg(pageArg))
),
Field(
"drugAndClinicalCandidates",
clinicalTargetsImp,
description = Some(""),
arguments = Nil,
resolve = ctx => ctx.ctx.getClinicalTargetsByTarget(ctx.value.id)
),
Field(
"novelty",
noveltyResultsImp,
description = Some("Novelty"),
arguments = efoId :: isDirect :: pageArg :: Nil,
resolve = ctx =>
ctx.ctx.getNovelty(ctx.arg(efoId), ctx.value.id, ctx.arg(isDirect), ctx.arg(pageArg))
)
)
)
implicit lazy val chemicalProbeUrlImp: ObjectType[Backend, ChemicalProbeUrl] =
deriveObjectType[Backend, ChemicalProbeUrl](
ObjectTypeDescription("URL information for chemical probe resources"),
DocumentField("niceName", "Nice name for the linked URL"),
DocumentField("url", "URL providing details about the chemical probe")
)
implicit lazy val chemicalProbeImp: ObjectType[Backend, ChemicalProbe] =
deriveObjectType[Backend, ChemicalProbe](
ObjectTypeDescription(
"Chemical probes related to the target. High-quality chemical probes are small molecules that can be used to modulate and study the function of proteins."
),
DocumentField("id", "Unique identifier for the chemical probe"),
DocumentField("control", "Whether the chemical probe serves as a control"),
DocumentField("drugId", "Drug ID associated with the chemical probe"),
DocumentField("mechanismOfAction", "Mechanism of action of the chemical probe"),
DocumentField("isHighQuality", "Indicates if the chemical probe is high quality"),
DocumentField("origin", "Origin of the chemical probe"),
DocumentField("probeMinerScore", "Score from ProbeMiner for chemical probe quality"),
DocumentField("probesDrugsScore", "Score for chemical probes related to druggability"),
DocumentField("scoreInCells", "Score indicating chemical probe activity in cells"),
DocumentField("scoreInOrganisms", "Score indicating chemical probe activity in organisms"),
DocumentField("targetFromSourceId", "Ensembl gene ID of the target for the chemical probe"),
DocumentField("urls", "URLs linking to more information about the chemical probe")
)
implicit lazy val reactomePathwayImp: ObjectType[Backend, ReactomePathway] =
deriveObjectType[Backend, ReactomePathway](
ObjectTypeDescription("Reactome pathway information for the target"),
DocumentField("pathway", "Pathway name"),
DocumentField("pathwayId", "Reactome pathway identifier"),
DocumentField("topLevelTerm", "Top-level pathway term")
)
// disease
implicit lazy val diseaseSynonymsImp: ObjectType[Backend, DiseaseSynonyms] =
deriveObjectType[Backend, DiseaseSynonyms](
ObjectTypeDescription("Synonymous disease labels grouped by relationship type"),
DocumentField("relation", "Type of synonym relationship (e.g., exact, related, narrow)"),
DocumentField("terms", "List of synonymous disease labels for this relationship type")
)
implicit lazy val diseaseImp: ObjectType[Backend, Disease] = deriveObjectType(
ObjectTypeDescription(
"Core annotation for diseases or phenotypes. A disease or phenotype in the Platform is understood as any disease, phenotype, biological process or measurement that might have any type of causality relationship with a human target. The EMBL-EBI Experimental Factor Ontology (EFO) (slim version) is used as scaffold for the disease or phenotype entity."
),
DocumentField("id", "Open Targets disease identifier [bioregistry:efo]"),
DocumentField("name", "Preferred disease or phenotype label"),
DocumentField("description", "Short description of the disease or phenotype"),
DocumentField("synonyms", "Synonymous disease or phenotype labels"),
DocumentField("dbXRefs", "Cross-references to external disease ontologies"),
DocumentField("obsoleteTerms", "Obsoleted ontology terms replaced by this term"),
DocumentField("directLocationIds", "EFO terms for direct anatomical locations"),
DocumentField("indirectLocationIds",
"EFO terms for indirect anatomical locations (propagated)"
),
DocumentField("ancestors",
"Ancestor disease nodes in the EFO ontology up to the top-level therapeutic area"
),
DocumentField("descendants", "Descendant disease nodes in the EFO ontology below this term"),
ReplaceField(
"therapeuticAreas",
Field(
"therapeuticAreas",
ListType(diseaseImp),
Some(
"Ancestor therapeutic area nodes the disease or phenotype term belongs in the EFO ontology"
),
resolve = r => diseasesFetcher.deferSeq(r.value.therapeuticAreas)
)
),
ReplaceField(
"parents",
Field(
"parents",
ListType(diseaseImp),
Some("Immediate parent disease nodes in the ontology"),
resolve = r => diseasesFetcher.deferSeq(r.value.parents)
)
),
ReplaceField(
"children",
Field(
"children",
ListType(diseaseImp),
Some("Direct child disease nodes in the ontology"),
resolve = r => diseasesFetcher.deferSeq(r.value.children)
)
),
AddFields(
Field(
"directLocations",
ListType(diseaseImp),
Some("Diseases mapped to direct anatomical locations"),
resolve = r => diseasesFetcher.deferSeqOpt(r.value.directLocationIds.getOrElse(Seq.empty))
),
Field(
"indirectLocations",
ListType(diseaseImp),
Some("Diseases mapped via indirect (propagated) anatomical locations"),
resolve = r => diseasesFetcher.deferSeqOpt(r.value.indirectLocationIds.getOrElse(Seq.empty))
),
Field(
"similarEntities",
ListType(similarityGQLImp),
description = Some("Semantically similar diseases based on a PubMed word embedding model"),
arguments = idsArg :: entityNames :: thresholdArg :: pageSize :: Nil,
complexity = Some(complexityCalculator(pageSize)),
resolve = c => {
val ids = c.arg(idsArg).getOrElse(List.empty)
val thres = c.arg(thresholdArg).getOrElse(0.1)
val cats = c.arg(entityNames).getOrElse(Nil).toList
val n = c.arg(pageSize).getOrElse(10)
c.ctx.getSimilarW2VEntities(c.value.id, ids.toSet, cats, thres, n)
}
),
Field(
"literatureOcurrences",
publicationsImp,
description =
Some("Publications that mention this disease, alone or alongside other entities"),
arguments = idsArg :: startYear :: startMonth :: endYear :: endMonth :: cursor :: Nil,
resolve = c => {
val ids = c.arg(idsArg).getOrElse(List.empty) ++ List(c.value.id)
val filterStartYear = c.arg(startYear)
val filterStartMonth = c.arg(startMonth)
val filterEndYear = c.arg(endYear)
val filterEndMonth = c.arg(endMonth)
val cur = c.arg(cursor)
c.ctx.getLiteratureOcurrences(ids.toSet,
filterStartYear,
filterStartMonth,
filterEndYear,
filterEndMonth,
cur
)
}
),
Field(
"phenotypes",
diseaseHPOsImp,
description = Some(
"Human Phenotype Ontology (HPO) annotations linked to this disease as clinical signs or symptoms"
),
arguments = pageArg :: Nil,
complexity = Some(complexityCalculator(pageArg)),
resolve = ctx => DiseaseHPOsDeferred(ctx.value.id, ctx.arg(pageArg))
),
Field(
"evidences",
evidencesImp,
description =
Some("Target–disease evidence items supporting associations for this disease"),
arguments =
ensemblIds :: indirectEvidences :: datasourceIdsArg :: pageSize :: cursor :: Nil,
complexity = Some(complexityCalculator(pageSize)),
resolve = ctx => {
val indirects = ctx.arg(indirectEvidences).getOrElse(true)
val efos = if (indirects) ctx.value.id +: ctx.value.descendants else ctx.value.id +: Nil
ctx.ctx.getEvidencesByEfoId(
ctx arg datasourceIdsArg,
ctx arg ensemblIds,
efos,
Some(("score", "desc")),
ctx arg pageSize,
ctx arg cursor
)
}
),
Field(
"otarProjects",
ListType(otarProjectImp),
description = Some(
"Open Targets (OTAR) projects linked to this disease. Data only available in Partner Platform Preview (PPP)"
),
resolve = r =>
DeferredValue(otarProjectsFetcher.deferOpt(r.value.id)).map {
case Some(otars) => otars.rows
case None => Seq.empty
}
),
Field(
"associatedTargets",
associatedOTFTargetsImp,
description = Some(
"Target–disease associations computed on the fly with configurable datasource weights and filters"
),
arguments =
BIds :: indirectEvidences :: datasourceSettingsListArg :: facetFiltersListArg :: BFilterString :: scoreSorting :: pageArg :: Nil,
complexity = Some(complexityCalculator(pageArg)),
resolve = ctx =>
(ctx arg datasourceSettingsListArg) foreach { settingsList =>
val invalidWeights =
for setting <- settingsList if setting.weight > 1 || setting.weight < 0
yield s"The assigned weight for '${setting.id}' was ${setting.weight}"
if invalidWeights.nonEmpty then
val errors = Vector(
invalidWeights.map(invWeight =>
InvalidArgValueError("weight", "between 0 and 1", Some(invWeight))
)*
)
throw InputParameterCheckError(errors)
}
ctx.ctx.getAssociationsDiseaseFixed(
ctx.value,
ctx arg datasourceSettingsListArg,
ctx arg indirectEvidences getOrElse (true),
ctx arg facetFiltersListArg getOrElse (Seq.empty),
ctx arg BIds map (_.toSet) getOrElse (Set.empty),
ctx arg BFilterString,
(ctx arg scoreSorting) map (_.split(" ").take(2).toList match {
case a :: b :: Nil => (a, b)
case a :: Nil => (a, "desc")
case _ => ("score", "desc")
}),
ctx arg pageArg
)
),
Field(
"resolvedAncestors",
ListType(diseaseImp),
description = Some(
"All ancestor diseases in the ontology from this term up to the top-level therapeutic area"
),
arguments = Nil,
resolve = ctx => diseasesFetcher.deferSeq(ctx.value.ancestors)
),
Field(
"drugAndClinicalCandidates",
clinicalIndicationsFromDiseaseImp,
description = Some(
"Clinical indications for this disease as reported by clinical trial records."
),
arguments = Nil,
resolve = ctx => ctx.ctx.getClinicalIndicationsByDisease(ctx.value.id)
),
Field(
"novelty",
noveltyResultsImp,
description = Some("Novelty"),
arguments = ensemblId :: isDirect :: pageArg :: Nil,
resolve = ctx =>
ctx.ctx.getNovelty(ctx.value.id, ctx.arg(ensemblId), ctx.arg(isDirect), ctx.arg(pageArg))
)
)
)
implicit val tractabilityImp: ObjectType[Backend, Tractability] =
deriveObjectType[Backend, Tractability](
ObjectTypeDescription(
"Tractability information for the target. Indicates the feasibility of targeting the gene/protein with different therapeutic modalities."
),
RenameField("id", "label"),
DocumentField("id", "Tractability category label"),
DocumentField("modality", "Modality of the tractability assessment"),
DocumentField("value", "Tractability value assigned to the target (true indicates tractable)")
)
implicit val scoredDataTypeImp: ObjectType[Backend, ScoredComponent] =
deriveObjectType[Backend, ScoredComponent](
ObjectTypeDescription("Scored component used in association scoring"),
DocumentField("id", "Component identifier (e.g., datatype or datasource name)"),
DocumentField(
"score",
"Association score for the component. Scores are normalized to a range of 0-1. The higher the score, the stronger the association."
)
)
implicit val associatedOTFTargetImp: ObjectType[Backend, Association] =
deriveObjectType[Backend, Association](
ObjectTypeName("AssociatedTarget"),
ObjectTypeDescription("Associated target entity"),
DocumentField(
"score",
"Overall association score aggregated across all evidence types. A higher score indicates a stronger association between the target and the disease. Scores are normalized to a range of 0-1."
),
DocumentField(
"datatypeScores",
"Association scores computed for every datatype (e.g., Genetic associations, Somatic, Literature)"
),
DocumentField(
"datasourceScores",
"Association scores computed for every datasource (e.g., IMPC, ChEMBL, Gene2Phenotype)"
),
DocumentField(
"noveltyDirect",
"A measure of how novel the target–disease association is, calculated based on the accumulation of direct evidence over time"
),
DocumentField(
"noveltyIndirect",
"A measure of how novel the target–disease association is, calculated based on the accumulation of indirect evidence over time"
),
ReplaceField(
"id",
Field("target",
targetImp,
Some("Associated target entity"),
resolve = r => targetsFetcher.defer(r.value.id)
)
)
)
implicit val associatedOTFDiseaseImp: ObjectType[Backend, Association] =
deriveObjectType[Backend, Association](
ObjectTypeName("AssociatedDisease"),
ObjectTypeDescription("Associated disease entity"),
DocumentField(
"score",
"Overall association score aggregated across all evidence types. A higher score indicates a stronger association between the target and the disease. Scores are normalized to a range of 0-1."
),
DocumentField(
"datatypeScores",
"Association scores computed for every datatype (e.g., Genetic associations, Somatic, Literature)"
),
DocumentField(
"datasourceScores",
"Association scores computed for every datasource (e.g., IMPC, ChEMBL, Gene2Phenotype)"
),
DocumentField(
"noveltyDirect",
"A measure of how novel the target–disease association is, calculated based on the accumulation of direct evidence over time"
),
DocumentField(
"noveltyIndirect",
"A measure of how novel the target–disease association is, calculated based on the accumulation of indirect evidence over time"
),
ReplaceField(
"id",
Field(
"disease",
diseaseImp,
Some("Associated disease entity"),
resolve = r => diseasesFetcher.defer(r.value.id)
)
)
)
implicit val credibleSetsImp: ObjectType[Backend, CredibleSets] =
deriveObjectType[Backend, CredibleSets](
ObjectTypeDescription(
"95% credible sets for GWAS and molQTL studies. Credible sets include all variants in the credible set as well as the fine-mapping method and statistics used to estimate the credible set."
),
DocumentField("count", "Total number of credible sets matching the query filters"),
DocumentField(
"rows",
"List of credible set entries with their associated statistics and fine-mapping information"
)
)
implicit val noveltyResultsImp: ObjectType[Backend, NoveltyResults] =
deriveObjectType[Backend, NoveltyResults](
ObjectTypeDescription(
"Novelty of the association between a target and a disease. Calculated based on the accumulation of evidence over time, providing insights into how novel or well-established a target-disease association is."
),
DocumentField(
"count",
"Total number of novelty results matching the query filters"
),
DocumentField(
"rows",
"List of novelty entries with their associated novelty scores and temporal information"
)
)
implicit val noveltyImp: ObjectType[Backend, Novelty] = deriveObjectType[Backend, Novelty](
ObjectTypeDescription(
"Novelty of the association between a target and a disease. Calculated based on the accumulation of evidence over time, providing insights into how novel or well-established a target-disease association is."
),
DocumentField("diseaseId", "EFO ID of the disease"),
DocumentField(
"targetId",
"Ensembl ID of the target gene"
),
DocumentField(
"aggregationType",
"Type of aggregation used for novelty calculation"
),
DocumentField(
"aggregationValue",
"Value used for novelty aggregation"
),
DocumentField(
"year",
"Year of the evidence item used for novelty calculation"
),
DocumentField(
"associationScore",
"Association score between the target and disease"
),
DocumentField(
"novelty",
"Novelty score indicating how novel the target-disease association is."
),
DocumentField(
"yearlyEvidenceCount",
"Yearly count of evidence items"
),
DocumentField(
"isDirect",
"Flag indicating whether the novelty calculation is based on direct evidence only or includes indirect evidence"
),
ExcludeFields("meta_total")
)
implicit val tissueImp: ObjectType[Backend, Tissue] = deriveObjectType[Backend, Tissue](
ObjectTypeDescription(
"Baseline RNA and protein expression data across tissues. This data does not contain raw expression values, instead to shows how targets are selectively expressed across different tissues. This dataset combines expression values from multiple sources including Expression Atlas and Human Protein Atlas."
),
DocumentField("id", "UBERON id"),
DocumentField("label", "Name of the biosample the expression data is from"),
DocumentField("anatomicalSystems",
"List of anatomical systems that the biosample can be found in"
),
DocumentField("organs", "List of organs that the biosample can be found in")
)
implicit val rnaExpressionImp: ObjectType[Backend, RNAExpression] =
deriveObjectType[Backend, RNAExpression](
ObjectTypeDescription(
"RNA expression values for a particular biosample and gene combination"
),
DocumentField("zscore", "Expression zscore"),
DocumentField("value", "Expression value"),
DocumentField("unit", "Unit for the RNA expression"),
DocumentField("level", "Level of RNA expression normalised to 0-5 or -1 if absent")
)
implicit val cellTypeImp: ObjectType[Backend, CellType] = deriveObjectType[Backend, CellType](
ObjectTypeDescription("Cell type where protein levels were measured"),
DocumentField("reliability", "Reliability of the cell type measurement"),
DocumentField("name", "Cell type name"),
DocumentField("level", "Level of expression for this cell type")
)
implicit val proteinExpressionImp: ObjectType[Backend, ProteinExpression] =
deriveObjectType[Backend, ProteinExpression](
ObjectTypeDescription(
"Struct containing relevant protein expression values for a particular biosample and gene combination"
),
DocumentField("reliability", "Reliability of the protein expression measurement"),
DocumentField("level", "Level of protein expression normalised to 0-5 or -1 if absent"),
DocumentField("cellType", "List of cell types were protein levels were measured")
)
implicit val expressionImp: ObjectType[Backend, Expression] =
deriveObjectType[Backend, Expression](
ObjectTypeDescription(
"Array of structs containing expression data relevant to a particular gene and biosample combination"
),
DocumentField("tissue", "Tissue/biosample information for the expression data"),
DocumentField("rna", "RNA expression values for the biosample and gene combination"),
DocumentField("protein", "Protein expression values for the biosample and gene combination")
)
implicit val expressionsImp: ObjectType[Backend, Expressions] =
deriveObjectType[Backend, Expressions](
ObjectTypeDescription(
"Baseline RNA and protein expression data across tissues for a target gene"
),
ExcludeFields("id"),
DocumentField("rows",
"Array of structs containing expression data relevant to a particular gene"
)
)
implicit lazy val baselineExpressionRowImp: ObjectType[Backend, BaselineExpressionRow] =
deriveObjectType[Backend, BaselineExpressionRow](
ReplaceField(
"tissueBiosampleId",
Field(
"tissueBiosample",
OptionType(biosampleImp),
Some("Tissue biosample entity"),
resolve = r =>
r.value.tissueBiosampleId match {
case Some(id) => biosamplesFetcher.deferOpt(id)
case None => Future.successful(None)
}
)
),
ReplaceField(
"tissueBiosampleParentId",
Field(
"tissueBiosampleParent",
OptionType(biosampleImp),
Some("Tissue biosample parent entity"),
resolve = r =>
r.value.tissueBiosampleParentId match {
case Some(id) => biosamplesFetcher.deferOpt(id)
case None => Future.successful(None)
}
)
),
ReplaceField(
"celltypeBiosampleId",
Field(
"celltypeBiosample",
OptionType(biosampleImp),
Some("Cell type biosample entity"),
resolve = r =>
r.value.celltypeBiosampleId match {
case Some(id) => biosamplesFetcher.deferOpt(id)
case None => Future.successful(None)
}
)
),
ReplaceField(
"celltypeBiosampleParentId",
Field(
"celltypeBiosampleParent",
OptionType(biosampleImp),
Some("Cell type biosample parent entity"),
resolve = r =>
r.value.celltypeBiosampleParentId match {
case Some(id) => biosamplesFetcher.deferOpt(id)
case None => Future.successful(None)
}
)
)
)
implicit lazy val baselineExpressionImp: ObjectType[Backend, BaselineExpression] =
deriveObjectType[Backend, BaselineExpression]()
implicit val adverseEventImp: ObjectType[Backend, AdverseEvent] =
deriveObjectType[Backend, AdverseEvent](
ObjectTypeDescription(
"Significant adverse events associated with drugs sharing the same pharmacological target. This dataset is based on the FDA's Adverse Event Reporting System (FAERS) reporting post-marketing surveillance data and it's filtered to include only reports submitted by health professionals. The significance of a given target-ADR is estimated using a Likelihood Ratio Test (LRT) using all reports associated with the drugs with the same target."
),
DocumentField("name", "Meddra term on adverse event"),
DocumentField("meddraCode", "8 digit unique meddra identification number"),
DocumentField("count", "Number of reports mentioning drug and adverse event"),
DocumentField("logLR", "Log-likelihood ratio")
)
implicit val adverseEventsImp: ObjectType[Backend, AdverseEvents] =
deriveObjectType[Backend, AdverseEvents](
ObjectTypeDescription(
"Significant adverse events associated with drugs sharing the same pharmacological target. This dataset is based on the FDA's Adverse Event Reporting System (FAERS) reporting post-marketing surveillance data and it's filtered to include only reports submitted by health professionals. The significance of a given target-ADR is estimated using a Likelihood Ratio Test (LRT) using all reports associated with the drugs with the same target."
),
DocumentField("count", "Total significant adverse events"),
DocumentField("criticalValue", "LLR critical value to define significance"),
DocumentField("rows", "Significant adverse event entries")
)
implicit val otarProjectImp: ObjectType[Backend, OtarProject] =
deriveObjectType[Backend, OtarProject](
ObjectTypeDescription(
"Open Targets (OTAR) project information associated with a disease. Data only available in Partner Platform Preview (PPP)"