-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
38 lines (30 loc) · 1.26 KB
/
app.py
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
import streamlit as st
import pandas as pd
from rdkit import Chem
from rdkit.Chem import PandasTools
def load_data(uploaded_file):
# Cargar datos sin agregar una columna de índice adicional
df = pd.read_csv(uploaded_file)
return df
def display_molecules(df):
df['mol'] = df['SMILES'].apply(lambda x: Chem.MolFromSmiles(x))
# Asegurarse de usar el índice del DataFrame como parte de la leyenda
df['legend'] = df.index.astype(str) + ": " + df['SMILES']
if 'Docking Scores' in df.columns:
df['legend'] += "\nDocking Score: " + df['Docking Scores'].astype(str)
img = PandasTools.FrameToGridImage(df, column='mol', legendsCol='legend', molsPerRow=3, subImgSize=(300, 300))
return img
def main():
st.title('Visualizador de Moléculas')
uploaded_file = st.file_uploader("Cargue su archivo CSV", type=['csv'])
if uploaded_file is not None:
data = load_data(uploaded_file)
if 'SMILES' in data.columns:
# Se muestra el DataFrame sin el índice reseteado para evitar duplicaciones
st.dataframe(data)
img = display_molecules(data)
st.image(img)
else:
st.error("El archivo CSV debe contener una columna 'SMILES'.")
if __name__ == "__main__":
main()