Mercurial > repos > bgruening > sucos_docking_scoring
annotate sucos_max.py @ 2:c6a0e987f8ea draft
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit 8542cbcae3ebed4cb9a6c20b1fabd418a6efb7e8"
author | bgruening |
---|---|
date | Sat, 28 Mar 2020 09:32:01 +0000 |
parents | 53fb0e116e99 |
children | 4e75edcf9513 |
rev | line source |
---|---|
0
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
1 #!/usr/bin/env python |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
2 """ |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
3 Assess ligands against a second set of molecules using SuCOS scores. |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
4 This is a quite specialised function that is designed to take a set of potential follow up |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
5 compounds and compare them to a set of clustered fragment hits to help identify which follow up |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
6 ligands best map to the binding space of the hits. |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
7 |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
8 The clustering of the fragment hits is expected to be performed with the sucos_cluster.py module |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
9 and will generate a set of SD files, one for each cluster of hits (presumably corresponding to a |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
10 binding pocket in the protein target). |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
11 |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
12 Each molecule in the input ligands is then compared (using SuCOS) to each hit in the clusters. There |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
13 are different modes which determine how the ligand is assessed. |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
14 |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
15 In mode 'max' the hit with the best SuCOS score is identified. The output is a SD file with each of the ligands, |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
16 with these additional fields for each molecule: |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
17 Max_SuCOS_Score - the best score |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
18 Max_SuCOS_FeatureMap_Score - the feature map score for the hit that has the best SuCOS score |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
19 Max_SuCOS_Protrude_Score - the protrude volume for the hit that has the best SuCOS score |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
20 Max_SuCOS_Cluster - the name of the cluster SD file that contains the best hit |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
21 Max_SuCOS_Index - the index of the best hit in the SD file |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
22 |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
23 In mode 'cum' the sum of all the scores is calculated and reported as the following properties for each molecule: |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
24 Cum_SuCOS_Score property: the sum of the SuCOS scores |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
25 Cum_SuCOS_FeatureMap_Score: the sum of the feature map scores |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
26 Cum_SuCOS_Protrude_Score: the sum of the protrude volume scores |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
27 |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
28 If a molecule has no alignment to any of the clustered hits (all alignment scores of zero) then it is not |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
29 included in the results. |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
30 |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
31 |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
32 SuCOS is the work of Susan Leung. |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
33 GitHub: https://github.com/susanhleung/SuCOS |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
34 Publication: https://doi.org/10.26434/chemrxiv.8100203.v1 |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
35 """ |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
36 |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
37 import sucos, utils |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
38 import argparse, gzip, os |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
39 from rdkit import Chem |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
40 |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
41 |
1
53fb0e116e99
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit 6f1ee2812cca091561a2b2e464498dae2f913b8d"
bgruening
parents:
0
diff
changeset
|
42 def process(inputfilename, clusterfilenames, outputfilename): |
0
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
43 all_clusters = {} |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
44 for filename in clusterfilenames: |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
45 cluster = [] |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
46 cluster_file = utils.open_file_for_reading(filename) |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
47 suppl = Chem.ForwardSDMolSupplier(cluster_file) |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
48 i = 0 |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
49 for mol in suppl: |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
50 i += 1 |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
51 if not mol: |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
52 utils.log("WARNING: failed to generate molecule", i, "in cluster", filename) |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
53 continue |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
54 try: |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
55 features = sucos.getRawFeatures(mol) |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
56 cluster.append((mol, features)) |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
57 except: |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
58 utils.log("WARNING: failed to generate features for molecule", i, "in cluster", filename) |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
59 |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
60 cluster_file.close() |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
61 all_clusters[filename] = cluster |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
62 |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
63 input_file = utils.open_file_for_reading(inputfilename) |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
64 suppl = Chem.ForwardSDMolSupplier(input_file) |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
65 output_file = utils.open_file_for_writing(outputfilename) |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
66 writer = Chem.SDWriter(output_file) |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
67 |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
68 comparisons = 0 |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
69 mol_num = 0 |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
70 |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
71 for mol in suppl: |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
72 mol_num += 1 |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
73 if not mol: |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
74 utils.log("WARNING: failed to generate molecule", mol_num, "in input") |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
75 continue |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
76 try: |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
77 query_features = sucos.getRawFeatures(mol) |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
78 except: |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
79 utils.log("WARNING: failed to generate features for molecule", mol_num, "in input") |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
80 continue |
1
53fb0e116e99
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit 6f1ee2812cca091561a2b2e464498dae2f913b8d"
bgruening
parents:
0
diff
changeset
|
81 scores_max = [0, 0, 0] |
53fb0e116e99
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit 6f1ee2812cca091561a2b2e464498dae2f913b8d"
bgruening
parents:
0
diff
changeset
|
82 scores_cum = [0, 0, 0] |
0
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
83 for clusterfilename in all_clusters: |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
84 cluster = all_clusters[clusterfilename] |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
85 index = 0 |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
86 for entry in cluster: |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
87 hit = entry[0] |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
88 ref_features = entry[1] |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
89 index += 1 |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
90 comparisons += 1 |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
91 sucos_score, fm_score, vol_score = sucos.get_SucosScore(hit, mol, |
1
53fb0e116e99
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit 6f1ee2812cca091561a2b2e464498dae2f913b8d"
bgruening
parents:
0
diff
changeset
|
92 tani=False, ref_features=ref_features, |
53fb0e116e99
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit 6f1ee2812cca091561a2b2e464498dae2f913b8d"
bgruening
parents:
0
diff
changeset
|
93 query_features=query_features) |
53fb0e116e99
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit 6f1ee2812cca091561a2b2e464498dae2f913b8d"
bgruening
parents:
0
diff
changeset
|
94 |
53fb0e116e99
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit 6f1ee2812cca091561a2b2e464498dae2f913b8d"
bgruening
parents:
0
diff
changeset
|
95 if sucos_score > scores_max[0]: |
53fb0e116e99
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit 6f1ee2812cca091561a2b2e464498dae2f913b8d"
bgruening
parents:
0
diff
changeset
|
96 scores_max[0] = sucos_score |
53fb0e116e99
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit 6f1ee2812cca091561a2b2e464498dae2f913b8d"
bgruening
parents:
0
diff
changeset
|
97 scores_max[1] = fm_score |
53fb0e116e99
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit 6f1ee2812cca091561a2b2e464498dae2f913b8d"
bgruening
parents:
0
diff
changeset
|
98 scores_max[2] = vol_score |
53fb0e116e99
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit 6f1ee2812cca091561a2b2e464498dae2f913b8d"
bgruening
parents:
0
diff
changeset
|
99 cluster_name = clusterfilename |
53fb0e116e99
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit 6f1ee2812cca091561a2b2e464498dae2f913b8d"
bgruening
parents:
0
diff
changeset
|
100 cluster_index = index |
53fb0e116e99
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit 6f1ee2812cca091561a2b2e464498dae2f913b8d"
bgruening
parents:
0
diff
changeset
|
101 |
53fb0e116e99
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit 6f1ee2812cca091561a2b2e464498dae2f913b8d"
bgruening
parents:
0
diff
changeset
|
102 scores_cum[0] += sucos_score |
53fb0e116e99
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit 6f1ee2812cca091561a2b2e464498dae2f913b8d"
bgruening
parents:
0
diff
changeset
|
103 scores_cum[1] += fm_score |
53fb0e116e99
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit 6f1ee2812cca091561a2b2e464498dae2f913b8d"
bgruening
parents:
0
diff
changeset
|
104 scores_cum[2] += vol_score |
0
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
105 |
2
c6a0e987f8ea
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit 8542cbcae3ebed4cb9a6c20b1fabd418a6efb7e8"
bgruening
parents:
1
diff
changeset
|
106 |
c6a0e987f8ea
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit 8542cbcae3ebed4cb9a6c20b1fabd418a6efb7e8"
bgruening
parents:
1
diff
changeset
|
107 cluster_file_name_only = cluster_name.split(os.sep)[-1] |
0
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
108 |
2
c6a0e987f8ea
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit 8542cbcae3ebed4cb9a6c20b1fabd418a6efb7e8"
bgruening
parents:
1
diff
changeset
|
109 # utils.log("Max SuCOS:", scores[0], "FM:", scores[1], "P:", scores[2],"File:", cluster_file_name_only, "Index:", cluster_index) |
c6a0e987f8ea
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit 8542cbcae3ebed4cb9a6c20b1fabd418a6efb7e8"
bgruening
parents:
1
diff
changeset
|
110 mol.SetDoubleProp("Max_SuCOS_Score", scores_max[0] if scores_max[0] > 0 else 0) |
c6a0e987f8ea
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit 8542cbcae3ebed4cb9a6c20b1fabd418a6efb7e8"
bgruening
parents:
1
diff
changeset
|
111 mol.SetDoubleProp("Max_SuCOS_FeatureMap_Score", scores_max[1] if scores_max[1] > 0 else 0) |
c6a0e987f8ea
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit 8542cbcae3ebed4cb9a6c20b1fabd418a6efb7e8"
bgruening
parents:
1
diff
changeset
|
112 mol.SetDoubleProp("Max_SuCOS_Protrude_Score", scores_max[2] if scores_max[2] > 0 else 0) |
c6a0e987f8ea
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit 8542cbcae3ebed4cb9a6c20b1fabd418a6efb7e8"
bgruening
parents:
1
diff
changeset
|
113 mol.SetProp("Max_SuCOS_Cluster", cluster_file_name_only) |
c6a0e987f8ea
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit 8542cbcae3ebed4cb9a6c20b1fabd418a6efb7e8"
bgruening
parents:
1
diff
changeset
|
114 mol.SetIntProp("Max_SuCOS_Index", cluster_index) |
c6a0e987f8ea
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit 8542cbcae3ebed4cb9a6c20b1fabd418a6efb7e8"
bgruening
parents:
1
diff
changeset
|
115 |
c6a0e987f8ea
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit 8542cbcae3ebed4cb9a6c20b1fabd418a6efb7e8"
bgruening
parents:
1
diff
changeset
|
116 # utils.log("Cum SuCOS:", scores[0], "FM:", scores[1], "P:", scores[2]) |
c6a0e987f8ea
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit 8542cbcae3ebed4cb9a6c20b1fabd418a6efb7e8"
bgruening
parents:
1
diff
changeset
|
117 mol.SetDoubleProp("Cum_SuCOS_Score", scores_cum[0] if scores_cum[0] > 0 else 0) |
c6a0e987f8ea
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit 8542cbcae3ebed4cb9a6c20b1fabd418a6efb7e8"
bgruening
parents:
1
diff
changeset
|
118 mol.SetDoubleProp("Cum_SuCOS_FeatureMap_Score", scores_cum[1] if scores_cum[1] > 0 else 0) |
c6a0e987f8ea
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit 8542cbcae3ebed4cb9a6c20b1fabd418a6efb7e8"
bgruening
parents:
1
diff
changeset
|
119 mol.SetDoubleProp("Cum_SuCOS_Protrude_Score", scores_cum[2] if scores_cum[2] > 0 else 0) |
0
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
120 |
1
53fb0e116e99
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit 6f1ee2812cca091561a2b2e464498dae2f913b8d"
bgruening
parents:
0
diff
changeset
|
121 writer.write(mol) |
0
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
122 |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
123 input_file.close() |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
124 writer.flush() |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
125 writer.close() |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
126 output_file.close() |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
127 |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
128 utils.log("Completed", comparisons, "comparisons") |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
129 |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
130 |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
131 ### start main execution ######################################### |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
132 |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
133 def main(): |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
134 parser = argparse.ArgumentParser(description='Max SuCOS scores with RDKit') |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
135 parser.add_argument('-i', '--input', help='Input file to score in SDF format. Can be gzipped (*.gz).') |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
136 parser.add_argument('-o', '--output', help='Output file in SDF format. Can be gzipped (*.gz).') |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
137 parser.add_argument('clusters', nargs='*', help="One or more SDF files with the clustered hits") |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
138 |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
139 args = parser.parse_args() |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
140 utils.log("Max SuCOS Args: ", args) |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
141 |
1
53fb0e116e99
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit 6f1ee2812cca091561a2b2e464498dae2f913b8d"
bgruening
parents:
0
diff
changeset
|
142 process(args.input, args.clusters, args.output) |
0
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
143 |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
144 |
1f19b95adc5c
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
145 if __name__ == "__main__": |
1
53fb0e116e99
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit 6f1ee2812cca091561a2b2e464498dae2f913b8d"
bgruening
parents:
0
diff
changeset
|
146 main() |