annotate chembl.py @ 9:a446ea7e2bc1 draft default tip

"planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 7ca965e469cce3951d22c854dc7b6cb2a3a4f9f6"
author bgruening
date Tue, 23 Mar 2021 13:48:35 +0000
parents a43a00845834
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
a57de37f12c2 "planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 78f2261af4e00c830ea311337d0aed9b297aad8e"
bgruening
parents: 5
diff changeset
1 import argparse
a57de37f12c2 "planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 78f2261af4e00c830ea311337d0aed9b297aad8e"
bgruening
parents: 5
diff changeset
2
1
6f8458d1cf46 "planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 594b8bcfa2730fb21de1efa83f89e0380fdcaa0f"
bgruening
parents: 0
diff changeset
3 from chembl_webresource_client.settings import Settings
6f8458d1cf46 "planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 594b8bcfa2730fb21de1efa83f89e0380fdcaa0f"
bgruening
parents: 0
diff changeset
4 Settings.Instance().CACHING = False
8
a43a00845834 "planemo upload for repository https://github.com/chembl/chembl_webresource_client commit e062e8287369e08bacf084e445acbeceb38c8ede"
bgruening
parents: 6
diff changeset
5 from chembl_webresource_client.new_client import new_client # noqa
6
a57de37f12c2 "planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 78f2261af4e00c830ea311337d0aed9b297aad8e"
bgruening
parents: 5
diff changeset
6
0
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
7
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
8 def open_file(filename):
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
9 with open(filename) as f:
4
59eea7d0d720 "planemo upload for repository https://github.com/chembl/chembl_webresource_client commit f5c316339ed36a0469f4862d00fa0e5cafebc041"
bgruening
parents: 2
diff changeset
10 return f.readline().split()[0]
0
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
11
6
a57de37f12c2 "planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 78f2261af4e00c830ea311337d0aed9b297aad8e"
bgruening
parents: 5
diff changeset
12
0
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
13 def get_smiles(res):
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
14 """
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
15 Get a list of SMILES from function results
6
a57de37f12c2 "planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 78f2261af4e00c830ea311337d0aed9b297aad8e"
bgruening
parents: 5
diff changeset
16 """
0
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
17 smiles = set()
6
a57de37f12c2 "planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 78f2261af4e00c830ea311337d0aed9b297aad8e"
bgruening
parents: 5
diff changeset
18 for smi in res:
5
1ade252ebe08 "planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 944ea4bb8a9cd4244152a4a4fecd0485fabc2ad0"
bgruening
parents: 4
diff changeset
19 try:
1ade252ebe08 "planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 944ea4bb8a9cd4244152a4a4fecd0485fabc2ad0"
bgruening
parents: 4
diff changeset
20 smiles.add('{}\t{}'.format(smi['molecule_structures']['canonical_smiles'], smi['molecule_chembl_id']))
1ade252ebe08 "planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 944ea4bb8a9cd4244152a4a4fecd0485fabc2ad0"
bgruening
parents: 4
diff changeset
21 except TypeError:
1ade252ebe08 "planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 944ea4bb8a9cd4244152a4a4fecd0485fabc2ad0"
bgruening
parents: 4
diff changeset
22 continue
0
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
23 return smiles
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
24
6
a57de37f12c2 "planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 78f2261af4e00c830ea311337d0aed9b297aad8e"
bgruening
parents: 5
diff changeset
25
0
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
26 def sim_search(smiles, tanimoto):
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
27 """
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
28 Return compounds which are within a Tanimoto range of the SMILES input
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
29 """
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
30 similarity = new_client.similarity
2
f56492688f43 "planemo upload for repository https://github.com/chembl/chembl_webresource_client commit d7fca21744d3c87cf173c1539c069a5c720084f3"
bgruening
parents: 1
diff changeset
31 return similarity.filter(smiles=smiles, similarity=tanimoto).only(['molecule_structures', 'molecule_chembl_id'])
6
a57de37f12c2 "planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 78f2261af4e00c830ea311337d0aed9b297aad8e"
bgruening
parents: 5
diff changeset
32
a57de37f12c2 "planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 78f2261af4e00c830ea311337d0aed9b297aad8e"
bgruening
parents: 5
diff changeset
33
0
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
34 def substr_search(smiles):
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
35 """
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
36 Return compounds which contain the SMILES substructure input
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
37 """
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
38 substructure = new_client.substructure
2
f56492688f43 "planemo upload for repository https://github.com/chembl/chembl_webresource_client commit d7fca21744d3c87cf173c1539c069a5c720084f3"
bgruening
parents: 1
diff changeset
39 return substructure.filter(smiles=smiles).only(['molecule_structures', 'molecule_chembl_id'])
6
a57de37f12c2 "planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 78f2261af4e00c830ea311337d0aed9b297aad8e"
bgruening
parents: 5
diff changeset
40
a57de37f12c2 "planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 78f2261af4e00c830ea311337d0aed9b297aad8e"
bgruening
parents: 5
diff changeset
41
0
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
42 def filter_drugs(mols):
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
43 """
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
44 Return only compounds which are approved drugs
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
45 """
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
46 return mols.filter(max_phase=4)
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
47
6
a57de37f12c2 "planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 78f2261af4e00c830ea311337d0aed9b297aad8e"
bgruening
parents: 5
diff changeset
48
0
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
49 def filter_biotherapeutic(mols):
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
50 """
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
51 Return only biotherapeutic molecules
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
52 """
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
53 return mols.filter(biotherapeutic__isnull=False)
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
54
6
a57de37f12c2 "planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 78f2261af4e00c830ea311337d0aed9b297aad8e"
bgruening
parents: 5
diff changeset
55
0
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
56 def filter_nat_prod(mols):
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
57 """
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
58 Return only natural products
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
59 """
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
60 return mols.filter(natural_product=1)
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
61
6
a57de37f12c2 "planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 78f2261af4e00c830ea311337d0aed9b297aad8e"
bgruening
parents: 5
diff changeset
62
0
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
63 def filter_ro5(mols):
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
64 """
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
65 Return only compounds with no RO5 violations
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
66 """
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
67 return mols.filter(molecule_properties__num_ro5_violations=0)
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
68
6
a57de37f12c2 "planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 78f2261af4e00c830ea311337d0aed9b297aad8e"
bgruening
parents: 5
diff changeset
69
0
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
70 def main():
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
71 parser = argparse.ArgumentParser(description='Search ChEMBL database for compounds')
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
72 parser.add_argument('-i', '--input', help='SMILES input')
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
73 parser.add_argument('-f', '--file', help='SMILES input as file')
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
74 parser.add_argument('-o', '--output', help="SMILES output")
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
75 parser.add_argument('-t', '--tanimoto', type=int, help='Tanimoto similarity score')
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
76 parser.add_argument('-s', '--substructure', action='store_true', help='Substructure search using the SMILES input.')
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
77 parser.add_argument('-d', '--drugs', action='store_true', help='Filter approved drugs')
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
78 parser.add_argument('-b', '--biotherapeutic', action='store_true', help='Filter biotherapeutic molecules')
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
79 parser.add_argument('-n', '--nat-prod', action='store_true', help='Filter natural products')
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
80 parser.add_argument('-r', '--ro5', action='store_true', help='Filter compounds that pass Lipinski RO5')
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
81
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
82 args = parser.parse_args()
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
83
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
84 if args.file: # get SMILES from file rather than -i option
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
85 args.input = open_file(args.file)
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
86
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
87 if len(args.input) < 5:
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
88 raise IOError('SMILES must be at least 5 characters long.')
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
89
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
90 if args.substructure: # specify search type: substructure or similarity
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
91 mols = substr_search(args.input)
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
92 else:
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
93 mols = sim_search(args.input, args.tanimoto)
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
94
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
95 # filter options:
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
96 if args.drugs:
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
97 mols = filter_drugs(mols)
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
98
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
99 if args.biotherapeutic:
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
100 mols = filter_biotherapeutic(mols)
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
101
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
102 if args.nat_prod:
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
103 mols = filter_nat_prod(mols)
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
104
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
105 if args.ro5:
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
106 mols = filter_ro5(mols)
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
107
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
108 # get SMILES from search output
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
109 mols = get_smiles(mols)
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
110
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
111 # write to file
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
112 with open(args.output, 'w') as f:
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
113 f.write('\n'.join(mols))
6
a57de37f12c2 "planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 78f2261af4e00c830ea311337d0aed9b297aad8e"
bgruening
parents: 5
diff changeset
114
0
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
115
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
116 if __name__ == "__main__":
915e9be38994 planemo upload for repository https://github.com/chembl/chembl_webresource_client commit 2e3c3c2bd7ecdc9c2968a32f91e81136e0cb3835
bgruening
parents:
diff changeset
117 main()