-
Notifications
You must be signed in to change notification settings - Fork 0
/
gt-sto2msi.py
138 lines (112 loc) · 2.75 KB
/
gt-sto2msi.py
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
#!/usr/bin/env python3
import sys
element = [
"H",
"H", "He",
"Li", "Be", " B", " C", " N", " O", " F", "Ne",
"Na", "Mg", "Al", "Si", " P", " S", "Cl", "Ar",
"Ca", "Sc", "Ti", " V", "Cr", "Mn", "Fe", "Co",
"Ni", "Cu", "Zn", "Ga", "Ge", "As", "Se", "Br", "Kr" ]
# using single bond radii www.iumsc.indiana.edu/helps/radii.html
'''
radii = {
'H': 0.5,
'D': 0.299,
'He': 1.0,
'Li': 0.5,
'Be': 1.06,
'B': 0.830,
'C': 0.767,
'N': 0.702,
'O': 1.0,
'F': 0.619,
'Ne': 1.0,
'Na': 0.5,
'Mg': 0.5,
'Al': 1.0,
'Si': 1.0,
'P': 1.088,
'S': 1.052,
'Cl': 1.023,
'Ar': 1.5
}
'''
radii = [
0.5,
0.299,
1.0,
0.5,
1.06,
0.830,
0.767,
0.702,
1.0,
0.619,
1.0,
0.5,
0.5,
1.0,
1.0,
1.088,
1.052,
1.023,
1.5
]
# Function to print atoms
def PrintAtoms ( sto ):
for row in sto:
d = int(row[0]) + 1
print (" (%s Atom " % d )
print (" (A C ACL \"%s %s\") " % ( row[1], element[int(row[1])] ))
# fprintf (output, " (A C ACL \"%d %s\") \n", Z = (Z == 1) ? 0 : Z, element[Z]);
print (" (A D XYZ (%s %s %s)) " % (row[3], row[4], row[5]))
print (" (A I Id %s) " % d)
print (" (A I ZOrder %s)" % d)
print (" ) ")
def PrintBonding (sto):
newsto = sto.copy()
i = 0
for sto1 in sto:
for sto2 in newsto:
if sto1[0] > sto2[0]:
distsq = (( float(sto1[3]) - float(sto2[3]) ) * ( float(sto1[3]) - float(sto2[3]) ) +
( float(sto1[4]) - float(sto2[4]) ) * ( float(sto1[4]) - float(sto2[4]) ) +
( float(sto1[5]) - float(sto2[5]) ) * ( float(sto1[5]) - float(sto2[5]) ))
radsumsq = ( ( radii[int(sto1[1])] + radii[int(sto2[1])] ) *
( radii[int(sto1[1])] + radii[int(sto2[1])] ))
if radsumsq > distsq:
print (" (%s Bond " % i )
z1 = int(sto1[0]) + 1
z2 = int(sto2[0]) + 1
print (" (A O Atom1 %s) " % z1 )
print (" (A O Atom2 %s) " % z2 )
print (" ) ")
i = i + 1
def grabSto ( fileln ):
i = 0
flag = 0
sto = []
for line in fileln:
if "Standard orientation:" in line:
sto = []
flag = 1
if flag == 1:
i = i + 1
if i < 6:
continue
elif "---" in line and i > 6 :
i = 0
flag = 0
else:
sto.append( line.split() )
return sto
print ("# MSI CERIUS2 DataModel File Version 3 0 ")
print ("(1 Model ")
print (" (A I Id 1)")
print (" (A C Label \"%s\")" % sys.argv[1] )
file = open ( sys.argv[1], 'r' )
sto = []
sto = grabSto ( file.readlines() )
PrintAtoms(sto)
PrintBonding(sto)
print (") ")