Spaces:
Sleeping
Sleeping
File size: 6,502 Bytes
7c5ab20 7cfe591 451f080 7c5ab20 13d53f6 36bc071 ab15dde 13d53f6 7c5ab20 6338588 13d53f6 6338588 ec2e39f 6338588 7c5ab20 37ed0f0 654e610 37ed0f0 e76478e 70d85fd 5816504 7e89c47 75c5e64 2eb40bb 838a6e2 2eb40bb ab15dde 2eb40bb 6338588 ab15dde 6338588 2eb40bb 13d53f6 7c5ab20 2eb40bb e76478e 4d392c6 7c5ab20 13d53f6 7c5ab20 4d392c6 7c5ab20 13d53f6 7c5ab20 c6df981 7c5ab20 1275613 c5045c9 bbfebe9 d332a9f c5045c9 9fa9452 6338588 ec2e39f 6338588 a3b045d ec2e39f 755228d ec2e39f 965b05a 6338588 9fa9452 5cb3b63 9fa9452 bf1d1e2 |
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 |
import datasets
import streamlit as st
from st_aggrid import AgGrid, GridOptionsBuilder, JsCode
st.set_page_config(layout='wide')
# parse out gene_ids from URL query args to it's possible to link to this page
query_params = st.query_params
if "gene_id" in query_params.keys():
gene_id = query_params["gene_id"]
else:
gene_id = "B9J08_001120"
st.markdown("""
# Druggable Candida auris Genome
**DrAG** is a database of candidate compounds for targeting Candida auris, the emerging fungal pathogen
For each C. auris gene we have a number of compound linked in ChEMBL and IUPHAR.
* Full network and dataset: https://huggingface.co/datasets/julietanku/DrAG
## Look up compounds for a C.auris gene:
Put in the ``B9J08_######`` gene_id for a gene and expand the table to get the predicted compounds""")
DrAG_hits_ChEMBL = datasets.load_dataset(
path = "julietanku/DrAG",
data_files = {"DrAG_hits_ChEMBL": "cau_targets_to_chembl_cpds_20240131.parquet"})
DrAG_hits_ChEMBL = DrAG_hits_ChEMBL["DrAG_hits_ChEMBL"].to_pandas()
DrAG_hits_IUPHAR = datasets.load_dataset(
path = "julietanku/DrAG",
data_files = {"DrAG_hits_IUPHAR": "Cau_vs_IUPHAR_cpds_imp.parquet"})
DrAG_hits_IUPHAR = DrAG_hits_IUPHAR["DrAG_hits_IUPHAR"].to_pandas()
col1, col2, col3 = st.columns(spec = [0.3, 0.2, 0.5])
with col1:
gene_ids= st.text_area(
label = "Gene IDs",
value = f"{gene_id}",
max_chars = None,
height = None,
help = "B9J08 Gene ID e.g. B9J08_004214, B9J08_001120")
gene_ids= gene_ids.split("\n")
gene_ids=[gene_id.strip() for gene_id in gene_ids] ### Striping the blank space/character in the query box before searching###
###radio buttons###
with col2:
database_name=st.radio(
label='select the database to search',
options=['ChEMBL','IUPHAR'],
captions=['ChEMBL drug list','IUPHAR drug list'] )
if database_name=="ChEMBL":
DrAG_hits = DrAG_hits_ChEMBL[DrAG_hits_ChEMBL['feature_name'].isin(gene_ids)]
elif database_name=="IUPHAR":
DrAG_hits = DrAG_hits_IUPHAR[DrAG_hits_IUPHAR['feature_name_1.y'].isin(gene_ids)]
else:
raise Exception('Database was not recognised')
DrAG_hits.reset_index()
with col3:
st.text('') # help alignment with input box
st.download_button(
label = "Download data as TSV",
data = DrAG_hits.to_csv(sep ='\t').encode('utf-8'),
file_name = f"DrAG_hits_{gene_id}.tsv",
mime = "text/csv")
# third column is padding only
######### Table #########
CGD_link_renderer = JsCode("""
class UrlCellRenderer {
init(params) {
this.eGui = document.createElement('a');
this.eGui.innerText = params.value;
this.eGui.setAttribute('href', "http://candidagenome.org/cgi-bin/locus.pl?locus="+params.value);
this.eGui.setAttribute('style', "text-decoration:none");
this.eGui.setAttribute('target', "_blank");
}
getGui() {
return this.eGui;
}
}
""")
ChEMBL_link_renderer = JsCode("""
class UrlCellRenderer {
init(params) {
this.eGui = document.createElement('a');
this.eGui.innerText = params.value;
this.eGui.setAttribute('href', "http://ebi.ac.uk/chembl/compound_report_card/"+params.value);
this.eGui.setAttribute('style', "text-decoration:none");
this.eGui.setAttribute('target', "_blank");
}
getGui() {
return this.eGui;
}
}
""")
IUPHAR_link_renderer = JsCode("""
class UrlCellRenderer {
init(params) {
this.eGui = document.createElement('a');
this.eGui.innerText = params.value;
this.eGui.setAttribute('href', "https://www.guidetopharmacology.org/GRAC/LigandDisplayForward?ligandId="+params.value);
this.eGui.setAttribute('style', "text-decoration:none");
this.eGui.setAttribute('target', "_blank");
}
getGui() {
return this.eGui;
}
}
""")
if database_name=="ChEMBL":
grid_option_builder = GridOptionsBuilder()
grid_option_builder.configure_auto_height()
grid_option_builder.configure_default_column(
filterable=False,
groupable=False,
editable=False,
wrapText=True,
autoHeight=True)
grid_option_builder.configure_column("feature_name", header_name="feature_name", pinned="left", cellRenderer=CGD_link_renderer, width=550)
grid_option_builder.configure_column("sac_ortholog", header_name="sac_ortholog", pinned="left", width=500)
grid_option_builder.configure_column("description", header_name="description", width=1650)
grid_option_builder.configure_column("uniprot_accn", header_name="uniprot_accn", width=500)
grid_option_builder.configure_column("EValue", header_name="EValue", pinned="left", width=500)
grid_option_builder.configure_column("chembl_id", header_name="chembl_id", pinned="left", cellRenderer=ChEMBL_link_renderer, width=550)
grid_option_builder.configure_selection(selection_mode=False, use_checkbox=False)
elif database_name=="IUPHAR":
grid_option_builder = GridOptionsBuilder()
grid_option_builder.configure_auto_height()
grid_option_builder.configure_default_column(
filterable=False,
groupable=False,
editable=False,
wrapText=True,
autoHeight=True)
grid_option_builder.configure_column("feature_name", header_name="feature_name_1.y", pinned="left", cellRenderer=CGD_link_renderer, width=550)
grid_option_builder.configure_column("Ligand", header_name="Compound", pinned="left", width=500)
grid_option_builder.configure_column("Ligand ID", header_name="Compound ID", cellRenderer=IUPHAR_link_renderer, width=550)
grid_option_builder.configure_column("Target UniProt ID", header_name="uniprot_accn", width=500)
grid_option_builder.configure_column("EValue.y", header_name="EValue", pinned="left", width=500)
grid_option_builder.configure_column("SMILES", header_name="Compound SMILES", pinned="left", width=1650)
grid_option_builder.configure_selection(selection_mode=False, use_checkbox=False)
else:
raise Exception('Database was not recognised')
AgGrid(
data = DrAG_hits,
gridOptions = grid_option_builder.build(),
fit_columns_on_grid_load=True,
theme="streamlit",
allow_unsafe_jscode=True)
|