mark the example submission rule files as being raw, so the escapes dont get confused
[htsworkflow.git] / scripts / htsw-elandseq
1 #!/usr/bin/env python
2 import optparse
3 import os
4 import sys
5
6 from htsworkflow.pipelines.eland import extract_eland_sequence
7
8 def make_parser():
9   usage = "usage: %prog [options] infile [outfile]"
10
11   parser = optparse.OptionParser(usage)
12   parser.add_option("-e", "--extract", dest="slice",
13     default=":",
14     help="provide a python slice operator to select a portion of an eland file")
15   return parser
16
17 def main(argv):
18   parser = make_parser()
19
20   (opt, args) = parser.parse_args(argv)
21
22   if len(args) not in (0, 1, 2):
23     parser.error('incorrect number of arguments')
24
25   # get our slice coordinates
26   start, end = opt.slice.split(':')
27   if len(start) > 0:
28     start = int(start)
29   else:
30     start = None
31   if len(end) > 0:
32     end = int(end)
33   else:
34     end = None
35
36   # open infile
37   if len(args) > 0:
38     instream = open(args[0],'r')
39   else:
40     instream = sys.stdin
41
42   if len(args) > 1:
43     outstream = open(args[1],'w')
44   else:
45     outstream = sys.stdout
46
47   extract_eland_sequence(instream, outstream, start, end)
48
49 if __name__ == "__main__":
50     sys.exit(main(sys.argv[1:]))
51