Mercurial > repos > bgruening > autodock_vina
comparison convert_pdbqt_to_sdf.py @ 6:0ae768a0e5c0 draft
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/autodock_vina commit a2f6034a691af458e3df662e36d7f05617982bdc
author | bgruening |
---|---|
date | Wed, 19 Jun 2019 06:43:41 -0400 |
parents | |
children | 7a871df65202 |
comparison
equal
deleted
inserted
replaced
5:c410ffcabf9d | 6:0ae768a0e5c0 |
---|---|
1 import pybel, openbabel | |
2 import sys | |
3 | |
4 | |
5 def main(): | |
6 if len(sys.argv) == 3: | |
7 process(sys.argv[1], sys.argv[2]) | |
8 else: | |
9 print("Usage: convert_pdbqt_to_sdf.py <input-pdbqt-file> <output-sdf-file>") | |
10 exit(1) | |
11 | |
12 def add_property(mol, prop_name, prop_value): | |
13 newData = openbabel.OBPairData() | |
14 newData.SetAttribute(prop_name) | |
15 newData.SetValue(prop_value) | |
16 mol.OBMol.CloneData(newData) | |
17 | |
18 def process(input, output): | |
19 docked = pybel.readfile('pdbqt', input) | |
20 sdf = pybel.Outputfile("sdf", output, overwrite=True) | |
21 for mol in docked: | |
22 if mol.OBMol.HasData('REMARK'): | |
23 remark = mol.OBMol.GetData('REMARK').GetValue() | |
24 lines = remark.splitlines() | |
25 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 | |
34 sdf.write(mol) | |
35 | |
36 sdf.close() | |
37 | |
38 if __name__ == "__main__": | |
39 main() | |
40 |