-
Notifications
You must be signed in to change notification settings - Fork 0
/
box_lipid.py
executable file
·62 lines (51 loc) · 1.56 KB
/
box_lipid.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
import sys
import math
def box_lipid(inputfile):
f=file(inputfile)
i=0
P_x=[]
P_y=[]
P_z=[]
P_x_min_sum=0
P_x_max_sum=0
P_y_min_sum=0
P_y_max_sum=0
P_z_min_sum=0
P_z_max_sum=0
volume=0
P_number=0
while True:
line=f.readline()
if len(line)==0:
break
if (line[0:4]=='ATOM' or line[0:6]=='HETATM') and line[17:20]=='POP' and line[13:14]=='P':
i=i+1
P_x.append(float(line[30:38]))
P_y.append(float(line[38:46]))
P_z.append(float(line[46:54]))
P_number=i
P_x.sort()
P_y.sort()
P_z.sort()
i=0
while i<5:
P_x_min_sum=P_x_min_sum+P_x[i]
P_y_min_sum=P_y_min_sum+P_y[i]
P_z_min_sum=P_z_min_sum+P_z[i]
i=i+1
P_x.reverse()
P_y.reverse()
P_z.reverse()
i=0
while i<5:
P_x_max_sum=P_x_max_sum+P_x[i]
P_y_max_sum=P_y_max_sum+P_y[i]
P_z_max_sum=P_z_max_sum+P_z[i]
i=i+1
volume=(P_x_max_sum/5-P_x_min_sum/5)*(P_y_max_sum/5-P_y_min_sum/5)*(P_z_max_sum/5-P_z_min_sum/5)
print "\n lipid_box x max: "+str(P_x_max_sum/5)+"; x min: "+str(P_x_min_sum/5)
print "\n lipid_box y max: "+str(P_y_max_sum/5)+"; y min: "+str(P_y_min_sum/5)
print "\n lipid_box z min: "+str(P_z_max_sum/5)+"; z min: "+str(P_z_min_sum/5)
print "\n lipid_box volume: "+str(volume)+"; lipid_number: "+str(P_number)
print "\n volume/lipid: "+str(volume/P_number)
box_lipid(sys.argv[1])