aboutsummaryrefslogtreecommitdiff
path: root/app/scripts/get_dock_score.py
blob: c4cc30d0fbd3ee493ace9ea1450b2cc2902e9b93 (plain)
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
46
47
48
49
50
#!/usr/bin/python3
from datetime import datetime
import argparse

parser = argparse.ArgumentParser(description="Get Docking Score")
parser.add_argument("-p","--protein",help="Path to protein file")
parser.add_argument("-l","--ligand",help="Path to ligand_out file")

args = parser.parse_args()

if args.protein == None:
    print("Error: Please specify protein file")
    exit(1)
if args.ligand == None:
    print("Error: Please specify ligand file")
    exit(1)


protein = args.protein
ligand = args.ligand

from os.path import basename

print("% Molecular Docking of " + str(basename(ligand)).replace("_out.pdbqt","") + " with " +str(basename(protein)).replace(".pdbqt",""))
print("%")
print("% " + str(datetime.now().strftime("%b %d, %Y")))

print("![Structure of %s](compound.svg)"%(str(basename(ligand)).replace("_out.pdbqt","")),end="\n\n")

from tabulate import tabulate

file = open(ligand, "r")
lines = file.readlines()
results = []
i = 1
for line in lines:
    ta = []
    if line.find('REMARK VINA') == 0 and line.split()[3] != "":
        l = line.split()
        ta.append(i)
        ta.append(l[3])
        ta.append(l[4])
        ta.append(l[5])
        i += 1
    if ta != []:
        results.append(ta)

print("# Docking Score",end="\n\n")
print(tabulate(results,headers=["No.","Affinity","rmsd l.b","rmsd u.b"]))
print("",end="\n\n")