Example #1
0
    def __init__(self, randomSeed=0, numCalls=1, variantDensity=0.5,
                 numVariantSets=1, numReferenceSets=1,
                 numReferencesPerReferenceSet=1, numAlignments=2):
        super(SimulatedBackend, self).__init__()

        # Datasets
        dataset1 = datasets.SimulatedDataset(
            "simulatedDataset1", randomSeed, numCalls,
            variantDensity, numVariantSets, numAlignments)
        dataset2 = datasets.SimulatedDataset(
            "simulatedDataset2", randomSeed, numCalls,
            variantDensity, numVariantSets, numAlignments)
        self._datasetIdMap[dataset1.getId()] = dataset1
        self._datasetIdMap[dataset2.getId()] = dataset2
        self._datasetIds = sorted(self._datasetIdMap.keys())

        # References
        randomGenerator = random.Random()
        randomGenerator.seed(randomSeed)
        for i in range(numReferenceSets):
            referenceSetId = "referenceSet{}".format(i)
            referenceSetSeed = randomGenerator.getrandbits(32)
            referenceSet = references.SimulatedReferenceSet(
                referenceSetId, referenceSetSeed,
                numReferencesPerReferenceSet)
            self._referenceSetIdMap[referenceSetId] = referenceSet
            for reference in referenceSet.getReferences():
                referenceId = reference.getId()
                self._referenceIdMap[referenceId] = reference
        self._referenceSetIds = sorted(self._referenceSetIdMap.keys())
        self._referenceIds = sorted(self._referenceIdMap.keys())
Example #2
0
 def testCreation(self):
     dataset = datasets.Dataset('dataset1')
     referenceSet = references.SimulatedReferenceSet("srs1")
     localId = "variantAnnotationSetId"
     simulatedVariantSet = variants.SimulatedVariantSet(
         dataset,
         referenceSet,
         'variantSet1',
         randomSeed=self.randomSeed,
         numCalls=self.numCalls,
         variantDensity=self.variantDensity)
     simulatedVariantAnnotationSet = variants.SimulatedVariantAnnotationSet(
         simulatedVariantSet, localId, self.randomSeed)
     annotations = simulatedVariantAnnotationSet.getVariantAnnotations(
         self.referenceName, self.startPosition, self.endPosition)
     self.assertEquals(
         simulatedVariantSet.toProtocolElement().id,
         simulatedVariantAnnotationSet.toProtocolElement().variant_set_id,
         "Variant Set ID should match the annotation's variant set ID")
     for variant, ann in annotations:
         self.assertEquals(
             datetime.datetime.strptime(
                 ann.created,
                 "%Y-%m-%dT%H:%M:%S.%fZ").strftime("%Y-%m-%dT%H:%M:%S.%fZ"),
             ann.created, "Expect time format to be in ISO8601")
         self.assertEqual(variant.id, ann.variant_id)
Example #3
0
    def __init__(
            self, randomSeed=0, numDatasets=2,
            numVariantSets=1, numCalls=1, variantDensity=0.5,
            numReferenceSets=1, numReferencesPerReferenceSet=1,
            numReadGroupSets=1, numReadGroupsPerReadGroupSet=1,
            numAlignments=2):
        super(SimulatedDataRepository, self).__init__()

        # References
        for i in range(numReferenceSets):
            localId = "referenceSet{}".format(i)
            seed = randomSeed + i
            referenceSet = references.SimulatedReferenceSet(
                localId, seed, numReferencesPerReferenceSet)
            self.addReferenceSet(referenceSet)

        # Datasets
        for i in range(numDatasets):
            seed = randomSeed + i
            localId = "simulatedDataset{}".format(i)
            referenceSet = self.getReferenceSetByIndex(i % numReferenceSets)
            dataset = datasets.SimulatedDataset(
                localId, referenceSet=referenceSet, randomSeed=seed,
                numCalls=numCalls, variantDensity=variantDensity,
                numVariantSets=numVariantSets,
                numReadGroupSets=numReadGroupSets,
                numReadGroupsPerReadGroupSet=numReadGroupsPerReadGroupSet,
                numAlignments=numAlignments)
            self.addDataset(dataset)
 def testRunGetRequest(self):
     id_ = "anId"
     obj = references.SimulatedReferenceSet(id_)
     idMap = {id_: obj}
     responseStr = self._backend.runGetRequest(idMap, id_)
     class_ = protocol.ReferenceSet
     response = class_.fromJsonString(responseStr)
     self.assertTrue(isinstance(response, class_))
Example #5
0
 def testCreation(self):
     dataset = datasets.AbstractDataset('dataset1')
     localId = "readGroupSetId"
     referenceSet = references.SimulatedReferenceSet("srs1")
     simulatedReadGroupSet = reads.SimulatedReadGroupSet(
         dataset, localId, referenceSet)
     for readGroup in simulatedReadGroupSet.getReadGroups():
         alignments = list(readGroup.getReadAlignments())
         self.assertGreater(len(alignments), 0)
Example #6
0
 def _getSimulatedVariantSet(self):
     dataset = datasets.Dataset('dataset1')
     referenceSet = references.SimulatedReferenceSet("srs1")
     simulatedVariantSet = variants.SimulatedVariantSet(
         dataset,
         referenceSet,
         'variantSet1',
         randomSeed=self.randomSeed,
         numCalls=self.numCalls,
         variantDensity=self.variantDensity)
     return simulatedVariantSet