annotate tools/filters/catWrapper.py @ 0:9071e359b9a3

Uploaded
author xuebing
date Fri, 09 Mar 2012 19:37:19 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1 #!/usr/bin/env python
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2 #By, Guruprasad Ananda.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
4 from galaxy import eggs
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
5 import sys, os
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
6
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
7 def stop_err(msg):
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
8 sys.stderr.write(msg)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
9 sys.exit()
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
10
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
11 def main():
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
12 outfile = sys.argv[1]
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
13 infile = sys.argv[2]
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
14
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
15 try:
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
16 fout = open(sys.argv[1],'w')
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
17 except:
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
18 stop_err("Output file cannot be opened for writing.")
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
19
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
20 try:
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
21 fin = open(sys.argv[2],'r')
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
22 except:
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
23 stop_err("Input file cannot be opened for reading.")
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
24
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
25 if len(sys.argv) < 4:
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
26 os.system("cp %s %s" %(infile,outfile))
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
27 sys.exit()
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
28
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
29 cmdline = "cat %s " %(infile)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
30 for inp in sys.argv[3:]:
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
31 cmdline = cmdline + inp + " "
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
32 cmdline = cmdline + ">" + outfile
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
33 try:
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
34 os.system(cmdline)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
35 except:
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
36 stop_err("Error encountered with cat.")
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
37
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
38 if __name__ == "__main__": main()