Ejemplo n.º 1
0
 def setUp(self):
     out_fname = test_utils.test_tmpfile('output.gff')
     self.writer = gff_writer.GffWriter.to_file(out_fname,
                                                gff_pb2.GffHeader(),
                                                gff_pb2.GffWriterOptions())
     self.expected_gff_content = open(
         test_utils.genomics_core_testdata(
             'test_features.gff')).readlines()
     self.header = gff_pb2.GffHeader(
         sequence_regions=[ranges.make_range('ctg123', 0, 1497228)])
     self.record = gff_pb2.GffRecord(
         range=ranges.make_range('ctg123', 1000, 1100))
Ejemplo n.º 2
0
    def __init__(self, output_path, header):
        """Initializer for NativeGffWriter.

    Args:
      output_path: str. The path to which to write the GFF file.
      header: nucleus.genomics.v1.GffHeader. The header that defines all
        information germane to the constituent GFF records.
    """
        super(NativeGffWriter, self).__init__()
        writer_options = gff_pb2.GffWriterOptions()
        self._writer = gff_writer.GffWriter.to_file(output_path, header,
                                                    writer_options)
Ejemplo n.º 3
0
    def test_writing_canned_records(self):
        """Tests writing all the records that are 'canned' in our tfrecord file."""
        # This file is in TFRecord format.
        tfrecord_file = test_utils.genomics_core_testdata(
            'test_features.gff.tfrecord')
        writer_options = gff_pb2.GffWriterOptions()
        gff_records = list(
            io_utils.read_tfrecords(tfrecord_file, proto=gff_pb2.GffRecord))
        out_fname = test_utils.test_tmpfile('output.gff')
        with gff_writer.GffWriter.to_file(out_fname, self.header,
                                          writer_options) as writer:
            for record in gff_records:
                writer.write(record)

        with open(out_fname) as f:
            self.assertEqual(f.readlines(), self.expected_gff_content)