Beispiel #1
0
 def generateVariantAnnotation(self, variant):
     """
     Generate a random variant annotation based on a given variant.
     This generator should be seeded with a value that is unique to the
     variant so that the same annotation will always be produced regardless
     of the order it is generated in.
     """
     # To make this reproducible, make a seed based on this
     # specific variant.
     seed = self._randomSeed + variant.start + variant.end
     randomNumberGenerator = random.Random()
     randomNumberGenerator.seed(seed)
     ann = protocol.VariantAnnotation()
     ann.variantAnnotationSetId = str(self.getCompoundId())
     ann.variantId = variant.id
     ann.start = variant.start
     ann.end = variant.end
     ann.createDateTime = self._creationTime
     # make a transcript effect for each alternate base element
     # multiplied by a random integer (0,5)
     ann.transcriptEffects = []
     for base in variant.alternateBases * (
             randomNumberGenerator.randint(0, 5)):
         ann.transcriptEffects.append(self.generateTranscriptEffect(
             ann, base, randomNumberGenerator))
     ann.id = self.getVariantAnnotationId(variant, ann)
     return ann
 def testHashVariantAnnotation(self):
     annotation = protocol.VariantAnnotation()
     variant = protocol.Variant()
     expected = 'bec63dc7c876bb3c7b71422203b101d1'
     hashed = self._variantAnnotationSet.hashVariantAnnotation(
         variant, annotation)
     self.assertEqual(hashed, expected)
Beispiel #3
0
 def testHashVariantAnnotation(self):
     annotation = protocol.VariantAnnotation()
     variant = protocol.Variant()
     expected = hashlib.md5('\t()\t[]\t').hexdigest()
     hashed = self._variantAnnotationSet.hashVariantAnnotation(
         variant, annotation)
     self.assertEqual(hashed, expected)
Beispiel #4
0
 def _createGaVariantAnnotation(self):
     """
     Convenience method to set the common fields in a GA VariantAnnotation
     object from this variant set.
     """
     ret = protocol.VariantAnnotation()
     ret.created = self._creationTime
     ret.updated = self._updatedTime
     ret.variantAnnotationSetId = self.getId()
     return ret
Beispiel #5
0
 def testCreation(self):
     dataset = datasets.AbstractDataset('dataset1')
     localId = "variantAnnotationSetId"
     simulatedVariantSet = variants.SimulatedVariantSet(
         dataset, 'variantSet1', randomSeed=self.randomSeed,
         numCalls=self.numCalls, variantDensity=self.variantDensity)
     simulatedVariantAnnotationSet = variants.SimulatedVariantAnnotationSet(
         dataset, localId, simulatedVariantSet, self.randomSeed)
     annotations = simulatedVariantAnnotationSet.getVariantAnnotations(
                 self.referenceName, self.startPosition, self.endPosition)
     self.assertEquals(
         simulatedVariantSet.toProtocolElement().id,
         simulatedVariantAnnotationSet.toProtocolElement().variantSetId,
         "Variant Set ID should match the annotation's variant set ID")
     for ann in annotations:
         for key in protocol.VariantAnnotation().requiredFields:
             self.assertEquals(datetime.datetime.strptime(
                 ann.createDateTime, "%Y-%m-%dT%H:%M:%S.%fZ").strftime(
                     "%Y-%m-%dT%H:%M:%S.%fZ"), ann.createDateTime,
                     "Expect time format to be in ISO8601")
             self.assertTrue(hasattr(ann, key),
                             "Failed to find required key: " + key)