Mercurial > repos > greg > ideas
changeset 127:1c49e78e4ee7 draft
Deleted selected files
author | greg |
---|---|
date | Wed, 22 Nov 2017 08:36:59 -0500 |
parents | dcc642e255ec |
children | de93d8e8a096 |
files | create_window_positions_by_chrom.py |
diffstat | 1 files changed, 0 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- a/create_window_positions_by_chrom.py Tue Nov 21 14:46:55 2017 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -#!/usr/bin/env python -import argparse -import collections - -parser = argparse.ArgumentParser() -parser.add_argument('--input', dest='input', help='Input bed dataset') -parser.add_argument('--output', dest='output', help='Output window positions by chromosome dataset') - -args = parser.parse_args() - -chroms = collections.OrderedDict() - -with open(args.input, 'r') as fh: - for count, line in enumerate(fh): - line = line.strip() - if not line or line.startswith('#'): - # Skip blank lines and comments. - continue - items = line.split('\t') - chrom = items[0] - if count == 0: - # First window. - chroms[chrom] = [0, count+1] - elif chrom in chroms: - # Get the start / end tuple. - tup = chroms[chrom] - # Increment end by 1. - tup[1] += 1 - chroms[chrom] = tup - else: - # chrom not in chroms. - chroms[chrom] = [count, count+1] - -with open(args.output, 'w') as fh: - for k, v in chroms.items(): - fh.write('%s %d %d\n' % (k, v[0], v[1]))