def test_fastq_iterate(self): with fastq_reader.FastqReader.from_file(self.fastq, self.options) as reader: iterable = reader.iterate() self.assertIsInstance(iterable, clif_postproc.WrappedCppIterable) self.assertEqual(test_utils.iterable_len(iterable), 3) zreader = fastq_reader.FastqReader.from_file( self.zipped_fastq, fastq_pb2.FastqReaderOptions( compression_type=fastq_pb2.FastqReaderOptions.GZIP)) with zreader: ziterable = zreader.iterate() self.assertIsInstance(ziterable, clif_postproc.WrappedCppIterable) self.assertEqual(test_utils.iterable_len(ziterable), 3)
def test_bam_iterate(self): reader = sam_reader.SamReader.from_file( reads_path=self.bam, ref_path='', options=self.options) with reader: iterable = reader.iterate() self.assertIsInstance(iterable, clif_postproc.WrappedCppIterable) self.assertEqual(test_utils.iterable_len(iterable), 106)
def test_sam_query(self): reader = sam.SamReader(test_utils.genomics_core_testdata('test.bam')) expected = [(ranges.parse_literal('chr20:10,000,000-10,000,100'), 106), (ranges.parse_literal('chr20:10,000,000-10,000,000'), 45)] with reader: for interval, n_expected in expected: with reader.query(interval) as iterable: self.assertEqual(test_utils.iterable_len(iterable), n_expected)
def test_bam_query(self): reader = sam_reader.SamReader.from_file(self.bam, self.indexed_options) expected = [(ranges.parse_literal('chr20:10,000,000-10,000,100'), 106), (ranges.parse_literal('chr20:10,000,000-10,000,000'), 45)] with reader: for interval, n_expected in expected: with reader.query(interval) as iterable: self.assertIsInstance(iterable, clif_postproc.WrappedCppIterable) self.assertEqual(test_utils.iterable_len(iterable), n_expected)
def test_sam_query(self): reader = sam.SamReader( test_utils.genomics_core_testdata('test.bam')) expected = [(ranges.parse_literal('chr20:10,000,000-10,000,100'), 106), (ranges.parse_literal('chr20:10,000,000-10,000,000'), 45)] with reader: for interval, n_expected in expected: with reader.query(interval) as iterable: self.assertEqual(test_utils.iterable_len(iterable), n_expected)
def test_bam_query(self): reader = sam_reader.SamReader.from_file( reads_path=self.bam, ref_path='', options=self.options) expected = [(ranges.parse_literal('chr20:10,000,000-10,000,100'), 106), (ranges.parse_literal('chr20:10,000,000-10,000,000'), 45)] with reader: for interval, n_expected in expected: with reader.query(interval) as iterable: self.assertIsInstance(iterable, clif_postproc.WrappedCppIterable) self.assertEqual(test_utils.iterable_len(iterable), n_expected)
def test_downsampling(self, method, maybe_range, fraction, expected_n_reads): reader = sam.SamReader( test_utils.genomics_core_testdata('test.bam'), downsample_fraction=fraction, random_seed=12345) with reader: if method == 'iterate': reads_iter = reader.iterate() elif method == 'query': reads_iter = reader.query(ranges.parse_literal(maybe_range)) else: self.fail('Unexpected method ' + str(method)) self.assertEqual(test_utils.iterable_len(reads_iter), expected_n_reads)
def test_downsampling(self, method, maybe_range, fraction, expected_n_reads): reader = sam.SamReader( test_utils.genomics_core_testdata('test.bam'), downsample_fraction=fraction, random_seed=12345) with reader: if method == 'iterate': reads_iter = reader.iterate() elif method == 'query': reads_iter = reader.query(ranges.parse_literal(maybe_range)) else: self.fail('Unexpected method', method) self.assertEqual(test_utils.iterable_len(reads_iter), expected_n_reads)
def test_vcf_query(self): range1 = ranges.parse_literal('chr3:100,000-500,000') iterable = self.samples_reader.query(range1) self.assertEqual(test_utils.iterable_len(iterable), 4)
def test_vcf_iterate(self): iterable = self.sites_reader.iterate() self.assertEqual(test_utils.iterable_len(iterable), 5)
def test_fastq_iterate(self, filename): path = test_utils.genomics_core_testdata(filename) with fastq_reader.FastqReader.from_file(path, self.options) as reader: iterable = reader.iterate() self.assertIsInstance(iterable, clif_postproc.WrappedCppIterable) self.assertEqual(test_utils.iterable_len(iterable), 4)
def test_bam_iterate(self): reader = sam.SamReader(test_utils.genomics_core_testdata('test.bam'), use_index=False) with reader: self.assertEqual(test_utils.iterable_len(reader.iterate()), 106)
def test_sam_iterate(self): reader = sam.SamReader(test_utils.genomics_core_testdata('test.sam')) with reader: self.assertEqual(test_utils.iterable_len(reader.iterate()), 6)
def test_query(self, filename, has_embedded_ref): with self._make_reader(filename, has_embedded_ref) as reader: for interval, n_expected in [('chr1:1-100', 3), ('chr2:1-121', 0)]: with reader.query(ranges.parse_literal(interval)) as iterable: self.assertEqual(test_utils.iterable_len(iterable), n_expected)
def test_bam_iterate(self): reader = sam_reader.SamReader.from_file(self.bam, self.options) with reader: iterable = reader.iterate() self.assertIsInstance(iterable, clif_postproc.WrappedCppIterable) self.assertEqual(test_utils.iterable_len(iterable), 106)
def test_bam_iterate(self): reader = sam.SamReader( test_utils.genomics_core_testdata('test.bam'), use_index=False) with reader: self.assertEqual(test_utils.iterable_len(reader.iterate()), 106)