@@ -67,6 +67,7 @@ def convert_df(df):
67
67
input = st .selectbox (
68
68
"How would you like to enter your input?" ,
69
69
["Upload a CSV file" , "Draw a molecule" , "Enter SMILES" , "Upload an SDF file" ],
70
+ key = "input" ,
70
71
)
71
72
72
73
multismiles = False
@@ -82,7 +83,7 @@ def convert_df(df):
82
83
smiles_column_name = "SMILES"
83
84
smiles_column = queried_df [smiles_column_name ]
84
85
elif input == "Enter SMILES" :
85
- smiles = st .text_input ("Enter a SMILES string" )
86
+ smiles = st .text_input ("Enter a SMILES string" , key = "smiles_user_input" )
86
87
if _is_valid_smiles (smiles ):
87
88
st .success ("Valid SMILES string" , icon = "✅" )
88
89
else :
@@ -95,7 +96,7 @@ def convert_df(df):
95
96
elif input == "Upload a CSV file" :
96
97
# Create a file uploader for CSV files
97
98
uploaded_file = st .file_uploader (
98
- "Choose a CSV file to upload your predictions to" , type = "csv"
99
+ "Choose a CSV file to upload your predictions to" , type = "csv" , key = "csv_file"
99
100
)
100
101
101
102
# If a file is uploaded, parse it into a DataFrame
@@ -104,7 +105,7 @@ def convert_df(df):
104
105
else :
105
106
st .stop ()
106
107
# Select a column from the DataFrame
107
- smiles_column_name = st .selectbox ("Select a SMILES column" , queried_df .columns )
108
+ smiles_column_name = st .selectbox ("Select a SMILES column" , queried_df .columns , key = "df_smiles_column" )
108
109
multismiles = True
109
110
smiles_column = queried_df [smiles_column_name ]
110
111
@@ -128,15 +129,18 @@ def convert_df(df):
128
129
# read with rdkit
129
130
if uploaded_file is not None :
130
131
# To convert to a string based IO:
131
- stringio = StringIO (uploaded_file .getvalue ().decode ("utf-8" ))
132
- # To read file as string:
133
- string_data = stringio .read ()
134
- mols = sdf_str_to_rdkit_mol (string_data )
135
- smiles = [Chem .MolToSmiles (m ) for m in mols ]
136
- queried_df = pd .DataFrame (smiles , columns = ["SMILES" ])
137
- # st.error("Error reading the SDF file, please check the input", icon="🚨")
138
- # st.stop()
132
+ try :
133
+ stringio = StringIO (uploaded_file .getvalue ().decode ("utf-8" ))
134
+ # To read file as string:
135
+ string_data = stringio .read ()
136
+ mols = sdf_str_to_rdkit_mol (string_data )
137
+ smiles = [Chem .MolToSmiles (m ) for m in mols ]
138
+ queried_df = pd .DataFrame (smiles , columns = ["SMILES" ])
139
+ except :
140
+ st .error ("Error reading the SDF file, please check the input" , icon = "🚨" )
141
+ st .stop ()
139
142
else :
143
+ st .error ("No file uploaded" , icon = "🚨" )
140
144
st .stop ()
141
145
142
146
st .success (
@@ -154,11 +158,11 @@ def convert_df(df):
154
158
# filter out None values
155
159
targets = [t for t in targets if t is not None ]
156
160
# Select a target value from the preset list
157
- target_value = st .selectbox ("Select a biological target " , targets )
161
+ target_value = st .selectbox ("Select a biological target " , targets , key = "target" )
158
162
# endpoints
159
163
endpoints = ASAPMLModelRegistry .get_endpoints ()
160
164
# Select a target value from the preset list
161
- endpoint_value = st .selectbox ("Select a property " , endpoints )
165
+ endpoint_value = st .selectbox ("Select a property " , endpoints , key = "endpoint" )
162
166
163
167
if not ASAPMLModelRegistry .endpoint_has_target (endpoint_value ):
164
168
_target = None
0 commit comments