forked from fryzjergda/simrna_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrafl_extract_lowestE_frame.py
executable file
·54 lines (36 loc) · 1.12 KB
/
trafl_extract_lowestE_frame.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
#!/usr/bin/python
import sys, os
if(len(sys.argv) < 2):
print >>sys.stderr, "usage: trafl_finds_lowestE_frame.py file.trafl"
sys.exit(1)
inpfilename = sys.argv[1]
if(inpfilename[-6:]!=".trafl"):
print >>sys.stderr, "extension of input file: "+inpfilename+" has to be .trafl"
sys.exit(1)
if(os.path.exists(inpfilename) == False):
print >>sys.stderr, "specified file: "+inpfilename+" doesn't exist"
sys.exit(1)
counter = 1
lowest_frame = 1
lowest_energy = 1000000.0
inpfile = open(inpfilename)
curr_line = inpfile.readline()
while(curr_line):
if(len(curr_line) < 100):
splitted_line = curr_line.split()
curr_energy = float(splitted_line[-2])
if(lowest_energy > curr_energy):
lowest_energy = curr_energy
lowest_frame = counter
lowestE_header = curr_line
lowestE_coords = inpfile.readline()
counter += 1
curr_line = inpfile.readline()
inpfile.close()
print lowest_frame, lowest_energy
outfilename = inpfilename.replace(".trafl","_minE.trafl")
print outfilename
outfile = open(outfilename,"w")
print >>outfile, lowestE_header,
print >>outfile, lowestE_coords,
outfile.close()