Skip to content

Commit 673d507

Browse files
author
=
committed
fix strawberry types for pharos graphql api
1 parent b60c794 commit 673d507

File tree

2 files changed

+56
-17
lines changed

2 files changed

+56
-17
lines changed

src/api_adapters/strawberry_models/pharos_query_models.py

Lines changed: 56 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,26 @@
1010
from src.interfaces.simple_enum import NodeLabel, RelationshipLabel
1111
from src.models.analyte import Synonym
1212
from src.models.gene import Gene as GeneBase, GeneticLocation
13-
from src.models.generif import GeneGeneRifRelationship, GeneRif as GeneRifBase
13+
from src.models.generif import GeneGeneRifRelationship as GeneGeneRifRelationshipBase, GeneRif as GeneRifBase
1414
from src.models.go_term import GoTerm as GoTermBase, ProteinGoTermRelationship as ProteinGoTermRelationshipBase, \
1515
GoEvidence as GoEvidenceBase
16-
from src.models.ligand import Ligand as LigandBase, ProteinLigandRelationship, ActivityDetails
16+
from src.models.ligand import Ligand as LigandBase, ProteinLigandRelationship as ProteinLigandRelationshipBase, ActivityDetails
1717
from src.models.node import Node, EquivalentId, Relationship
1818
from src.models.protein import Protein as ProteinBase
19-
from src.models.transcript import Transcript as TranscriptBase, TranscriptLocation, IsoformProteinRelationship, \
20-
GeneProteinRelationship, \
21-
TranscriptProteinRelationship, GeneTranscriptRelationship
19+
from src.models.transcript import Transcript as TranscriptBase, TranscriptLocation, IsoformProteinRelationship as IsoformProteinRelationshipBase, \
20+
GeneProteinRelationship as GeneProteinRelationshipBase, \
21+
TranscriptProteinRelationship as TranscriptProteinRelationshipBase, GeneTranscriptRelationship as GeneTranscriptRelationshipBase
2222

2323
NodeLabel = strawberry.type(NodeLabel)
2424
Node = strawberry.type(Node)
2525
EquivalentId = strawberry.type(EquivalentId)
2626
Synonym = strawberry.type(Synonym)
2727
GeneticLocation = strawberry.type(GeneticLocation)
2828
ActivityDetails = strawberry.type(ActivityDetails)
29-
30-
IsoformProteinRelationship = strawberry.type(IsoformProteinRelationship)
31-
GeneProteinRelationship = strawberry.type(GeneProteinRelationship)
32-
TranscriptProteinRelationship = strawberry.type(TranscriptProteinRelationship)
33-
GeneTranscriptRelationship = strawberry.type(GeneTranscriptRelationship)
34-
ProteinLigandRelationship = strawberry.type(ProteinLigandRelationship)
35-
GeneGeneRifRelationship = strawberry.type(GeneGeneRifRelationship)
3629
RelationshipLabel = strawberry.type(RelationshipLabel)
3730
Relationship = strawberry.type(Relationship)
38-
3931
TranscriptLocation = strawberry.type(TranscriptLocation)
4032

41-
4233
@strawberry.type
4334
class GeneRif(GeneRifBase):
4435
pmids: List[str]
@@ -292,9 +283,59 @@ class ProteinGoTermRelationship(ProteinGoTermRelationshipBase):
292283
@strawberry.field()
293284
def provenance(root) -> Provenance:
294285
return Provenance.parse_provenance_fields(root)
295-
286+
start_node: Protein
287+
end_node: GoTerm
296288
evidence: List[GoEvidence]
297289

290+
291+
@strawberry.type
292+
class IsoformProteinRelationship(IsoformProteinRelationshipBase):
293+
@strawberry.field()
294+
def provenance(root) -> Provenance:
295+
return Provenance.parse_provenance_fields(root)
296+
start_node: Protein
297+
end_node: Protein
298+
299+
@strawberry.type
300+
class GeneProteinRelationship(GeneProteinRelationshipBase):
301+
@strawberry.field()
302+
def provenance(root) -> Provenance:
303+
return Provenance.parse_provenance_fields(root)
304+
start_node: Gene
305+
end_node: Protein
306+
307+
@strawberry.type
308+
class TranscriptProteinRelationship(TranscriptProteinRelationshipBase):
309+
@strawberry.field()
310+
def provenance(root) -> Provenance:
311+
return Provenance.parse_provenance_fields(root)
312+
start_node: Transcript
313+
end_node: Protein
314+
315+
@strawberry.type
316+
class GeneTranscriptRelationship(GeneTranscriptRelationshipBase):
317+
@strawberry.field()
318+
def provenance(root) -> Provenance:
319+
return Provenance.parse_provenance_fields(root)
320+
start_node: Gene
321+
end_node: Transcript
322+
323+
@strawberry.type
324+
class ProteinLigandRelationship(ProteinLigandRelationshipBase):
325+
@strawberry.field()
326+
def provenance(root) -> Provenance:
327+
return Provenance.parse_provenance_fields(root)
328+
start_node: Protein
329+
end_node: Ligand
330+
331+
@strawberry.type
332+
class GeneGeneRifRelationship(GeneGeneRifRelationshipBase):
333+
@strawberry.field()
334+
def provenance(root) -> Provenance:
335+
return Provenance.parse_provenance_fields(root)
336+
start_node: Gene
337+
end_node: GeneRif
338+
298339
ProteinGeneQueryResult = make_linked_list_result_type("ProteinGeneQueryResult", "ProteinGeneDetails", GeneProteinRelationship, Gene)
299340
ProteinTranscriptQueryResult = make_linked_list_result_type("ProteinTranscriptQueryResult", "ProteinTranscriptDetails", TranscriptProteinRelationship, Transcript)
300341
ProteinGoTermQueryResult = make_linked_list_result_type("ProteinGoTermQueryResult", "ProteinGoTermDetails", ProteinGoTermRelationship, GoTerm)

src/api_adapters/strawberry_models/pounce_query_models.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,6 @@ class GeneDataResults:
466466
ExperimentInvestigatorQueryResult = make_linked_list_result_type("ExperimentInvestigatorQueryResult", "ExperimentInvestigatorDetails", ExperimentInvestigatorRelationship, Investigator)
467467
InvestigatorExperimentQueryResult = make_linked_list_result_type("InvestigatorExperimentQueryResult", "InvestigatorExperimentDetails", ExperimentInvestigatorRelationship, Experiment)
468468

469-
top_level_classes = [Biospecimen, Sample, Investigator, Protein, Project, ProjectType, Experiment, Gene, Metabolite]
470-
471469
ENDPOINTS: Dict[type, Dict[str, str]] = {
472470
Project: {
473471
"list": "projects",

0 commit comments

Comments
 (0)