Exemple #1
0
 def log_realigned_reads(self, region, reads):
     """Logs, if enabled, the realigned reads for region."""
     if self.enabled and self.config.emit_realigned_reads:
         path = self._file_for_region(region, self.realigned_reads_filename)
         with genomics_io.make_read_writer(path) as writer:
             for read in reads:
                 writer.write(read)
Exemple #2
0
  def test_make_read_writer_tfrecords(self):
    outfile = test_utils.test_tmpfile('test.tfrecord')
    writer = genomics_io.make_read_writer(outfile=outfile)

    # Test that the writer is a context manager and that we can write a read to
    # it.
    with writer:
      writer.write(self.read1)
      writer.write(self.read2)

    # Our output should have exactly one read in it.
    self.assertEqual([self.read1, self.read2],
                     list(
                         io_utils.read_tfrecords(outfile,
                                                 proto=reads_pb2.Read)))
Exemple #3
0
 def test_make_read_writer_bam_fails_with_not_implemented_error(self):
   with self.assertRaises(NotImplementedError):
     genomics_io.make_read_writer('test.bam', contigs=self.contigs)
Exemple #4
0
 def test_make_read_writer_bam_fails_without_contigs(self):
   with self.assertRaisesRegexp(ValueError, 'contigs'):
     genomics_io.make_read_writer('test.bam')