diff 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
line wrap: on
line diff
--- a/convert_pdbqt_to_sdf.py	Tue Jul 28 08:13:41 2020 -0400
+++ b/convert_pdbqt_to_sdf.py	Tue Dec 21 14:18:33 2021 +0000
@@ -1,40 +1,43 @@
 import sys
 
-from openbabel import pybel, openbabel
+from openbabel import openbabel, pybel
+
 
 def main():
-	if len(sys.argv) == 3:
-		process(sys.argv[1], sys.argv[2])
-	else:
-		print("Usage: convert_pdbqt_to_sdf.py <input-pdbqt-file> <output-sdf-file>")
-		exit(1)
+    if len(sys.argv) == 3:
+        process(sys.argv[1], sys.argv[2])
+    else:
+        print("Usage: convert_pdbqt_to_sdf.py <input-pdbqt-file> <output-sdf-file>")
+        exit(1)
+
 
 def add_property(mol, prop_name, prop_value):
-	newData = openbabel.OBPairData() 
-	newData.SetAttribute(prop_name)
-	newData.SetValue(prop_value) 
-	mol.OBMol.CloneData(newData)
+    newData = openbabel.OBPairData()
+    newData.SetAttribute(prop_name)
+    newData.SetValue(prop_value)
+    mol.OBMol.CloneData(newData)
+
 
 def process(input, output):
-	docked = pybel.readfile('pdbqt', input)
-	sdf = pybel.Outputfile("sdf", output, overwrite=True)
-	for mol in docked:
-		if mol.OBMol.HasData('REMARK'):
-			remark = mol.OBMol.GetData('REMARK').GetValue()
-			lines = remark.splitlines()
-			tokens = lines[0].split()
-		
-			# add the score property
-			add_property(mol, "SCORE", tokens[2]) 
-			# add the first RMSD property
-			add_property(mol, "RMSD_LB", tokens[3])
-			# add the second RMSD property
-			add_property(mol, "RMSD_UB", tokens[4])
+    docked = pybel.readfile("pdbqt", input)
+    sdf = pybel.Outputfile("sdf", output, overwrite=True)
+    for mol in docked:
+        if mol.OBMol.HasData("REMARK"):
+            remark = mol.OBMol.GetData("REMARK").GetValue()
+            lines = remark.splitlines()
+            tokens = lines[0].split()
 
-		sdf.write(mol)
+            # add the score property
+            add_property(mol, "SCORE", tokens[2])
+            # add the first RMSD property
+            add_property(mol, "RMSD_LB", tokens[3])
+            # add the second RMSD property
+            add_property(mol, "RMSD_UB", tokens[4])
 
-	sdf.close()
+        sdf.write(mol)
+
+    sdf.close()
+
 
 if __name__ == "__main__":
     main()
-