saicharan2804 commited on
Commit
9b06241
1 Parent(s): 068a1bb

adding scscore

Browse files
Files changed (3) hide show
  1. app.py +44 -17
  2. molgenevalmetric.py +17 -1
  3. scscore1 → scscore +0 -0
app.py CHANGED
@@ -1,17 +1,44 @@
1
- import evaluate
2
- from evaluate.utils import launch_gradio_widget
3
- import gradio as gr
4
-
5
- module = evaluate.load("saicharan2804/molgenevalmetric")
6
- # launch_gradio_widget(module)
7
-
8
- iface = gr.Interface(
9
- fn = module,
10
- inputs=[
11
- gr.File(label="Generated SMILES"),
12
- gr.File(label="Training Data", value=None),
13
- ],
14
- outputs="text"
15
- )
16
-
17
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # import evaluate
2
+ # from evaluate.utils import launch_gradio_widget
3
+ # import gradio as gr
4
+
5
+ # module = evaluate.load("saicharan2804/molgenevalmetric")
6
+ # # launch_gradio_widget(module)
7
+
8
+ # iface = gr.Interface(
9
+ # fn = module,
10
+ # inputs=[
11
+ # gr.File(label="Generated SMILES"),
12
+ # gr.File(label="Training Data", value=None),
13
+ # ],
14
+ # outputs="text"
15
+ # )
16
+
17
+ # iface.launch()
18
+
19
+ # import pandas as pd
20
+
21
+ # df = pd.read_csv('/home/saicharan/Downloads/chembl.csv')
22
+
23
+ # df = df.rename(columns={'canonical_smiles': 'SMILES'})
24
+
25
+ # df = df[0:10000]
26
+
27
+ # print(df[['SMILES']].to_csv('/home/saicharan/Downloads/chembl_10000.csv'))
28
+ from scscore.scscore.standalone_model_numpy import SCScorer
29
+
30
+ import pandas as pd
31
+
32
+ model = SCScorer()
33
+ model.restore()
34
+
35
+ pubchem = pd.read_csv('/home/saicharan/Downloads/chembl_10000.csv')
36
+
37
+ # smis = ['CCCOCCC', 'CCCNc1ccccc1']
38
+ smis = pubchem['SMILES'].tolist()
39
+ smis = smis[0:1000]
40
+ print('computing')
41
+ average_score = model.get_avg_score(smis)
42
+
43
+ # Print the average score
44
+ print('Average score:', average_score)
molgenevalmetric.py CHANGED
@@ -38,6 +38,7 @@ import pandas as pd
38
  from fcd_torch import FCD
39
  # from syba.syba import SybaClassifier
40
 
 
41
 
42
 
43
  def get_mol(smiles_or_mol):
@@ -195,6 +196,21 @@ def novelty(gen, train, n_jobs=1):
195
  # return None
196
 
197
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
 
199
  def average_agg_tanimoto(stock_vecs, gen_vecs,
200
  batch_size=5000, agg='max',
@@ -509,7 +525,7 @@ class molgenevalmetric(evaluate.Metric):
509
  # metrics['Oracles'] = oracles(gen = gensmi, train = trainsmi)
510
 
511
  # metrics['SA'] = SAscore(gen=gensmi)
512
- # metrics['SCS'] = SAscore(gen=trainsmi)
513
 
514
  return metrics
515
 
 
38
  from fcd_torch import FCD
39
  # from syba.syba import SybaClassifier
40
 
41
+ from scscore.scscore.standalone_model_numpy import SCScorer
42
 
43
 
44
  def get_mol(smiles_or_mol):
 
196
  # return None
197
 
198
 
199
+ def SCScore(gen):
200
+ """
201
+ Calculate the average Synthetic Complexity Score (SCScore) for a list of molecules represented by their SMILES strings.
202
+
203
+ Parameters:
204
+ - gen (list of str): A list containing the SMILES representations of the molecules.
205
+
206
+ Returns:
207
+ - float: The average Synthetic Accessibility Score for the valid molecules in the list. Returns None if no valid molecules are found.
208
+ """
209
+
210
+ model = SCScore()
211
+ average_score = model.get_avg_score(gen)
212
+ return average_score
213
+
214
 
215
  def average_agg_tanimoto(stock_vecs, gen_vecs,
216
  batch_size=5000, agg='max',
 
525
  # metrics['Oracles'] = oracles(gen = gensmi, train = trainsmi)
526
 
527
  # metrics['SA'] = SAscore(gen=gensmi)
528
+ metrics['SCS'] = SCScore(gen=gensmi)
529
 
530
  return metrics
531
 
scscore1 → scscore RENAMED
File without changes