annotate chembl.py @ 0:2f59c6239f25 draft default tip

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