-
Notifications
You must be signed in to change notification settings - Fork 8
/
integrateRama.py
executable file
·46 lines (35 loc) · 1.33 KB
/
integrateRama.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
#!/usr/bin/env python
################################################################################
# #
# This script will integrate a ramachandran plot within 2 ranges. #
# #
################################################################################
import sys, os, math
def printusage():
import sys
print 'integrateRama.py -i Ramachandran_datafile -phi NxN -psi NxN'
sys.exit()
if len(sys.argv) != 7:
printusage()
phi = [0,0]
psi = [0,0]
for x in range(len(sys.argv)):
if sys.argv[x] == '-i':
datafile = sys.argv[x+1]
elif sys.argv[x] == '-phi':
phi[0] = float(sys.argv[x+1].split('x')[0].strip())
phi[1] = float(sys.argv[x+1].split('x')[1].strip())
elif sys.argv[x] == '-psi':
psi[0] = float(sys.argv[x+1].split('x')[0].strip())
psi[1] = float(sys.argv[x+1].split('x')[1].strip())
sum = 0
data = open(datafile,'r')
for line in data:
if len(line.strip()) == 0:
continue
words = line.split()
for x in range(len(words)):
words[x] = float(words[x])
if words[0] > phi[0] and words[0] < phi[1] and words[1] > psi[0] and words[1] < psi[1]:
sum += words[2]
print sum * (phi[1]-phi[0]) * (psi[1]-psi[0])