annotate rdkit_descriptors.py @ 8:a1c53f0533b0 draft

"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
author bgruening
date Wed, 17 Feb 2021 12:59:43 +0000
parents 6674260c1459
children 0993ac4f4a23
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
1 #!/usr/bin/env python
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
2
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
3 import argparse
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
4 import inspect
8
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
5 import sys
0
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
6
8
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
7 from rdkit import Chem
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
8 from rdkit.Chem import Descriptors
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
9
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
10
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
11 def get_supplier(infile, format='smiles'):
0
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
12 """
8
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
13 Returns a generator over a SMILES or InChI file. Every element is of RDKit
0
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
14 molecule and has its original string as _Name property.
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
15 """
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
16 with open(infile) as handle:
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
17 for line in handle:
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
18 line = line.strip()
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
19 if format == 'smiles':
8
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
20 mol = Chem.MolFromSmiles(line, sanitize=True)
0
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
21 elif format == 'inchi':
8
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
22 mol = Chem.inchi.MolFromInchi(line, sanitize=True, removeHs=True, logLevel=None, treatWarningAsError=False)
0
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
23 if mol is None:
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
24 yield False
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
25 else:
8
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
26 mol.SetProp('_Name', line.split('\t')[0])
0
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
27 yield mol
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
28
8
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
29
0
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
30 def get_rdkit_descriptor_functions():
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
31 """
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
32 Returns all descriptor functions under the Chem.Descriptors Module as tuple of (name, function)
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
33 """
8
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
34 ret = [(name, f) for name, f in inspect.getmembers(Descriptors) if inspect.isfunction(f) and not name.startswith('_')]
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
35 # some which are not in the official Descriptors module we need to add manually
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
36 ret.extend([('FormalCharge', Chem.GetFormalCharge), ('SSSR', Chem.GetSSSR)])
0
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
37 ret.sort()
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
38 return ret
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
39
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
40
8
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
41 def descriptors(mol, functions):
0
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
42 """
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
43 Calculates the descriptors of a given molecule.
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
44 """
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
45 for name, function in functions:
8
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
46 yield (name, function(mol))
0
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
47
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
48
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
49 if __name__ == "__main__":
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
50 parser = argparse.ArgumentParser()
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
51 parser.add_argument('-i', '--infile', required=True, help='Path to the input file.')
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
52 parser.add_argument("--iformat", help="Specify the input file format.")
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
53
8
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
54 parser.add_argument('-o', '--outfile', type=argparse.FileType('w+'),
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
55 default=sys.stdout,
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
56 help="path to the result file, default is stdout")
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
57
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
58 parser.add_argument('-s', '--select', default=None,
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
59 help="select a subset of comma-separated descriptors to use")
0
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
60
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
61 parser.add_argument("--header", dest="header", action="store_true",
8
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
62 default=False,
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
63 help="Write header line.")
0
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
64
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
65 args = parser.parse_args()
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
66
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
67 if args.iformat == 'sdf':
8
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
68 supplier = Chem.SDMolSupplier(args.infile)
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
69 elif args.iformat == 'smi':
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
70 supplier = get_supplier(args.infile, format='smiles')
0
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
71 elif args.iformat == 'inchi':
8
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
72 supplier = get_supplier(args.infile, format='inchi')
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
73 elif args.iformat == 'pdb':
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
74 supplier = [Chem.MolFromPDBFile(args.infile)]
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
75 elif args.iformat == 'mol2':
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
76 supplier = [Chem.MolFromMol2File(args.infile)]
0
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
77
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
78 functions = get_rdkit_descriptor_functions()
8
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
79 if args.select and args.select != 'None':
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
80 selected = args.select.split(',')
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
81 functions = [(name, f) for name, f in functions if name in selected]
0
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
82
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
83 if args.header:
8
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
84 args.outfile.write('%s\n' % '\t'.join(['MoleculeID'] + [name for name, f in functions]))
0
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
85
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
86 for mol in supplier:
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
87 if not mol:
749cc765636b planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit ed9b6859de648aa5f7cde483732f5df20aaff90e
bgruening
parents:
diff changeset
88 continue
8
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
89 descs = descriptors(mol, functions)
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
90 try:
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
91 molecule_id = mol.GetProp("_Name")
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
92 except KeyError:
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
93 molecule_id = Chem.MolToSmiles(mol)
a1c53f0533b0 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdkit commit 4d0bfcf37bfbedafc7ff0672dfe452766ca8a606"
bgruening
parents: 2
diff changeset
94 args.outfile.write("%s\n" % '\t'.join([molecule_id] + [str(round(res, 6)) for name, res in descs]))