示例#1
0
 def test_bad_create_args(self):
     with self.assertRaisesRegexp(ValueError,
                                  'multiple ones were found on 1'):
         fasta.InMemoryFastaReader([
             ('1', 10, 'AC'),
             ('1', 20, 'AC'),
         ])
示例#2
0
 def test_query_edge_cases(self):
     reader = fasta.InMemoryFastaReader([('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')
示例#3
0
  def setUpClass(cls):
    cls.fasta_reader = fasta.IndexedFastaReader(
        test_utils.genomics_core_testdata('test.fasta'))

    cls.in_mem = fasta.InMemoryFastaReader(
        [(contig.name, 0,
          cls.fasta_reader.query(
              ranges.make_range(contig.name, 0, contig.n_bases)))
         for contig in cls.fasta_reader.header.contigs])
示例#4
0
  def test_non_zero_start_query(self):
    bases = 'ACGTAACCGGTT'
    for start in range(len(bases)):
      reader = fasta.InMemoryFastaReader([('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])
示例#5
0
 def test_bad_query_with_start(self, start, end):
     reader = fasta.InMemoryFastaReader([('1', 10, 'ACGT')])
     with self.assertRaises(ValueError):
         reader.query(ranges.make_range('1', start, end))