def test_reserved_info_field_get_fn(self):
     info = variants_pb2.Variant().info
     values = ['C']
     struct_utils.set_string_field(info, 'AA', values)
     get_fn = vcf_constants.reserved_info_field_get_fn('AA')
     actual = get_fn(info, 'AA')
     self.assertEqual(actual, values[0])
Пример #2
0
 def test_reserved_info_field_get_fn(self):
   info = variants_pb2.Variant().info
   values = ['C']
   struct_utils.set_string_field(info, 'AA', values)
   get_fn = vcf_constants.reserved_info_field_get_fn('AA')
   actual = get_fn(info, 'AA')
   self.assertEqual(actual, values[0])
Пример #3
0
def get_info(variant, field_name, vcf_object=None):
  """Returns the value of the `field_name` INFO field.

  The `vcf_object` is used to determine the type of the resulting value. If it
  is a single value or a Flag, that single value will be returned. Otherwise,
  the list of values is returned.

  Args:
    variant: Variant proto. The Variant of interest.
    field_name: str. The name of the field to retrieve values from.
    vcf_object: (Optional) nucleus.io.vcf.Vcf{Reader,Writer}. If not None, the
      type of the field is inferred from the associated VcfReader or VcfWriter
      based on its name. Otherwise, the type is inferred if it is a reserved
      field.
  """
  if vcf_object is None:
    get_field_fn = vcf_constants.reserved_info_field_get_fn(field_name)
  else:
    get_field_fn = vcf_object.field_access_cache.info_field_get_fn(field_name)
  return get_field_fn(variant.info, field_name)
 def test_invalid_reserved_info_field_get_fn(self, field):
     with self.assertRaisesRegexp(ValueError,
                                  'Unknown reserved INFO field to get:'):
         vcf_constants.reserved_info_field_get_fn(field)
Пример #5
0
 def test_invalid_reserved_info_field_get_fn(self, field):
   with self.assertRaisesRegexp(ValueError,
                                'Unknown reserved INFO field to get:'):
     vcf_constants.reserved_info_field_get_fn(field)