-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtorsion.py
More file actions
123 lines (100 loc) · 5.4 KB
/
Copy pathtorsion.py
File metadata and controls
123 lines (100 loc) · 5.4 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
#! /usr/bin/env python
###########################
##### This is an ugly script to generate conformations spaced from 10 degrees using tleap and
##### parse the generated mol2 files to gaussian input files.
##### please pick your atoms names from the lists at the end of this script and put the right residus name ( I said it was ugly ... )
##### This script would normally crach if anything is wrong but preview your mol2 files before running long gaussians calculations...
############################
import os
import subprocess
import argparse
def main(list_of_torsions):
list_of_key={}
tleap_input_file=open('tleap.in', 'w')
inputfile=open(inputmol2, 'r')
inputfiliecontent=inputfile.readlines()
for l in range(len(inputfiliecontent)):
if res_name in inputfiliecontent[l] :
list_of_key.update({inputfiliecontent[l].split()[1]: inputfiliecontent[l].split()[0]})
print (list_of_key)
list_of_atoms=[]
for torsion in list_of_torsions:
list_of_atoms.append([list_of_key[torsion.replace("\"","").split()[0]],list_of_key[torsion.replace("\"","").split()[1]], \
list_of_key[torsion.replace("\"","").split()[2]],list_of_key[torsion.replace("\"","").split()[3]]])
print(list_of_atoms)
inputfile.close()
tleap_input_file.writelines(['source leaprc.protein.ff14SB \n' , 'm = loadmol2 %s \n' %(inputmol2) , 'relax m \n' ])
print ('Shall we begin ?')
for bond in range(len(list_of_torsions)) :
for angle in range(-180,+180,10) :
tleap_input_file.writelines( [ 'impose m { 1 } { { %s %s } }\n' %(list_of_torsions[bond] , angle) , 'savemol2 m %s_%s.mol2 1\n' %(torsion_names[bond] , angle)] )
tleap_input_file.writelines(['quit' ])
tleap_input_file.close()
print (' tleap -f tleap.in')
subprocess.call('tleap -f tleap.in' ,shell=True )
for finp in os.listdir('./') :
if finp[-4:]=='mol2' and finp[:3] in ['PHI', 'PSI' , 'CHI']:
fi=open(finp, 'r')
fo=open('%s' %(finp[:-4]+'gau'), 'w')
fo.write('--Link1-- \n%%RWF=%s\n%%NoSave\n%%chk=%s \n#P b3lyp/6-31G* Opt=(ModRedundant,MaxCycle=400) Freq SCF=(Conver=6,MaxCycle=400) Pop=NoMBS\n \nparamfit run\n \n%s %s \n' %(finp[:-5],finp[:-5],charge,multiplicity))
while 'ATOM' not in fi.readline() : continue
i=True
while i==True :
line=fi.readline().split()
if 'TRIPOS' not in line[0] :
#lineout=line[1][0]+'-' + line[5] + '-' + line[8] + ' ' + line[2] + ' ' + line[3] + ' ' + line[4] + '\n'
lineout=line[1][0]+ ' ' + line[2] + ' ' + line[3] + ' ' + line[4] + '\n'
fo.write(lineout)
else:
i=False
fo.write('\n')
numb=torsion_names.index(finp[0:4].replace('_',''))
listdih=list_of_atoms[numb]
#fo.write('F'+str(list_of_atoms[numb][0])+'\nF'+str(list_of_atoms[numb][1])+'\nF'+str(list_of_atoms[numb][2])+'\nF'+str(list_of_atoms[numb][3])+'\n')
fo.write('D ' + str(listdih[0]) +' '+ str(listdih[1])+ ' '+ str(listdih[2])+ ' '+str(listdih[3])+ ' F\n')
fo.close()
fi.close
if __name__ =='__main__':
PHI_ATOMS = '"C10" "N" "CA" "C"'
PSI_ATOMS = '"N" "CA" "C" "N1"'
CHI1_ATOMS = ['"N" "CA" "CB" "CC"',
'"N" "CA" "CB" "CG1"',
'"N" "CA" "CB" "S"',
'"N" "CA" "CB" "OG"',
'"N" "CA" "CB" "OG1"']
CHI2_ATOMS = ['"CA" "CB" "CC" "CD"',
'"CA" "CB" "S" "CC"',
'"CA" "CB" "CG1" "CD1"',
'"CA" "CB" "CG" "OD1"',
'"CA" "CB" "CG" "ND1"',
'"CA" "CB" "CG" "SD"']
CHI3_ATOMS = ['"CB" "S" "CC" "C"',
'"CB" "CC" "CD" "CE"',
'"CB" "CG" "CD" "OE1"',
'"CB" "CG" "SD" "CE"']
CHI4_ATOMS = ['"CG" "CD" "NE" "CZ"',
'"S" "CC" "CD" "CE"',
'"CC" "CD" "CE" "NZ"']
CHI5_ATOMS = '"CD" "CE" "NZ" "NY"'
res_name=' NXS'
list_of_torsions = [PHI_ATOMS, PSI_ATOMS, CHI1_ATOMS[2], CHI2_ATOMS[1] ,CHI3_ATOMS[0] ,CHI4_ATOMS[1] ]
torsion_names =[ 'PHI' , 'PSI' , 'CHI1', 'CHI2' , 'CHI3' ,'CHI4' ]
'''
res_name=' PGR'
lis 2_-20.gau-runonphase9.bsh t_of_torsions = [PHI_ATOMS, PSI_ATOMS, CHI1_ATOMS[0] ]
torsion_names =[ 'PHI' , 'PSI' , 'CHI1']
res_name=' LNR'
list_of_torsions = [PHI_ATOMS, PSI_ATOMS, CHI1_ATOMS[0], CHI2_ATOMS[0] ,CHI3_ATOMS[1] ,CHI4_ATOMS[2] , CHI5_ATOMS]
torsion_names =[ 'PHI' , 'PSI' , 'CHI1', 'CHI2' , 'CHI3', 'CHI4', 'CHI5' ]
res_name=' CLI'
list_of_torsions = [PHI_ATOMS, PSI_ATOMS, CHI1_ATOMS[0], CHI2_ATOMS[0] ,CHI3_ATOMS[1] ,CHI4_ATOMS[2] ]
torsion_names =[ 'PHI' , 'PSI' , 'CHI1', 'CHI2' , 'CHI3', 'CHI4' ]
res_name=' CPS'
list_of_torsions = [PHI_ATOMS, PSI_ATOMS, CHI1_ATOMS[0], CHI2_ATOMS[0] ,CHI3_ATOMS[1] ]
torsion_names =[ 'PHI' , 'PSI' , 'CHI1', 'CHI2' , 'CHI3' ]
'''
charge=0
multiplicity=1
inputmol2='Mol-sm_m1-c1.mol2'
print(list_of_torsions)
main(list_of_torsions)