avrabyt / st-speckmol Goto Github PK
View Code? Open in Web Editor NEW🧬Streamlit Component for creating Speck molecular structures within Streamlit Web app🚀.
Home Page: https://hellostspeckmol.streamlitapp.com
License: MIT License
🧬Streamlit Component for creating Speck molecular structures within Streamlit Web app🚀.
Home Page: https://hellostspeckmol.streamlitapp.com
License: MIT License
ModuleNotFoundError: No module named 'ipython_genutils'
spec_plot
and add_spec_param
speck_plot
and add_speck_param
__version__
function ➡️ for version checkedv0.0.5.1
had all functions in utils.py
, ➡️ now moved to __initi__.py
.pdb
(/other formats) to xyz coordinates
However, error (check details reported here ) pops up which does not allow to deploy it as an app yet .
https://github.com/avrabyt/Specklit/blob/8e13a969504dafede80f5672af92eba8a2dbe1b9/app.py
import streamlit as st
import ipywidgets as widgets
from ipywidgets import embed
import ipyspeck
import streamlit.components.v1 as components
import glob
st.set_page_config(
layout="centered",
page_title="Specklit",
page_icon=":sparkles:")
def add_spec_param(spec_xyz,atom_Scale,bond_Scale,outline,atomShade,bonds,bondThreshold):
#Modify atoms size
spec_xyz.atomScale = atom_Scale
#change bonds size
spec_xyz.bondScale = bond_Scale
#highlight borders
spec_xyz.outline = outline
spec_xyz.atomShade = atomShade
spec_xyz.bonds = bonds
spec_xyz.bondThreshold = bondThreshold
return spec_xyz
def spec_plot(_xyz):
spec_xyz = ipyspeck.speck.Speck(data=_xyz, title='')
spec_xyz = add_spec_param(spec_xyz,atom_Scale,bond_Scale,outline,atom_Shade,bonds,bondThreshold)
spec_xyz.setColorSchema(schema='newcpk')
c = widgets.Box([spec_xyz], layout=widgets.Layout(width="800px",height="700px"))
snippet = embed.embed_snippet(c)
html = embed.html_template.format(title="", snippet=snippet)
components.html(html,height = 1000, width = 900)
return spec_xyz
ex_files = glob.glob("examples/*.xyz")
st.sidebar.title(" XYZ to SPECK-Structures :tada:")
with st.sidebar.expander(label = "Examples",expanded=True):
st.markdown("[Source](https://github.com/wwwtyro/speck/tree/gh-pages/static/samples)")
example_xyz = st.selectbox("Select a molecule",ex_files)
f = open(example_xyz,"r")
example_xyz = f.read()
st.sidebar.markdown("# Parameter section:")
st.sidebar.info("You can also add your own coordinates below. :coffee:")
_xyz = st.sidebar.text_area(
label = "What are the Coordinates ?",
value= example_xyz, height = 200)
st.code(_xyz.splitlines()[1])
atom_Scale = st.sidebar.slider('Atom Scale', 0.1, 1.0, 0.35)
bond_Scale = st.sidebar.slider('Bond Scale', 0.1, 1.0, 0.5)
atom_Shade = st.sidebar.slider('Atom Shade', 0.1, 1.0, 0.0)
bondThreshold = st.sidebar.slider('Bond Threshold', 0.1, 5.0, 1.2)
bonds = st.sidebar.checkbox("Bonds",value = True)
outline = st.sidebar.checkbox('Outline',value = True)
res = spec_plot(_xyz)
with st.expander("References:",expanded=True):
st.markdown("[Speck Online](http://wwwtyro.github.io/speck/)")
st.markdown("[Speck Python package](https://pypi.org/project/ipyspeck/)")
Always goof to convert into a component for easy-usage.
_PARAMETERS
within the spec_plot
function allows to add parameters such as outline, bonds, brightness
etc . Mainly a helper function add_spec_param(xyz, **kwargs)
is called within the spec_plot
functionadd_spec_param(xyz, **kwargs)
♻️ needs to be rewritten laterWhile deploying Streamlit app, with the package, throws error (check details reported here ). The error pops up which does not allow to deploy it as an app yet .
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.