Mercurial > repos > guerler > springsuite
comparison spring_model_all.py @ 39:172398348efd draft
"planemo upload commit 26b4018c88041ee0ca7c2976e0a012015173d7b6-dirty"
author | guerler |
---|---|
date | Fri, 22 Jan 2021 15:50:27 +0000 |
parents | |
children | f316caf098a6 |
comparison
equal
deleted
inserted
replaced
38:80a4b98121b6 | 39:172398348efd |
---|---|
1 #! /usr/bin/env python3 | |
2 import argparse | |
3 from os import mkdir, remove | |
4 from os.path import isdir, isfile | |
5 | |
6 from spring_package.DBKit import DBKit | |
7 from spring_package.Modeller import createModel | |
8 | |
9 | |
10 class ModelArguments: | |
11 def __init__(self, args): | |
12 self.log = args.log | |
13 self.index = args.index | |
14 self.database = args.database | |
15 self.cross = args.cross | |
16 self.wenergy = args.wenergy | |
17 self.minscore = args.minscore | |
18 self.maxtries = args.maxtries | |
19 self.maxclashes = args.maxclashes | |
20 self.showtemplate = args.showtemplate | |
21 | |
22 def set(self, a_hhr, b_hhr, output): | |
23 self.a_hhr = a_hhr | |
24 self.b_hhr = b_hhr | |
25 self.output = output | |
26 | |
27 | |
28 def main(args): | |
29 modelArgs = ModelArguments(args) | |
30 outPath = args.outputpath.rstrip("/") | |
31 if not isdir(outPath): | |
32 mkdir(outPath) | |
33 if not isdir("temp"): | |
34 mkdir("temp") | |
35 dbkit = DBKit(args.hhr_index, args.hhr_database) | |
36 logFile = open(args.log, "w") | |
37 logFile.write("#namea\t nameb\t springscore\t tmscore\t energy\t clashes\n") | |
38 with open(args.pairs, "r") as file: | |
39 for line in file: | |
40 param = line.split() | |
41 aIdentifier = param[0] | |
42 bIdentifier = param[1] | |
43 aFile = "temp/%s" % aIdentifier | |
44 bFile = "temp/%s" % bIdentifier | |
45 if not dbkit.createFile(aIdentifier, aFile): | |
46 print("Failed to retrieve entry %s." % aIdentifier) | |
47 continue | |
48 if not dbkit.createFile(bIdentifier, bFile): | |
49 print("Failed to retrieve entry %s." % bIdentifier) | |
50 continue | |
51 output = "%s/%s.%s.pdb" % (outPath, aIdentifier, bIdentifier) | |
52 modelArgs.set(a_hhr=aFile, b_hhr=bFile, output=output) | |
53 modelData = createModel(modelArgs) | |
54 if modelData: | |
55 infoStr = "%s\t %s\t %5.2f\t %5.2f\t %5.2f\t %5.2f\n" % (aIdentifier, bIdentifier, | |
56 modelData["springscore"], | |
57 modelData["tmscore"], | |
58 modelData["energy"], | |
59 modelData["clashes"]) | |
60 logFile.write(infoStr) | |
61 if isfile(aFile): | |
62 remove(aFile) | |
63 if isfile(bFile): | |
64 remove(bFile) | |
65 logFile.close() | |
66 | |
67 | |
68 if __name__ == "__main__": | |
69 parser = argparse.ArgumentParser(description='Create 3D models from HH-search results.') | |
70 parser.add_argument('-p', '--pairs', help='Interaction table e.g. from min-Z evaluation (2-columns)', required=True) | |
71 parser.add_argument('-ih', '--hhr_index', help='HHR Index database file (ffindex)', required=True) | |
72 parser.add_argument('-dh', '--hhr_database', help='HHR Database file (ffdata)', required=True) | |
73 parser.add_argument('-i', '--index', help='PDB Database Index file (ffindex)', required=True) | |
74 parser.add_argument('-d', '--database', help='PDB Database file (ffdata)', required=True) | |
75 parser.add_argument('-c', '--cross', help='PDB Cross Reference', required=True) | |
76 parser.add_argument('-g', '--log', help='Log file', required=True) | |
77 parser.add_argument('-o', '--outputpath', help='Path to output directory', required=True) | |
78 parser.add_argument('-we', '--wenergy', help='Weight Energy term', type=float, default=-0.01, required=False) | |
79 parser.add_argument('-ms', '--minscore', help='Minimum min-Z score threshold', type=float, default=10.0, required=False) | |
80 parser.add_argument('-mt', '--maxtries', help='Maximum number of templates', type=int, default=20, required=False) | |
81 parser.add_argument('-mc', '--maxclashes', help='Maximum fraction of clashes', type=float, default=0.1, required=False) | |
82 parser.add_argument('-sr', '--showtemplate', help='Add reference template to model structure', required=False, default="true") | |
83 args = parser.parse_args() | |
84 main(args) |