Mercurial > repos > bgruening > autodock_vina
comparison convert_pdbqt_to_sdf.py @ 9:90ea16534012 draft default tip
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/autodock_vina commit 8ae58ec16b3b6d62b47022745211f11181ad78ea"
author | bgruening |
---|---|
date | Tue, 21 Dec 2021 14:18:33 +0000 |
parents | 7a871df65202 |
children |
comparison
equal
deleted
inserted
replaced
8:7a871df65202 | 9:90ea16534012 |
---|---|
1 import sys | 1 import sys |
2 | 2 |
3 from openbabel import pybel, openbabel | 3 from openbabel import openbabel, pybel |
4 | |
4 | 5 |
5 def main(): | 6 def main(): |
6 if len(sys.argv) == 3: | 7 if len(sys.argv) == 3: |
7 process(sys.argv[1], sys.argv[2]) | 8 process(sys.argv[1], sys.argv[2]) |
8 else: | 9 else: |
9 print("Usage: convert_pdbqt_to_sdf.py <input-pdbqt-file> <output-sdf-file>") | 10 print("Usage: convert_pdbqt_to_sdf.py <input-pdbqt-file> <output-sdf-file>") |
10 exit(1) | 11 exit(1) |
12 | |
11 | 13 |
12 def add_property(mol, prop_name, prop_value): | 14 def add_property(mol, prop_name, prop_value): |
13 newData = openbabel.OBPairData() | 15 newData = openbabel.OBPairData() |
14 newData.SetAttribute(prop_name) | 16 newData.SetAttribute(prop_name) |
15 newData.SetValue(prop_value) | 17 newData.SetValue(prop_value) |
16 mol.OBMol.CloneData(newData) | 18 mol.OBMol.CloneData(newData) |
19 | |
17 | 20 |
18 def process(input, output): | 21 def process(input, output): |
19 docked = pybel.readfile('pdbqt', input) | 22 docked = pybel.readfile("pdbqt", input) |
20 sdf = pybel.Outputfile("sdf", output, overwrite=True) | 23 sdf = pybel.Outputfile("sdf", output, overwrite=True) |
21 for mol in docked: | 24 for mol in docked: |
22 if mol.OBMol.HasData('REMARK'): | 25 if mol.OBMol.HasData("REMARK"): |
23 remark = mol.OBMol.GetData('REMARK').GetValue() | 26 remark = mol.OBMol.GetData("REMARK").GetValue() |
24 lines = remark.splitlines() | 27 lines = remark.splitlines() |
25 tokens = lines[0].split() | 28 tokens = lines[0].split() |
26 | |
27 # add the score property | |
28 add_property(mol, "SCORE", tokens[2]) | |
29 # add the first RMSD property | |
30 add_property(mol, "RMSD_LB", tokens[3]) | |
31 # add the second RMSD property | |
32 add_property(mol, "RMSD_UB", tokens[4]) | |
33 | 29 |
34 sdf.write(mol) | 30 # add the score property |
31 add_property(mol, "SCORE", tokens[2]) | |
32 # add the first RMSD property | |
33 add_property(mol, "RMSD_LB", tokens[3]) | |
34 # add the second RMSD property | |
35 add_property(mol, "RMSD_UB", tokens[4]) | |
35 | 36 |
36 sdf.close() | 37 sdf.write(mol) |
38 | |
39 sdf.close() | |
40 | |
37 | 41 |
38 if __name__ == "__main__": | 42 if __name__ == "__main__": |
39 main() | 43 main() |
40 |