コード例 #1
0
ファイル: test_common.py プロジェクト: joshuagryphon/plastid
 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"))
コード例 #2
0
ファイル: test_common.py プロジェクト: zzygyx9119/plastid
 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"))
コード例 #3
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)
コード例 #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)
コード例 #5
0
ファイル: common.py プロジェクト: joshuagryphon/plastid
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)
コード例 #6
0
ファイル: tabix_bench.py プロジェクト: AndrewNguyenF3/pysam
def test_iterator_file_uncompressed():
    f = open("windows_small.bed")
    l = len( list( pysam.tabix_file_iterator( f, parser = pysam.asBed() )))
コード例 #7
0
def iterate_file_uncompressed(fn):
    with open(fn) as f:
        return len(list(pysam.tabix_file_iterator(f, parser=pysam.asBed())))
コード例 #8
0
ファイル: tabix_bench.py プロジェクト: msto/pysam
def iterate_file_uncompressed(fn):
    with open(fn) as f:
        return len(list(pysam.tabix_file_iterator(f, parser=pysam.asBed())))
コード例 #9
0
ファイル: tabix_bench.py プロジェクト: zzygyx9119/pysam
def test_iterator_file_uncompressed():
    f = open("windows_small.bed")
    l = len(list(pysam.tabix_file_iterator(f, parser=pysam.asBed())))