New component: Streamlit-Molstar for visualisation and analysis of large-scale molecular data

Hi everyone, as part of a series of shared components, I will share a new component that we integrated Molstar (A modern web-based open-source toolkit for visualisation and analysis of large-scale molecular data.) into Streamlit in a real project a year ago. It can basically meet the visualization needs of proteins, molecules, and other scenarios, making it perfect for building some small research tools in the field of biological sciences. The project address:

Install

pip install streamlit-molstar

Basic Usage

Show Molecule

Protein with Traj

    import streamlit as st
    from streamlit_molstar import st_molstar, st_molstar_rcsb, st_molstar_remote

    #st_molstar_rcsb('1LOL', key='xx')
    #st_molstar_remote("https://files.rcsb.org/view/1LOL.cif", key='sds')
    #st_molstar('examples/complex.pdb',key='3')
    st_molstar('examples/complex.pdb', 'examples/complex.xtc', key='4')

Protein & Pocket

Select pocket from local protein (pockets predicted using p2rank)

    import streamlit as st
    from streamlit_molstar.pocket import select_pocket_from_local_protein

    selected = select_pocket_from_local_protein("examples/pocket/protein.pdb", prank_home='/Users/wfluo/Downloads/p2rank_2.4/')
    if selected:
        protein_file_path, pocket = selected
        st.write('Protein Path: ', protein_file_path)
        st.write('Selected Pocket: ', pocket)

Select pocket from uploaded protein (pockets predicted using p2rank)

    import streamlit as st
    from streamlit_molstar import st_molstar, st_molstar_rcsb, st_molstar_remote

    selected = select_pocket_from_upload_protein(prank_home='/Users/wfluo/Downloads/p2rank_2.4/')
    if selected:
        protein_file_path, pocket = selected
        st.write('Protein Path: ', protein_file_path)
        st.write('Selected Pocket: ', pocket)

Docking

Show docking result with ground truth

    import streamlit as st
    from streamlit_molstar.docking import st_molstar_docking

    st_molstar_docking('examples/docking/2zy1_protein.pdb', 
                       'examples/docking/docking.2zy1.0.sdf',  
    gt_ligand_file_path='examples/docking/2zy1_ligand.sdf', key="5", height=240)

Auto files

    import streamlit as st
    from streamlit_molstar.auto import st_molstar_auto

    import streamlit as st

    st.set_page_config(layout="wide")

    st.write("from remote url")
    files = ["https://files.rcsb.org/download/3PTB.pdb", "https://files.rcsb.org/download/1LOL.pdb"]
    st_molstar_auto(files, key="6", height="320px")

    st.write("from local file")
    files = ['examples/7bcq.pdb', "examples/7bcq.mrc"]

    st_molstar_auto(files, key="7", height="320px")

In addition, stmol is also a very nice solution for addressing molecular rendering issues, but the two projects integrate different visualization engines, with Streamlit-Molstar providing more complex features for real-life scenarios.

7 Likes

Nice work! Looks pretty useful :nerd_face:

3 Likes

Amazing work @mapix_i , big kudos on the creation of this component!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.