annotate distance_finder.py @ 16:a638d8d13bb3 draft default tip

planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit d9c51279c061a1da948a2582d5b502ca7573adbf
author bgruening
date Thu, 15 Aug 2024 11:02:57 +0000
parents 2cd8aee0d830
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
1 # Reports distances of ligands to reference points. An example input for the points is:
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
2 #
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
3 # 5.655 1.497 18.223
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
4 # 1.494 -8.367 18.574
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
5 # 13.034 6.306 25.232
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
6 #
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
7 # Data can be space or tab separated but must contain 3 and only 3 numbers for the x, y and z coordinates
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
8 #
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
9 # That would encode 3 points.
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
10 # Each record in the SDF input is read and the closest heavy atom to each of the reference points is recorded as
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
11 # a property named distance1 where the numeric part is the index (starting from 1) of the points (in that example
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
12 # there would be properties for distance1, distance2 and distance3.
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
13
14
2cd8aee0d830 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 1fe240ef0064a1a4a66d9be1ccace53824280b75"
bgruening
parents: 13
diff changeset
14 import argparse
2cd8aee0d830 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 1fe240ef0064a1a4a66d9be1ccace53824280b75"
bgruening
parents: 13
diff changeset
15 import math
2cd8aee0d830 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 1fe240ef0064a1a4a66d9be1ccace53824280b75"
bgruening
parents: 13
diff changeset
16 import sys
13
3ecaa9634126 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 944ea4bb8a9cd4244152a4a4fecd0485fabc2ad0"
bgruening
parents: 11
diff changeset
17
11
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
18 from openbabel import pybel
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
19
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
20
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
21 def log(*args, **kwargs):
16
a638d8d13bb3 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit d9c51279c061a1da948a2582d5b502ca7573adbf
bgruening
parents: 14
diff changeset
22 """Log output to STDERR"""
a638d8d13bb3 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit d9c51279c061a1da948a2582d5b502ca7573adbf
bgruening
parents: 14
diff changeset
23 print(*args, file=sys.stderr, **kwargs)
11
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
24
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
25
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
26 def execute(ligands_sdf, points_file, outfile):
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
27 """
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
28 :param ligands_sdf: A SDF with the 3D molecules to test
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
29 :param points_file: A file with the points to consider.
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
30 :param outfile: The name of the file for the SDF output
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
31 :return:
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
32 """
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
33
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
34 points = []
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
35
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
36 # read the points
16
a638d8d13bb3 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit d9c51279c061a1da948a2582d5b502ca7573adbf
bgruening
parents: 14
diff changeset
37 with open(points_file, "r") as f:
11
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
38 for line in f.readlines():
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
39 line.strip()
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
40 if line:
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
41 p = line.split()
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
42 if len(p) == 3:
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
43 points.append((float(p[0]), float(p[1]), float(p[2])))
14
2cd8aee0d830 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 1fe240ef0064a1a4a66d9be1ccace53824280b75"
bgruening
parents: 13
diff changeset
44 log("Read points", p)
11
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
45 continue
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
46 log("Failed to read line:", line)
16
a638d8d13bb3 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit d9c51279c061a1da948a2582d5b502ca7573adbf
bgruening
parents: 14
diff changeset
47 log("Found", len(points), "atom points")
11
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
48
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
49 sdf_writer = pybel.Outputfile("sdf", outfile, overwrite=True)
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
50
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
51 count = 0
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
52 for mol in pybel.readfile("sdf", ligands_sdf):
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
53 count += 1
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
54 if count % 50000 == 0:
16
a638d8d13bb3 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit d9c51279c061a1da948a2582d5b502ca7573adbf
bgruening
parents: 14
diff changeset
55 log("Processed", count)
11
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
56
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
57 try:
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
58 # print("Processing mol", mol.title)
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
59 clone = pybel.Molecule(mol)
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
60 clone.removeh()
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
61
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
62 coords = []
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
63 for atom in clone.atoms:
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
64 coords.append(atom.coords)
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
65
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
66 p = 0
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
67 for point in points:
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
68 p += 1
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
69 distances = []
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
70 for i in coords:
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
71 # calculates distance based on cartesian coordinates
16
a638d8d13bb3 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit d9c51279c061a1da948a2582d5b502ca7573adbf
bgruening
parents: 14
diff changeset
72 distance = math.sqrt(
a638d8d13bb3 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit d9c51279c061a1da948a2582d5b502ca7573adbf
bgruening
parents: 14
diff changeset
73 (point[0] - i[0]) ** 2
a638d8d13bb3 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit d9c51279c061a1da948a2582d5b502ca7573adbf
bgruening
parents: 14
diff changeset
74 + (point[1] - i[1]) ** 2
a638d8d13bb3 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit d9c51279c061a1da948a2582d5b502ca7573adbf
bgruening
parents: 14
diff changeset
75 + (point[2] - i[2]) ** 2
a638d8d13bb3 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit d9c51279c061a1da948a2582d5b502ca7573adbf
bgruening
parents: 14
diff changeset
76 )
11
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
77 distances.append(distance)
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
78 # log("distance:", distance)
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
79 min_distance = min(distances)
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
80 # log('Min:', min_distance)
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
81 # log(count, p, min_distance)
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
82
16
a638d8d13bb3 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit d9c51279c061a1da948a2582d5b502ca7573adbf
bgruening
parents: 14
diff changeset
83 mol.data["distance" + str(p)] = min_distance
11
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
84
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
85 sdf_writer.write(mol)
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
86
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
87 except Exception as e:
16
a638d8d13bb3 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit d9c51279c061a1da948a2582d5b502ca7573adbf
bgruening
parents: 14
diff changeset
88 log("Failed to handle molecule: " + str(e))
11
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
89 continue
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
90
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
91 sdf_writer.close()
16
a638d8d13bb3 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit d9c51279c061a1da948a2582d5b502ca7573adbf
bgruening
parents: 14
diff changeset
92 log("Wrote", count, "molecules")
11
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
93
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
94
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
95 def main():
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
96 global work_dir
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
97
16
a638d8d13bb3 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit d9c51279c061a1da948a2582d5b502ca7573adbf
bgruening
parents: 14
diff changeset
98 parser = argparse.ArgumentParser(
a638d8d13bb3 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit d9c51279c061a1da948a2582d5b502ca7573adbf
bgruening
parents: 14
diff changeset
99 description="XChem distances - measure distances to particular points"
a638d8d13bb3 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit d9c51279c061a1da948a2582d5b502ca7573adbf
bgruening
parents: 14
diff changeset
100 )
a638d8d13bb3 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit d9c51279c061a1da948a2582d5b502ca7573adbf
bgruening
parents: 14
diff changeset
101 parser.add_argument(
a638d8d13bb3 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit d9c51279c061a1da948a2582d5b502ca7573adbf
bgruening
parents: 14
diff changeset
102 "-i", "--input", help="SDF containing the 3D molecules to score)"
a638d8d13bb3 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit d9c51279c061a1da948a2582d5b502ca7573adbf
bgruening
parents: 14
diff changeset
103 )
a638d8d13bb3 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit d9c51279c061a1da948a2582d5b502ca7573adbf
bgruening
parents: 14
diff changeset
104 parser.add_argument("-p", "--points", help="PDB format file with atoms")
a638d8d13bb3 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit d9c51279c061a1da948a2582d5b502ca7573adbf
bgruening
parents: 14
diff changeset
105 parser.add_argument(
a638d8d13bb3 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit d9c51279c061a1da948a2582d5b502ca7573adbf
bgruening
parents: 14
diff changeset
106 "-o", "--outfile", default="output.sdf", help="File name for results"
a638d8d13bb3 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit d9c51279c061a1da948a2582d5b502ca7573adbf
bgruening
parents: 14
diff changeset
107 )
11
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
108
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
109 args = parser.parse_args()
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
110 log("XChem distances args: ", args)
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
111
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
112 execute(args.input, args.points, args.outfile)
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
113
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
114
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
115 if __name__ == "__main__":
49d21d05f77c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 6c84abdd07f292048bf2194073e2e938e94158c4"
bgruening
parents:
diff changeset
116 main()