-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdock_multiple_ligands.py
More file actions
45 lines (36 loc) · 1.21 KB
/
Copy pathdock_multiple_ligands.py
File metadata and controls
45 lines (36 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env python3
import os
import sys
import glob
from threading import Thread
from multiprocessing import Pool
import multiprocessing
def usage():
print ("\n\nUSAGE: \n\n\tpython dock_multiple_ligands.py protein.pdbqt dpf_file.dpf\n\n")
pdbqts = glob.glob("*.pdbqt")
protein_file = sys.argv[1]
dpf_file = sys.argv[2]
open_dpf = open(dpf_file,"r").readlines()
def processing(data):
if data != protein_file:
save_dpf = open(data[:-6] + ".dpf","w")
output = ""
for entry in open_dpf:
if "move" not in entry:
output += entry
else:
output += "move " + data + " # small molecule\n"
save_dpf.write(output)
save_dpf.close()
os.system("autodock4 -p " + data[:-6] + ".dpf -l " + data[:-6] + ".dlg")
def do_dock(data_set):
if __name__ == '__main__':
p = Pool(num_threads)
p.map(processing, data_set)
if len(sys.argv) <= 2:
usage()
else:
num_threads = int(input("Number of threads to be used ('0' to use all the threads) : "))
if num_threads == 0:
num_threads = multiprocessing.cpu_count() # change this to number of threads the program should run in
do_dock(pdbqts)