-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcreate_project.py
More file actions
executable file
·147 lines (125 loc) · 5.8 KB
/
create_project.py
File metadata and controls
executable file
·147 lines (125 loc) · 5.8 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/usr/bin/env python
import os
import argparse
import sys
from time import sleep
import subprocess
import myPersonalFunctions
import fileinput
from small_script.myFunctions import *
parser = argparse.ArgumentParser(
description="The goal of this python3 code is to automatically create \
the project template as fast as possible. Written by Wei Lu."
)
parser.add_argument("protein", help="The name of the protein")
parser.add_argument("-d", "--debug", action="store_true", default=False)
parser.add_argument("--frag", action="store_true", default=False)
parser.add_argument("--crystal", action="store_true", default=False)
parser.add_argument("--membrane", action="store_true", default=False)
parser.add_argument("--globular", action="store_true", default=False)
parser.add_argument("--hybrid", action="store_true", default=False)
parser.add_argument("--bias", action="store_true", default=False)
parser.add_argument("--rgbias", action="store_true", default=False)
args = parser.parse_args()
if(args.debug):
do = print
cd = print
else:
do = os.system
cd = os.chdir
proteinName = args.protein
# print(args)
with open('commandline_args.txt', 'w') as f:
f.write(' '.join(sys.argv))
f.write('\n')
# get fasta, pdb, seq file ready
# HETATM MSE will not be counted as regular residue.
do("~/opt/script/pdb2fasta.sh crystal_structure.pdb > {0}.fasta".format(proteinName))
size = myPersonalFunctions.length_from_fasta("{0}.fasta".format(proteinName))
## start with crystal structure
do("python2 ~/opt/script/PDBToCoordinates.py crystal_structure crystal.coord")
do("python2 ~/opt/small_script/coord2data.py crystal.coord data.crystal -b")
if not args.crystal:
do("~/opt/fasta2pdb.py "+proteinName)
do("python2 ~/opt/script/PDBToCoordinates.py {0} {0}.coord".format(proteinName))
do("python2 ~/opt/small_script/coord2data.py {0}.coord data.{0} -b".format(proteinName))
if True: # used for go model
# do("~/opt/fasta2pdb.py "+proteinName)
do("python2 ~/opt/script/GetCACADistancesFile.py crystal_structure native.dat")
do("python2 ~/opt/script/GetCACoordinatesFromPDB.py crystal_structure nativecoords.dat")
do("cp native.dat rnative.dat") # q bias need rnative
# do("python2 ~/opt/Pdb2Gro.py {0}.pdb amh-go.gro".format(proteinName))
do("python2 ~/opt/Pdb2Gro.py crystal_structure.pdb amh-go.gro")
## ssweight
do("stride crystal_structure.pdb > ssweight.stride")
do("python2 ~/opt/script/stride2ssweight.py > ssweight")
# below used for zim and zimPosition file
if args.membrane or args.hybrid:
do(f"cp data.crystal data.{proteinName}")
do("grep -E 'CB|CA GLY' crystal_structure.pdb > cbs.data")
do("""awk '{if($9>15) print "1"; else if($9<-15) print "3"; else print "2"}' cbs.data > zimPosition""")
do(f"python3 ~/opt/create_zim.py -f {proteinName}.fasta")
if args.crystal:
create_zim(f"crystal.seq")
# create "in" file
alpha_carbons = " ".join([str(i) for i in list(range(1, size*3+1, 3))])
beta_atoms = " ".join([str(i) for i in list(range(3, size*3+1, 3))])
oxygens = " ".join([str(i) for i in list(range(2, size*3+1, 3))])
last = " ".join(str(i) for i in [size*3-2, size*3-1, size*3])
if args.crystal:
print("try not use this template")
do("cp ~/opt/create_project_in_crystal_template.in {}_multi.in".format(proteinName))
else:
# if args.membrane:
# print("try not use this template")
# do("cp ~/opt/create_membrane_protein_folding_project_in_template.in {}_multi.in".format(proteinName))
# else:
do("cp ~/opt/create_project_in_template.in {}_multi.in".format(proteinName))
with fileinput.FileInput("{}_multi.in".format(proteinName), inplace=True, backup='.bak') as file:
for line in file:
tmp = line.replace("ALPHA_CARBONS", alpha_carbons)
tmp = tmp.replace("BETA_ATOMS", beta_atoms)
tmp = tmp.replace("OXYGENS", oxygens)
tmp = tmp.replace("PROTEIN", proteinName)
tmp = tmp.replace("LAST", last)
if args.hybrid:
tmp = tmp.replace("fix_backbone_coeff.data", "fix_backbone_coeff_hybrid.data")
if args.membrane:
tmp = tmp.replace("fix_backbone_coeff.data", "fix_backbone_coeff_membrane.data")
if args.bias:
tmp = tmp.replace("#FIXBIAS", "fix qbias alpha_carbons qbias fix_qbias_coeff.data\nfix_modify qbias energy no\nvariable biasinge equal f_qbias\n")
do("cp ~/opt/fix_qbias_coeff.data .")
if args.rgbias:
tmp = tmp.replace("#FIXRG", "fix rg alpha_carbons spring/rg K_RG TARGET_RG")
# tmp = BETA_ATOMS
print(tmp, end='')
# print(alpha_carbons)
# create coord and data file
# if args.crystal:
#
# ## start with man made long string
# if not args.crystal:
# copy parameters
do("cp ~/opt/parameters/globular_parameters/* .")
# if args.globular or args.hybrid:
# do("cp ~/opt/parameters/globular_parameters/* .")
if args.membrane:
do("cp membrane_gamma.dat gamma.dat")
# task specific input
## frag memory generation
# if args.frag:
# do("cp ~/opt/database/cullpdb_pc80_* .")
# do("python2 ~/opt/script/prepFragsLAMW_index.py \
# cullpdb_pc80_res3.0_R1.0_d160504_chains29712 %s.fasta 20 0" % proteinName)
# if args.frag:
# do("cp ~/opt/database/cullpdb_pc80_* .")
# do("python2 ~/opt/MultCha_prepFrags_index_HO.py \
# cullpdb_pc80_res3.0_R1.0_d160504_chains29712 %s.fasta 20 0 95" % proteinName)
if args.frag:
# do("cp ~/opt/database/cullpdb_pc80_* .")
# do("python2 ~/opt/script/MultCha_prepFrags_index.py \
# cullpdb_pc80_res3.0_R1.0_d160504_chains29712 %s.fasta 20 1 9 > logfile" % proteinName)
do(f"cp ~/opt/database/cullpdb_pc80_* .")
do(f"python ~/openmmawsem/helperFunctions/MultCha_prepFrags_index.py \
cullpdb_pc80_res3.0_R1.0_d160504_chains29712 %s.fasta 20 1 9 > logfile" % proteinName)
check_and_correct_fragment_memory_back("frags.mem")