Example #1
0
 def test_tabix_multi_ps_open(self):
     with open(self.tabix_ref,"rb") as fh1:
         with open(self.tabix_ref,"rb") as fh2:
             ps1 = pysam.tabix_file_iterator(fh1,pysam.asTuple())
             ps2 = pysam.tabix_file_iterator(fh2,pysam.asTuple())
             reader = MockReader(ps1,ps2,self.tabix_ref,tabix=True)
             for expected, found in zip(reader,self.bed_lines+self.bed_lines):
                 self.assertEqual(expected.strip("\n"),found.strip("\n"))
Example #2
0
 def test_tabix_multi_ps_open(self):
     with open(self.tabix_ref, "rb") as fh1:
         with open(self.tabix_ref, "rb") as fh2:
             ps1 = pysam.tabix_file_iterator(fh1, pysam.asTuple())
             ps2 = pysam.tabix_file_iterator(fh2, pysam.asTuple())
             reader = MockReader(ps1, ps2, self.tabix_ref, tabix=True)
             for expected, found in zip(reader,
                                        self.bed_lines + self.bed_lines):
                 self.assertEqual(expected.strip("\n"), found.strip("\n"))
def load_gap_intervals(gap_file):
    if gap_file is None: return []
    logger.info("Loading the gaps in the genome from %s" % gap_file)
    with open(gap_file) as gap_file_fd:
        gap_intervals = [SVInterval(it.contig, it.start, it.end, it.name, "gap") for it in
                         pysam.tabix_file_iterator(gap_file_fd, parser=pysam.asBed())]
    return merge_intervals(gap_intervals)
Example #4
0
def load_gap_intervals(gap_file):
    if gap_file is None: return []
    logger.info("Loading the gaps in the genome from %s" % gap_file)
    with open(gap_file) as gap_file_fd:
        gap_intervals = [SVInterval(it.contig, it.start, it.end, it.name, "gap") for it in
                         pysam.tabix_file_iterator(gap_file_fd, parser=pysam.asBed())]
    return merge_intervals(gap_intervals)
Example #5
0
def _tabix_iteradaptor(stream):
    """Open `stream` as an iterator over a `tabix`_ file, returning raw strings from tabix data.
    
    Parameters
    ----------
    streams : open file-like, :class:`pysam.ctabix.tabix_file_iterator`
    
    Returns
    -------
    generator
        Generator of tab-delimited string records in `tabix`_ file
    """
    if not isinstance(stream,(pysam.ctabix.tabix_generic_iterator,
                              pysam.ctabix.tabix_file_iterator)
                      ):
        stream = pysam.tabix_file_iterator(stream,pysam.asTuple())
    
    return (str(X) for X in stream)
Example #6
0
def test_iterator_file_uncompressed():
    f = open("windows_small.bed")
    l = len( list( pysam.tabix_file_iterator( f, parser = pysam.asBed() )))
Example #7
0
def iterate_file_uncompressed(fn):
    with open(fn) as f:
        return len(list(pysam.tabix_file_iterator(f, parser=pysam.asBed())))
Example #8
0
def iterate_file_uncompressed(fn):
    with open(fn) as f:
        return len(list(pysam.tabix_file_iterator(f, parser=pysam.asBed())))
Example #9
0
def test_iterator_file_uncompressed():
    f = open("windows_small.bed")
    l = len(list(pysam.tabix_file_iterator(f, parser=pysam.asBed())))