Mercurial > repos > bgruening > sucos_docking_scoring
annotate sucos.py @ 0:f8f53668d5a2 draft
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
author | bgruening |
---|---|
date | Wed, 02 Oct 2019 12:58:43 -0400 |
parents | |
children | 8161c08627bf |
rev | line source |
---|---|
0
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
1 #!/usr/bin/env python |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
2 """ |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
3 Basic SuCOS scoring. Allows a set of molecules from a SD file to be overlayed to a reference molecule, |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
4 with the resulting scores being written as properties in the output SD file. |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
5 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
6 SuCOS is the work of Susan Leung. |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
7 GitHub: https://github.com/susanhleung/SuCOS |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
8 Publication: https://doi.org/10.26434/chemrxiv.8100203.v1 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
9 """ |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
10 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
11 from __future__ import print_function |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
12 import argparse, os, sys, gzip |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
13 import numpy as np |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
14 from rdkit import Chem, rdBase, RDConfig |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
15 from rdkit.Chem import AllChem, rdShapeHelpers |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
16 from rdkit.Chem.FeatMaps import FeatMaps |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
17 import utils |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
18 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
19 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
20 ### start function definitions ######################################### |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
21 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
22 # Setting up the features to use in FeatureMap |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
23 fdef = AllChem.BuildFeatureFactory(os.path.join(RDConfig.RDDataDir, 'BaseFeatures.fdef')) |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
24 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
25 fmParams = {} |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
26 for k in fdef.GetFeatureFamilies(): |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
27 fparams = FeatMaps.FeatMapParams() |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
28 fmParams[k] = fparams |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
29 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
30 keep = ('Donor', 'Acceptor', 'NegIonizable', 'PosIonizable', 'ZnBinder', |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
31 'Aromatic', 'Hydrophobe', 'LumpedHydrophobe') |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
32 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
33 def filterFeature(f): |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
34 result = f.GetFamily() in keep |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
35 # TODO - nothing ever seems to be filtered. Is this expected? |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
36 if not result: |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
37 utils.log("Filtered out feature type", f.GetFamily()) |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
38 return result |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
39 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
40 def getRawFeatures(mol): |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
41 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
42 rawFeats = fdef.GetFeaturesForMol(mol) |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
43 # filter that list down to only include the ones we're interested in |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
44 filtered = list(filter(filterFeature, rawFeats)) |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
45 return filtered |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
46 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
47 def get_FeatureMapScore(small_feats, large_feats, tani=False, score_mode=FeatMaps.FeatMapScoreMode.All): |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
48 """ |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
49 Generate the feature map score. |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
50 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
51 :param small_feats: |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
52 :param large_feats: |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
53 :param tani: |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
54 :return: |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
55 """ |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
56 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
57 featLists = [] |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
58 for rawFeats in [small_feats, large_feats]: |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
59 # filter that list down to only include the ones we're interested in |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
60 featLists.append(rawFeats) |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
61 fms = [FeatMaps.FeatMap(feats=x, weights=[1] * len(x), params=fmParams) for x in featLists] |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
62 # set the score mode |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
63 fms[0].scoreMode = score_mode |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
64 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
65 try: |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
66 if tani: |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
67 c = fms[0].ScoreFeats(featLists[1]) |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
68 A = fms[0].GetNumFeatures() |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
69 B = len(featLists[1]) |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
70 if B != fms[1].GetNumFeatures(): |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
71 utils.log("Why isn't B equal to number of features...?!") |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
72 tani_score = float(c) / (A+B-c) |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
73 return tani_score |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
74 else: |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
75 fm_score = fms[0].ScoreFeats(featLists[1]) / min(fms[0].GetNumFeatures(), len(featLists[1])) |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
76 return fm_score |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
77 except ZeroDivisionError: |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
78 utils.log("ZeroDivisionError") |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
79 return 0 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
80 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
81 if tani: |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
82 tani_score = float(c) / (A+B-c) |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
83 return tani_score |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
84 else: |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
85 fm_score = fms[0].ScoreFeats(featLists[1]) / min(fms[0].GetNumFeatures(), len(featLists[1])) |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
86 return fm_score |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
87 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
88 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
89 def get_SucosScore(ref_mol, query_mol, tani=False, ref_features=None, query_features=None, score_mode=FeatMaps.FeatMapScoreMode.All): |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
90 """ |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
91 This is the key function that calculates the SuCOS scores and is expected to be called from other modules. |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
92 To improve performance you can pre-calculate the features and pass them in as optional parameters to avoid having |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
93 to recalculate them. Use the getRawFeatures function to pre-calculate the features. |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
94 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
95 :param ref_mol: The reference molecule to compare to |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
96 :param query_mol: The molecule to align to the reference |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
97 :param tani: Whether to calculate Tanimoto distances |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
98 :param ref_features: An optional feature map for the reference molecule, avoiding the need to re-calculate it. |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
99 :param query_features: An optional feature map for the query molecule, avoiding the need to re-calculate it. |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
100 :return: A tuple of 3 values. 1 the sucos score, 2 the feature map score, |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
101 3 the Tanimoto distance or 1 minus the protrude distance |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
102 """ |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
103 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
104 if not ref_features: |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
105 ref_features = getRawFeatures(ref_mol) |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
106 if not query_features: |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
107 query_features = getRawFeatures(query_mol) |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
108 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
109 fm_score = get_FeatureMapScore(ref_features, query_features, tani, score_mode) |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
110 fm_score = np.clip(fm_score, 0, 1) |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
111 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
112 if tani: |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
113 tani_sim = 1 - float(rdShapeHelpers.ShapeTanimotoDist(ref_mol, query_mol)) |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
114 tani_sim = np.clip(tani_sim, 0, 1) |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
115 SuCOS_score = 0.5*fm_score + 0.5*tani_sim |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
116 return SuCOS_score, fm_score, tani_sim |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
117 else: |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
118 protrude_dist = rdShapeHelpers.ShapeProtrudeDist(ref_mol, query_mol, allowReordering=False) |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
119 protrude_dist = np.clip(protrude_dist, 0, 1) |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
120 protrude_val = 1.0 - protrude_dist |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
121 SuCOS_score = 0.5 * fm_score + 0.5 * protrude_val |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
122 return SuCOS_score, fm_score, protrude_val |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
123 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
124 def process(refmol_filename, inputs_filename, outputs_filename, refmol_index=None, |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
125 refmol_format=None, tani=False, score_mode=FeatMaps.FeatMapScoreMode.All): |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
126 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
127 ref_mol = utils.read_single_molecule(refmol_filename, index=refmol_index, format=refmol_format) |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
128 #utils.log("Reference mol has", ref_mol.GetNumHeavyAtoms(), "heavy atoms") |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
129 ref_features = getRawFeatures(ref_mol) |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
130 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
131 input_file = utils.open_file_for_reading(inputs_filename) |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
132 suppl = Chem.ForwardSDMolSupplier(input_file) |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
133 output_file = utils.open_file_for_writing(outputs_filename) |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
134 writer = Chem.SDWriter(output_file) |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
135 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
136 count = 0 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
137 total = 0 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
138 errors = 0 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
139 for mol in suppl: |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
140 count +=1 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
141 if mol is None: |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
142 continue |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
143 #utils.log("Mol has", str(mol.GetNumHeavyAtoms()), "heavy atoms") |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
144 try: |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
145 sucos_score, fm_score, val3 = get_SucosScore(ref_mol, mol, tani=tani, ref_features=ref_features, score_mode=score_mode) |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
146 mol.SetDoubleProp("SuCOS_Score", sucos_score) |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
147 mol.SetDoubleProp("SuCOS_FeatureMap_Score", fm_score) |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
148 if tani: |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
149 mol.SetDoubleProp("SuCOS_Tanimoto_Score", val3) |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
150 else: |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
151 mol.SetDoubleProp("SuCOS_Protrude_Score", val3) |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
152 utils.log("Scores:", sucos_score, fm_score, val3) |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
153 writer.write(mol) |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
154 total +=1 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
155 except ValueError as e: |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
156 errors +=1 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
157 utils.log("Molecule", count, "failed to score:", e.message) |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
158 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
159 input_file.close() |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
160 writer.flush() |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
161 writer.close() |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
162 output_file.close() |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
163 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
164 utils.log("Completed.", total, "processed, ", count, "succeeded, ", errors, "errors") |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
165 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
166 def parse_score_mode(value): |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
167 if value == None or value == 'all': |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
168 return FeatMaps.FeatMapScoreMode.All |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
169 elif value == 'closest': |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
170 return FeatMaps.FeatMapScoreMode.Closest |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
171 elif value == 'best': |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
172 return FeatMaps.FeatMapScoreMode.Best |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
173 else: |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
174 raise ValueError(value + " is not a valid scoring mode option") |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
175 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
176 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
177 ### start main execution ######################################### |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
178 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
179 def main(): |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
180 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
181 parser = argparse.ArgumentParser(description='SuCOS with RDKit') |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
182 parser.add_argument('-i', '--input', help='Input file in SDF format. Can be gzipped (*.gz).') |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
183 parser.add_argument('-r', '--refmol', help='Molecule to compare against in Molfile (.mol) or SDF (.sdf) format') |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
184 parser.add_argument('--refmol-format', help="Format for the reference molecule (mol or sdf). " + |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
185 "Only needed if files don't have the expected extensions") |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
186 parser.add_argument('--refmolidx', help='Reference molecule index in SD file if not the first', type=int, default=1) |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
187 parser.add_argument('-o', '--output', help='Output file in SDF format. Can be gzipped (*.gz).') |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
188 parser.add_argument('--tanimoto', action='store_true', help='Include Tanimoto distance in score') |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
189 parser.add_argument('--score_mode', choices=['all', 'closest', 'best'], |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
190 help="choose the scoring mode for the feature map, default is 'all'.") |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
191 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
192 args = parser.parse_args() |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
193 utils.log("SuCOS Args: ", args) |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
194 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
195 score_mode = parse_score_mode(args.score_mode) |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
196 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
197 process(args.refmol, args.input, args.output, refmol_index=args.refmolidx, |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
198 refmol_format=args.refmol_format, tani=args.tanimoto, score_mode=score_mode) |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
199 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
200 |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
201 if __name__ == "__main__": |
f8f53668d5a2
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/sucos commit ef86cfa5f7ab5043de420511211579d03df58645"
bgruening
parents:
diff
changeset
|
202 main() |