Exemplo n.º 1
0
 def test_bad_create_args(self):
     with self.assertRaisesRegexp(ValueError,
                                  'multiple ones were found on 1'):
         fasta.InMemoryRefReader([
             ('1', 10, 'AC'),
             ('1', 20, 'AC'),
         ])
Exemplo n.º 2
0
 def test_query_edge_cases(self):
   reader = fasta.InMemoryRefReader([('1', 0, 'ACGT')])
   # Check that we can query the first base correctly.
   self.assertEqual(reader.query(ranges.make_range('1', 0, 1)), 'A')
   # Check that we can query the last base correctly.
   self.assertEqual(reader.query(ranges.make_range('1', 3, 4)), 'T')
   # Check that we can query the entire sequence correctly.
   self.assertEqual(reader.query(ranges.make_range('1', 0, 4)), 'ACGT')
Exemplo n.º 3
0
  def setUpClass(cls):
    cls.fasta_reader = fasta.RefFastaReader(
        test_utils.genomics_core_testdata('test.fasta'))

    cls.in_mem = fasta.InMemoryRefReader(
        [(contig.name, 0,
          cls.fasta_reader.query(
              ranges.make_range(contig.name, 0, contig.n_bases)))
         for contig in cls.fasta_reader.header.contigs])
Exemplo n.º 4
0
  def test_non_zero_start_query(self):
    bases = 'ACGTAACCGGTT'
    for start in range(len(bases)):
      reader = fasta.InMemoryRefReader([('1', start, bases[start:])])
      self.assertEqual(reader.header.contigs[0].name, '1')
      self.assertEqual(reader.header.contigs[0].n_bases, len(bases))

      # Check that our query operation works as expected with a start position.
      for end in range(start, len(bases)):
        self.assertEqual(reader.query(ranges.make_range('1', start, end)),
                         bases[start:end])
Exemplo n.º 5
0
 def test_bad_query_with_start(self, start, end):
     reader = fasta.InMemoryRefReader([('1', 10, 'ACGT')])
     with self.assertRaises(ValueError):
         reader.query(ranges.make_range('1', start, end))