代码如下:
#x轴
grep ^ATOM $1 | awk ‘{print $7}’| sort -n |sed -n ‘1p;$p’
#y轴
grep ^ATOM $1 | awk ‘{print $8}’| sort -n |sed -n ‘1p;$p’
#z轴
grep ^ATOM $1 | awk ‘{print $9}’| sort -n |sed -n ‘1p;$p’
代码如下:
#-*-coding:utf-8-*-
x=[]
y=[]
z=[]
for i in open('file.pdb','r'):
if i.startswith('ATOM'):
new=i.split()
x.append(float(new[6]))
y.append(float(new[7]))
z.append(float(new[8]))
else:
pass
print('长:'+str(max(x)-min(x)))
print('宽:'+str(max(y)-min(y)))
print('高:'+str(max(z)-min(z)))