-
Notifications
You must be signed in to change notification settings - Fork 4
/
mergeAllStats.py
executable file
·64 lines (54 loc) · 1.66 KB
/
mergeAllStats.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
#!/bin/env python
'''
mergeAllStats.py
Copyright (c) 2015, David Edwards, Bernie Pope, Kat Holt
All rights reserved. (see README.txt for more details)
merges the general statistics for two separate runs of the pipe.
example:
python mergeAllStats.py <new_AllStats.txt> <mergeDirectory>
Created: 23/10/2012
Modified: 29/10/2013 for mergeAllStats (from mergeStats)
author: David Edwards
'''
import sys
from pipe_utils import splitPath
inFileName = sys.argv[1]
(inPrefix, inName, inExt) = splitPath(inFileName)
mergeFileName = sys.argv[2] + inName + inExt
outfile_allStats_name_user = sys.argv[2] + inName + "_user" + inExt
output = ""
# Combine the two sets
# First get the merge run list
mergeFile = open(mergeFileName, "r")
for line in mergeFile:
output += line
mergeFile.close()
# then add the new run AllStats.txt leaving off the header
inFile = open(inFileName)
for line in inFile:
items = line.split()
if items[0] != "Isolate":
output += line
inFile.close()
mergeFile = open(mergeFileName, "w")
mergeFile.writelines(output)
mergeFile.close()
out_lines = []
infile_allStats = open(mergeFileName,"r")
test_line = infile_allStats.readline()
entries = test_line.split()
for i in range(0, len(entries)):
out_lines.append([entries[i]])
for line in infile_allStats:
entries = line.split()
for i in range(0, len(entries)):
out_lines[i].append(entries[i])
infile_allStats.close()
output = ""
for i in range(0, len(out_lines)):
for j in range(0, len(out_lines[i])-1):
output += out_lines[i][j] + "\t"
output += out_lines[i][-1] + "\n"
outfile_allStats_user = open(outfile_allStats_name_user,"w")
outfile_allStats_user.write(output)
outfile_allStats_user.close()