Mercurial > repos > iuc > resize_coordinate_window
comparison resize_coordinate_window.py @ 4:4eb3cc1f8466 draft default tip
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/resize_coordinate_window commit d357611d8d49631f0eb7c5e022e80cb4c9483308"
author | iuc |
---|---|
date | Wed, 11 Dec 2019 18:06:42 -0500 |
parents | 9ba78e8985dc |
children |
comparison
equal
deleted
inserted
replaced
3:9ba78e8985dc | 4:4eb3cc1f8466 |
---|---|
1 | |
2 | |
1 import argparse | 3 import argparse |
2 import fileinput | 4 import fileinput |
3 import sys | 5 import sys |
4 | 6 |
5 # Maximum value of a signed 32 bit integer (2**31 - 1). | 7 # Maximum value of a signed 32 bit integer (2**31 - 1). |
6 MAX_CHROM_LEN = 2147483647 | 8 MAX_CHROM_LEN = 2147483647 |
7 | 9 |
8 | 10 |
9 def stop_err(msg): | 11 def stop_err(msg): |
10 sys.stderr.write(msg) | 12 sys.exit(msg) |
11 sys.exit(1) | |
12 | 13 |
13 | 14 |
14 parser = argparse.ArgumentParser() | 15 parser = argparse.ArgumentParser() |
15 parser.add_argument('--input', dest='input', help="Input dataset") | 16 parser.add_argument('--input', dest='input', help="Input dataset") |
16 parser.add_argument('--start_coordinate', dest='start_coordinate', type=int, help='Chromosome start coordinate, either 0 or 1.') | 17 parser.add_argument('--start_coordinate', dest='start_coordinate', type=int, help='Chromosome start coordinate, either 0 or 1.') |
21 parser.add_argument('--region_boundaries', dest='region_boundaries', help="Option for handling region boundaries") | 22 parser.add_argument('--region_boundaries', dest='region_boundaries', help="Option for handling region boundaries") |
22 parser.add_argument('--output', dest='output', help="Output dataset") | 23 parser.add_argument('--output', dest='output', help="Output dataset") |
23 args = parser.parse_args() | 24 args = parser.parse_args() |
24 | 25 |
25 extend_existing = args.extend_existing == 'existing' | 26 extend_existing = args.extend_existing == 'existing' |
26 out = open(args.output, 'wb') | 27 out = open(args.output, 'w') |
27 | 28 |
28 chrom_start = int(args.start_coordinate) | 29 chrom_start = int(args.start_coordinate) |
29 chrom_lens = dict() | 30 chrom_lens = dict() |
30 # Determine the length of each chromosome and add it to the chrom_lens dictionary. | 31 # Determine the length of each chromosome and add it to the chrom_lens dictionary. |
31 len_file_missing = False | 32 len_file_missing = False |
82 new_line = '\t'.join([chrom, items[1], items[2], str(new_start), str(new_end), items[5], items[6], items[7], items[8]]) | 83 new_line = '\t'.join([chrom, items[1], items[2], str(new_start), str(new_end), items[5], items[6], items[7], items[8]]) |
83 out.write(new_line) | 84 out.write(new_line) |
84 out.close() | 85 out.close() |
85 | 86 |
86 if len_file_error is not None: | 87 if len_file_error is not None: |
87 print "All chrom lengths set to %d, error in chrom len file: %s" % (MAX_CHROM_LEN, len_file_error) | 88 print("All chrom lengths set to %d, error in chrom len file: %s" % (MAX_CHROM_LEN, len_file_error)) |
88 if len_file_missing: | 89 if len_file_missing: |
89 print "All chrom lengths set to %d, chrom len files are not installed." % MAX_CHROM_LEN | 90 print("All chrom lengths set to %d, chrom len files are not installed." % MAX_CHROM_LEN) |