= bootstrap_hdrs() + pdbe_molstar() hdrs
Protein display
Setup
AF_display
AF_display ()
client side scripts
pdbe_molstar
pdbe_molstar ()
Headers
*hdrs) show(
from ngrok_token import *
= start_ngrok(token) url
ngrok tunnel opened at: https://9771-3-91-16-70.ngrok-free.app
= fast_app(pico=False,hdrs=hdrs)
app,rt = JupyUvi(app) server
Check output format
= pd.read_parquet('data/AM.parquet') df
@rt
def test():
= Form(Input(id='uniprot_id'),Button('load'),hx_get='/sdf',target_id='result')
form = Div(id='result')
result return Div(form, result)
@rt
def sdf(uniprot_id:str):
= df[df['uniprot'] == uniprot_id].copy()
protein_data
if protein_data.empty:
return Div('Uniprot id not found in the phosphosite database')
'residue'] = protein_data.site.str[1:].astype(int)
protein_data['CDDM_kinases'] = protein_data['CDDM'].str.split(',').str[:5]
protein_data['PSPA_kinases'] = protein_data['PSPA'].str.split(',').str[:5]
protein_data['AM_pathogenicity'] = protein_data['AM_pathogenicity'].round(4)
protein_data[
# Convert the filtered data to a list of dictionaries
# It needs to include residue, as it uses residue number to highlight
= protein_data[['residue', 'AM_pathogenicity','site_seq','source','CDDM_kinases','PSPA_kinases']]
out
return Container(df2html(out))
'/sdf?uniprot_id=P10398') htmx(url,
Protein Display
P10398 P35222
Key listeners:
- uniprot_id: input text
- load-protein-btn: click to load new protein
- myViewer: display protein
- AF_view: control alphafold color on or off
@rt('/')
def get():
= Form(
form type='text', id = 'uniprot_id', placeholder='Enter Uniprot ID (e.g., P10398)'),
Input('Load Protein', type='button',id='load-protein-btn'),
Button(id='protein-form',
)= Div(id='myViewer')
viewer # script = Script(src="./imports/alphafold_display.js")
= Button('Turn On/Off Alphafold Color', type='button',id='AF_view'),
AF_button =Div(style='height: 600px;')
blank
return Titled('PDBe Mol* JS Plugin Demo - AlphaFold View', form, AF_button, viewer, AF_script, blank)
@rt('/api/protein/{uniprot_id}')
def get(uniprot_id: str):
# Filter the dataframe for the given UniProt ID
= df[df['uniprot'] == uniprot_id].copy()
protein_data
if protein_data.empty:
return {'error': 'Uniprot id not found in the phosphosite database'}
'residue'] = protein_data.site.str[1:].astype(int)
protein_data['CDDM_kinases'] = protein_data['CDDM'].str.split(',').str[:5]
protein_data['PSPA_kinases'] = protein_data['PSPA'].str.split(',').str[:5]
protein_data['AM_pathogenicity'] = protein_data['AM_pathogenicity'].round(4)
protein_data[
# Convert the filtered data to a list of dictionaries
# It needs to include residue, as it uses residue number to highlight
= protein_data[['residue', 'AM_pathogenicity','site_seq','source','CDDM_kinases','PSPA_kinases']].to_dict('records')
site_data
return {'site_data': site_data}
'/') htmx(url,
End
server.stop() kill_ngrok()
ngrok tunnel killed