Exemple #1
0
 def _parseTagValue(cls, value):
     if len(value) > 1:
         return [protocol.getValueFromValue(v) for v in value]
     elif isinstance(
             protocol.getValueFromValue(value[0]), (int, float, long)):
         return protocol.getValueFromValue(value[0])
     else:
         return str(
             protocol.getValueFromValue(value[0])).encode(cls._encoding)
Exemple #2
0
 def testGetValueFromValue(self):
     with self.assertRaises(TypeError):
         protocol.getValueFromValue(5)
     val = common.AttributeValue()
     with self.assertRaises(AttributeError):
         protocol.getValueFromValue(val)
     read = protocol.ReadAlignment()
     expected = "1"
     read.attributes.attr['key'].values.add().string_value = expected
     tag, value = read.attributes.attr.items()[0]
     result = protocol.getValueFromValue(value.values[0])
     self.assertEquals(result, expected)
 def testGetValueFromValue(self):
     with self.assertRaises(TypeError):
         protocol.getValueFromValue(5)
     val = common.AttributeValue()
     with self.assertRaises(AttributeError):
         protocol.getValueFromValue(val)
     read = protocol.ReadAlignment()
     expected = "1"
     read.attributes.attr['key'].values.add().string_value = expected
     tag, value = read.attributes.attr.items()[0]
     result = protocol.getValueFromValue(value.values[0])
     self.assertEquals(result, expected)
Exemple #4
0
 def _parseTagValue(cls, tag, value):
     if tag[0] in cls._tagReservedFieldPrefixes:
         # user reserved fields... not really sure what to do here
         return protocol.getValueFromValue(value.values[0]) \
             .encode(cls._encoding)
     elif tag in cls._tagIntegerFields:
         return int(protocol.getValueFromValue(value.values[0]))
     elif tag in cls._tagStringFields:
         return protocol.getValueFromValue(value.values[0]) \
             .encode(cls._encoding)
     elif tag in cls._tagIntegerArrayFields:
         return [int(integerString) for integerString in value]
     else:
         raise SamException("unrecognized tag '{}'".format(tag))
Exemple #5
0
 def _assertEquivalentGaVCFValues(gaValue, pyvcfValue):
     compareValue = protocol.getValueFromValue(gaValue)
     if isinstance(pyvcfValue, str):
         self.assertEqual(compareValue, pyvcfValue)
     elif isinstance(pyvcfValue, (int, bool)):
         self.assertEqual(compareValue, pyvcfValue)
     elif isinstance(pyvcfValue, float):
         self.assertAlmostEqual(float(compareValue), float(pyvcfValue))
     elif pyvcfValue is None:
         self.assertEqual(compareValue, ".")
     else:
         raise Exception(key, (" values are inconsistent",
                               "between ga4ghObject and pyvcf!"))
Exemple #6
0
 def _assertEquivalentGaVCFValues(gaValue, pyvcfValue):
     compareValue = protocol.getValueFromValue(gaValue)
     if isinstance(pyvcfValue, str):
         self.assertEqual(compareValue, pyvcfValue)
     elif isinstance(pyvcfValue, (int, bool)):
         self.assertEqual(compareValue, pyvcfValue)
     elif isinstance(pyvcfValue, float):
         self.assertAlmostEqual(float(compareValue), float(pyvcfValue))
     elif pyvcfValue is None:
         self.assertEqual(compareValue, ".")
     else:
         raise Exception(key, (
             " values are inconsistent",
             "between ga4ghObject and pyvcf!"))
Exemple #7
0
 def getDictFromMessageMap(self, messageMap):
     return dict([(k, [protocol.getValueFromValue(x) for x in v.values])
                  for (k, v) in messageMap._values.items()])
Exemple #8
0
 def getDictFromMessageMap(self, messageMap):
     return dict([
         (k, [protocol.getValueFromValue(x) for x in v.values])
         for (k, v) in messageMap._values.items()])