-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_profile_info.py
50 lines (43 loc) · 1.02 KB
/
get_profile_info.py
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
import requests
import json
def fetch_molecular_profile(mpId):
url = 'https://civicdb.org/api/graphql'
query = """
query MolecularProfileSummary($mpId: Int!) {
molecularProfile(id: $mpId) {
...MolecularProfileSummaryFields
}
}
fragment MolecularProfileSummaryFields on MolecularProfile {
parsedName {
...MolecularProfileParsedName
}
}
fragment MolecularProfileParsedName on MolecularProfileSegment {
__typename
... on MolecularProfileTextSegment {
text
}
... on Gene {
id
name
link
}
... on Variant {
id
name
link
deprecated
}
}
"""
variables = {"mpId": mpId}
response = requests.post(url, json={'query': query, 'variables': variables})
if response.status_code == 200:
return response.json()
else:
response.raise_for_status()
# Example usage
mpId = 4432
result = fetch_molecular_profile(mpId)
print(json.dumps(result))