Mercurial > repos > iuc > ngsutils_bam_filter
comparison ngsutils/bed/__init__.py @ 2:7a68005de299 draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ngsutils commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
author | iuc |
---|---|
date | Sun, 27 Nov 2016 15:01:21 -0500 |
parents | 4e4e4093d65d |
children |
comparison
equal
deleted
inserted
replaced
1:8187a729d9f4 | 2:7a68005de299 |
---|---|
1 import os | 1 import os |
2 | |
2 import ngsutils.support.ngs_utils | 3 import ngsutils.support.ngs_utils |
3 import pysam | 4 import pysam |
4 | 5 |
5 | 6 |
6 class BedStreamer(object): | 7 class BedStreamer(object): |
29 cols.append('') | 30 cols.append('') |
30 | 31 |
31 return BedRegion(*cols) | 32 return BedRegion(*cols) |
32 except: | 33 except: |
33 raise StopIteration | 34 raise StopIteration |
34 | |
35 | 35 |
36 | 36 |
37 class BedFile(object): | 37 class BedFile(object): |
38 ''' | 38 ''' |
39 BED files are read in their entirety memory, in a series of bins. Each bin | 39 BED files are read in their entirety memory, in a series of bins. Each bin |
133 if (chrom, bin) in self._bins: | 133 if (chrom, bin) in self._bins: |
134 for region in self._bins[(chrom, bin)]: | 134 for region in self._bins[(chrom, bin)]: |
135 if strand and strand != region.strand: | 135 if strand and strand != region.strand: |
136 continue | 136 continue |
137 if start <= region.start <= end or start <= region.end <= end: | 137 if start <= region.start <= end or start <= region.end <= end: |
138 if not region in buf: | 138 if region not in buf: |
139 yield region | 139 yield region |
140 buf.add(region) | 140 buf.add(region) |
141 elif region.start < start and region.end > end: | 141 elif region.start < start and region.end > end: |
142 if not region in buf: | 142 if region not in buf: |
143 yield region | 143 yield region |
144 buf.add(region) | 144 buf.add(region) |
145 | 145 |
146 def tell(self): | 146 def tell(self): |
147 return self._tellpos | 147 return self._tellpos |