Ejemplo n.º 1
0
 def test_sam_query(self):
   reader = genomics_io.make_sam_reader(
       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)
Ejemplo n.º 3
0
 def test_downsampling(self, method, maybe_range, fraction, expected_n_reads):
   reader = genomics_io.make_sam_reader(
       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)
Ejemplo n.º 4
0
 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)
Ejemplo n.º 5
0
 def test_vcf_iterate(self):
   iterable = self.sites_reader.iterate()
   self.assertEqual(test_utils.iterable_len(iterable), 5)
 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)
Ejemplo n.º 7
0
 def test_bam_iterate(self):
   reader = genomics_io.make_sam_reader(
       test_utils.genomics_core_testdata('test.bam'), use_index=False)
   with reader:
     self.assertEqual(test_utils.iterable_len(reader.iterate()), 106)