--- /dev/null
+#!/usr/bin/env python
+import optparse
+import os
+import sys
+
+def extract_sequence(instream, outstream, start, end):
+ for line in instream:
+ record = line.split()
+ if len(record) > 1:
+ result = [record[0], record[1][start:end]]
+ else:
+ result = [record[0][start:end]]
+ outstream.write("\t".join(result))
+ outstream.write(os.linesep)
+
+
+def make_parser():
+ usage = "usage: %prog [options] infile [outfile]"
+
+ parser = optparse.OptionParser(usage)
+ parser.add_option("-e", "--extract", dest="slice",
+ default=":",
+ help="provide a python slice operator to select a portion of an eland file")
+ return parser
+
+def main(argv):
+ parser = make_parser()
+
+ (opt, args) = parser.parse_args(argv)
+
+ if len(args) not in (0, 1, 2):
+ parser.error('incorrect number of arguments')
+
+ # get our slice coordinates
+ start, end = opt.slice.split(':')
+ if len(start) > 0:
+ start = int(start)
+ else:
+ start = None
+ if len(end) > 0:
+ end = int(end)
+ else:
+ end = None
+
+ # open infile
+ if len(args) > 0:
+ instream = open(args[0],'r')
+ else:
+ instream = sys.stdin
+
+ if len(args) > 1:
+ outstream = open(args[1],'w')
+ else:
+ outstream = sys.stdout
+
+ extract_sequence(instream, outstream, start, end)
+
+if __name__ == "__main__":
+ sys.exit(main(sys.argv[1:]))
+