Skip to content

Commit

Permalink
update apps
Browse files Browse the repository at this point in the history
  • Loading branch information
rhdolin committed Aug 22, 2024
1 parent 7cf2ec8 commit afe9cbb
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 37 deletions.
34 changes: 17 additions & 17 deletions genomics-apps/PGxScreening.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
)


@st.cache
@st.cache_data
def findSubjectHaplotypes(subject):
# CYP2B6, CYP2C9, CYP2C19, CYP2D6, CYP3A5, NUDT15, SLCO1B1, TPMP, UGT1A1
url = 'https://fhir-gen-ops.herokuapp.com/subject-operations/genotype-operations/$find-subject-haplotypes?subject='+subject + \
Expand All @@ -23,7 +23,7 @@ def findSubjectHaplotypes(subject):
return r.json()


@st.cache
@st.cache_data
def findSubjectTxImplications(subject, haplotypes):
url = 'https://fhir-gen-ops.herokuapp.com/subject-operations/phenotype-operations/$find-subject-tx-implications?subject='+subject+'&haplotypes='+haplotypes
headers = {'Accept': 'application/json'}
Expand Down Expand Up @@ -90,7 +90,8 @@ def getMedicationList(subject):
if count > 0:
for i in implications["parameter"]:
if i["name"] == "implication":
# get evidenceLevel, medicationCode, medicationName, implication
# get PharmGKBID, evidenceLevel, medicationCode, medicationName, implication
PharmGKBID.append("https://www.pharmgkb.org/gene/"+i["resource"]["identifier"][0]["value"])
for l in i["resource"]["component"]:
if l["code"]["coding"][0]["code"] == "93044-6":
evidenceLevel.append(l["valueCodeableConcept"]["text"])
Expand All @@ -100,11 +101,8 @@ def getMedicationList(subject):
elif l["code"]["coding"][0]["code"] == "predicted-therapeutic-implication":
implication.append(l["valueCodeableConcept"]["text"])
elif i["name"] == "genotype":
# get genotype, PharmGKBID
# get genotype
genotype.append(i["resource"]["valueCodeableConcept"]["coding"][0]["code"])
for l in i["resource"]["component"]:
if l["code"]["coding"][0]["code"] == "81252-9":
PharmGKBID.append("https://www.pharmgkb.org/gene/"+l["valueCodeableConcept"]["coding"][0]["code"])

with col2:
inxData = (pd.DataFrame({
Expand All @@ -117,15 +115,16 @@ def getMedicationList(subject):
if count == 0:
st.write('### No PGx data')
else:
gb = GridOptionsBuilder.from_dataframe(inxData)
gb.configure_column("PharmGKB",
cellRenderer=JsCode("""
function (params)
{return "<a target='_blank' href=" + params.value + ">" + params.value + "</a>"}
""").js_code
)
go = gb.build()
AgGrid(inxData, gridOptions=go, allow_unsafe_jscode=True, editable=True, enable_enterprise_modules=True, update_mode="value_changed")
# gb = GridOptionsBuilder.from_dataframe(inxData)
# gb.configure_column("PharmGKB",
# cellRenderer=JsCode("""
# function (params)
# {return "<a target='_blank' href=" + params.value + ">" + params.value + "</a>"}
# """).js_code
# )
# go = gb.build()
# AgGrid(inxData, gridOptions=go, allow_unsafe_jscode=True, editable=True, enable_enterprise_modules=True, update_mode="value_changed")
AgGrid(inxData, allow_unsafe_jscode=True, editable=True, enable_enterprise_modules=True, update_mode="value_changed")
inxData_t = inxData.T
st.download_button("Download table (json)", inxData_t.to_json())
st.download_button("Download table (csv)", inxData.to_csv())
Expand All @@ -137,7 +136,8 @@ def getMedicationList(subject):
for i in getMedicationList(subject):
for j in medicationCode:
if str(j) == str(i["ing"]):
inx = '<a target="_blank" href="https://api.pharmgkb.org/v1/infobutton?mainSearchCriteria.v.c='+str(i["ing"])+'">'+'🧬'+'</a>'
# inx = '<a target="_blank" href="https://api.pharmgkb.org/v1/infobutton?mainSearchCriteria.v.c='+str(i["ing"])+'">'+'🧬'+'</a>'
inx = '🧬'
break
else:
inx = ""
Expand Down
8 changes: 2 additions & 6 deletions genomics-apps/geneticScreening.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
)


@st.cache
@st.cache_data
def findPopulationDxImplications(conditionCode):
url = 'https://fhir-gen-ops.herokuapp.com/population-operations/phenotype-operations/$find-population-dx-implications?conditions='+conditionCode+'&includePatientList=true'
headers = {'Accept': 'application/json'}
r = requests.get(url, headers=headers)
return r.json()


@st.cache
@st.cache_data
def findSubjectDxImplications(subject, conditionCode):
url = 'https://fhir-gen-ops.herokuapp.com/subject-operations/phenotype-operations/$find-subject-dx-implications?subject='+subject+'&conditions='+conditionCode
headers = {'Accept': 'application/json'}
Expand Down Expand Up @@ -120,7 +120,3 @@ def findSubjectDxImplications(subject, conditionCode):
AgGrid(data, enable_enterprise_modules=True, update_mode="value_changed", allow_unsafe_jscode=True)

st.download_button("Download table", data_t.to_json())

AgGrid(data, enable_enterprise_modules=True, update_mode="value_changed", allow_unsafe_jscode=True)

st.download_button("Download table", data_t.to_json())
10 changes: 5 additions & 5 deletions genomics-apps/getMolecularConsequences.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
)


@st.cache
@st.cache_data
def getFeatureCoordinates(gene):
url = 'https://fhir-gen-ops.herokuapp.com/utilities/get-feature-coordinates?gene='+gene
headers = {'Accept': 'application/json'}
return requests.get(url, headers=headers)


@st.cache
@st.cache_data
def findSubjectVariants(subject, range, addAnnotationsFlag):
url = 'https://fhir-gen-ops.herokuapp.com/subject-operations/genotype-operations/$find-subject-variants?subject=' + \
subject+'&ranges='+range+'&includeVariants=true'
Expand All @@ -29,7 +29,7 @@ def findSubjectVariants(subject, range, addAnnotationsFlag):
return requests.get(url, headers=headers)


@st.cache
@st.cache_data
def findSubjectStructuralIntersectingVariants(subject, range, addAnnotationsFlag):
url = 'https://fhir-gen-ops.herokuapp.com/subject-operations/genotype-operations/$find-subject-structural-intersecting-variants?subject=' + \
subject+'&ranges='+range+'&includeVariants=true'
Expand All @@ -39,7 +39,7 @@ def findSubjectStructuralIntersectingVariants(subject, range, addAnnotationsFlag
return requests.get(url, headers=headers)


@st.cache
@st.cache_data
def findSubjectHaplotypes(subject, geneId):
url = 'https://fhir-gen-ops.herokuapp.com/subject-operations/genotype-operations/$find-subject-haplotypes?subject='+subject+'&genes='+geneId
headers = {'Accept': 'application/json'}
Expand All @@ -52,7 +52,7 @@ def _liftOver(chrom, pos):
return {"chrom": chrom, "pos": newPos[0][1]}


@st.cache
@st.cache_data
def findSPDI(SPDI):
url = 'https://api.ncbi.nlm.nih.gov/variation/v0/spdi/' + \
SPDI + '/canonical_representative'
Expand Down
8 changes: 4 additions & 4 deletions genomics-apps/getVariants.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,28 @@
)


@st.cache
@st.cache_data
def getFeatureCoordinates(gene):
url = 'https://fhir-gen-ops.herokuapp.com/utilities/get-feature-coordinates?gene='+gene
headers = {'Accept': 'application/json'}
return requests.get(url, headers=headers)


@st.cache
@st.cache_data
def findSubjectVariants(subject, range):
url = 'https://fhir-gen-ops.herokuapp.com/subject-operations/genotype-operations/$find-subject-variants?subject='+subject+'&ranges='+range+'&includeVariants=true'
headers = {'Accept': 'application/json'}
return requests.get(url, headers=headers)


@st.cache
@st.cache_data
def findSubjectStructuralIntersectingVariants(subject, range):
url = 'https://fhir-gen-ops.herokuapp.com/subject-operations/genotype-operations/$find-subject-structural-intersecting-variants?subject='+subject+'&ranges='+range+'&includeVariants=true'
headers = {'Accept': 'application/json'}
return requests.get(url, headers=headers)


@st.cache
@st.cache_data
def findSubjectHaplotypes(subject, geneId):
url = 'https://fhir-gen-ops.herokuapp.com/subject-operations/genotype-operations/$find-subject-haplotypes?subject='+subject+'&genes='+geneId
headers = {'Accept': 'application/json'}
Expand Down
6 changes: 3 additions & 3 deletions genomics-apps/polygenicScore.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@
:arrow_forward: *population mean* and *standard deviation* are based on Operations reference implementation population.")


@st.cache
@st.cache_data
def findSubjectVariants(subject, range):
url = 'https://fhir-gen-ops.herokuapp.com/subject-operations/genotype-operations/$find-subject-variants?subject='+subject+'&ranges='+range+'&includeVariants=true'
headers = {'Accept': 'application/json'}
return requests.get(url, headers=headers)


@st.cache
@st.cache_data
def findSubjectSpecificVariants(subject, variant):
url = 'https://fhir-gen-ops.herokuapp.com/subject-operations/genotype-operations/$find-subject-specific-variants?subject='+subject+'&variants='+variant+'&includeVariants=true'
# url = 'https://fhir-gen-ops-dev-ca42373833b6.herokuapp.com/subject-operations/genotype-operations/$find-subject-specific-variants?subject='+subject+'&variants='+variant+'&includeVariants=true'
headers = {'Accept': 'application/json'}
return requests.get(url, headers=headers)


@st.cache
@st.cache_data
def getPolygenicScoreMetadata(pgs_id):
url = 'https://www.pgscatalog.org/rest/score/'+pgs_id
headers = {'Accept': 'application/json'}
Expand Down
2 changes: 1 addition & 1 deletion genomics-apps/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pandas==2.0.3
pandas==2.2.2
pyliftover==0.4
requests==2.32.0
streamlit==1.34.0
Expand Down
2 changes: 1 addition & 1 deletion genomics-apps/simpleApp.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
)


@st.cache
@st.cache_data
def findSubjectVariants(subject, range):
url = 'https://fhir-gen-ops.herokuapp.com/subject-operations/genotype-operations/$find-subject-variants?subject='+subject+'&ranges='+range+'&includeVariants=true'
headers = {'Accept': 'application/json'}
Expand Down

0 comments on commit afe9cbb

Please sign in to comment.