def main(argv): if len(argv) != 3: print('Usage: %s <input_vcf> <output_vcf>' % argv[0]) sys.exit(-1) in_vcf = argv[1] out_vcf = argv[2] with vcf.VcfReader(in_vcf) as reader: if 'AD' in [info.id for info in reader.header.infos]: print('%s already contains AD field.' % in_vcf) sys.exit(-1) out_header = reader.header out_header.infos.extend([vcf_constants.reserved_info_field('AD')]) with vcf.VcfWriter(out_vcf, header=out_header) as writer: for variant in reader: variant_utils.set_info(variant, 'AD', get_variant_ad(variant), writer) writer.write(variant)
def test_invalid_get_reserved_info(self, field_id): with self.assertRaisesRegexp(ValueError, 'No reserved field with id'): vcf_constants.reserved_info_field(field_id)
def test_get_reserved_info(self, field_id): info = vcf_constants.reserved_info_field(field_id) self.assertIsInstance(info, variants_pb2.VcfInfo) self.assertEqual(info.id, field_id)