def getVariantId(self, gaVariant): """ Returns an ID string suitable for the specified GA Variant object in this variant set. """ compoundId = datamodel.VariantCompoundId( self.getCompoundId(), gaVariant.referenceName, gaVariant.start) return str(compoundId)
def getVariantId(self, gaVariant): """ Produces a variant ID for a variant annotated within this variant annotation set. :param gaVariant: protocol.Variant :return: compoundId String """ md5 = self.hashVariant(gaVariant) compoundId = datamodel.VariantCompoundId( self._variantSetId, gaVariant.referenceName, gaVariant.start, md5) return str(compoundId)
def testGetVariant(self): variantSet = self._gaObject for reference_name in self._reference_names: refnameVariants = self._getPyvcfVariants(reference_name) for variant in refnameVariants: # positive test: get the expected variant md5 = self._hashVariant(variant) compoundId = datamodel.VariantCompoundId( variantSet.getCompoundId(), reference_name, str(variant.start), md5) gotVariant = variantSet.getVariant(compoundId) self.assertEqual(str(compoundId), gotVariant.id) # negative test: change start position to past variant wrongStart = variant.end compoundId = datamodel.VariantCompoundId( variantSet.getCompoundId(), reference_name, str(wrongStart), md5) try: gotVariant = variantSet.getVariant(compoundId) self.assertNotEqual(variant.start, gotVariant.start) except exceptions.ObjectNotFoundException: pass # negative test: change reference name compoundId = datamodel.VariantCompoundId( variantSet.getCompoundId(), "wrong reference name", str(variant.start), md5) with self.assertRaises(exceptions.ObjectNotFoundException): variantSet.getVariant(compoundId) # negative test: change hash compoundId = datamodel.VariantCompoundId( variantSet.getCompoundId(), reference_name, str(variant.start), "wrong hash") with self.assertRaises(exceptions.ObjectNotFoundException): variantSet.getVariant(compoundId)
def testVariant(self): referenceName = "referenceName" start = "start" variantSet = self.getVariantSet() dataset = variantSet.getParentContainer() cid = datamodel.VariantCompoundId(variantSet.getCompoundId(), referenceName, start) self.assertRaises(ValueError, datamodel.VariantCompoundId, variantSet.getCompoundId()) self.assertRaises(ValueError, datamodel.VariantCompoundId, variantSet.getCompoundId(), referenceName) self.assertEqual(cid.dataset, dataset.getLocalId()) self.assertEqual(cid.variantSet, variantSet.getLocalId()) self.assertEqual(cid.referenceName, referenceName) self.assertEqual(cid.start, start) self.assertEqual(cid.datasetId, dataset.getId()) self.assertEqual(cid.variantSetId, variantSet.getId())