def testEndToEnd(self): # extract ids from a simulated data repo with the same config repo = datarepo.SimulatedDataRepository() peer = repo.getPeers()[0] dataset = repo.getDatasets()[0] datasetId = dataset.getId() variantSet = dataset.getVariantSets()[0] variantSetId = variantSet.getId() readGroupSet = dataset.getReadGroupSets()[0] readGroupId = readGroupSet.getReadGroups()[0].getId() referenceSet = repo.getReferenceSets()[0] referenceSetId = referenceSet.getId() referenceId = referenceSet.getReferences()[0].getId() variantAnnotationSetId = \ variantSet.getVariantAnnotationSets()[0].getId() self.simulatedPeerUrl = peer.getUrl() self.simulatedDatasetId = datasetId self.simulatedVariantSetId = variantSetId self.simulatedReadGroupId = readGroupId self.simulatedReferenceSetId = referenceSetId self.simulatedReferenceId = referenceId self.simulatedVariantAnnotationSetId = variantAnnotationSetId self.client = client.ClientForTesting(self.server.getUrl()) self.runVariantsRequest() self.assertLogsWritten() self.runPeersRequests() self.runReadsRequest() self.runReferencesRequest() self.runVariantSetsRequestDatasetTwo() self.runVariantAnnotationsRequest() self.runGetVariantAnnotationSetsRequest() self.client.cleanup()
def setUpClass(cls): cls.numReferences = 25 cls.backend = backend.Backend( datarepo.SimulatedDataRepository( randomSeed=100, numDatasets=0, numReferenceSets=1, numReferencesPerReferenceSet=cls.numReferences)) cls.dataRepo = cls.backend.getDataRepository()
def _configure_backend(app): """A helper function used just to help modularize the code a bit.""" # Allocate the backend # We use URLs to specify the backend. Currently we have file:// URLs (or # URLs with no scheme) for the SqlDataRepository, and special empty:// and # simulated:// URLs for empty or simulated data sources. dataSource = urlparse.urlparse(app.config["DATA_SOURCE"], "file") if dataSource.scheme == "simulated": # Ignore the query string randomSeed = app.config["SIMULATED_BACKEND_RANDOM_SEED"] numCalls = app.config["SIMULATED_BACKEND_NUM_CALLS"] variantDensity = app.config["SIMULATED_BACKEND_VARIANT_DENSITY"] numVariantSets = app.config["SIMULATED_BACKEND_NUM_VARIANT_SETS"] numReferenceSets = app.config["SIMULATED_BACKEND_NUM_REFERENCE_SETS"] numReferencesPerReferenceSet = app.config[ "SIMULATED_BACKEND_NUM_REFERENCES_PER_REFERENCE_SET"] numAlignmentsPerReadGroup = app.config[ "SIMULATED_BACKEND_NUM_ALIGNMENTS_PER_READ_GROUP"] numReadGroupsPerReadGroupSet = app.config[ "SIMULATED_BACKEND_NUM_READ_GROUPS_PER_READ_GROUP_SET"] numPhenotypeAssociations = app.config[ "SIMULATED_BACKEND_NUM_PHENOTYPE_ASSOCIATIONS"] numPhenotypeAssociationSets = app.config[ "SIMULATED_BACKEND_NUM_PHENOTYPE_ASSOCIATION_SETS"] numRnaQuantSets = app.config[ "SIMULATED_BACKEND_NUM_RNA_QUANTIFICATION_SETS"] numExpressionLevels = app.config[ "SIMULATED_BACKEND_NUM_EXPRESSION_LEVELS_PER_RNA_QUANT_SET"] dataRepository = datarepo.SimulatedDataRepository( randomSeed=randomSeed, numCalls=numCalls, variantDensity=variantDensity, numVariantSets=numVariantSets, numReferenceSets=numReferenceSets, numReferencesPerReferenceSet=numReferencesPerReferenceSet, numReadGroupsPerReadGroupSet=numReadGroupsPerReadGroupSet, numAlignments=numAlignmentsPerReadGroup, numPhenotypeAssociations=numPhenotypeAssociations, numPhenotypeAssociationSets=numPhenotypeAssociationSets, numRnaQuantSets=numRnaQuantSets, numExpressionLevels=numExpressionLevels) elif dataSource.scheme == "empty": dataRepository = datarepo.EmptyDataRepository() elif dataSource.scheme == "file": path = os.path.join(dataSource.netloc, dataSource.path) dataRepository = datarepo.SqlDataRepository(path) dataRepository.open(datarepo.MODE_READ) else: raise exceptions.ConfigurationException( "Unsupported data source scheme: " + dataSource.scheme) theBackend = backend.Backend(dataRepository) theBackend.setRequestValidation(app.config["REQUEST_VALIDATION"]) theBackend.setDefaultPageSize(app.config["DEFAULT_PAGE_SIZE"]) theBackend.setMaxResponseLength(app.config["MAX_RESPONSE_LENGTH"]) return theBackend
def setUp(self): self.request = protocol.SearchReadsRequest() self.backend = backend.Backend( datarepo.SimulatedDataRepository(numAlignments=0)) dataRepo = self.backend.getDataRepository() referenceSet = dataRepo.getReferenceSetByIndex(0) reference = referenceSet.getReferenceByIndex(0) self.request.reference_id = reference.getId() self.dataset = dataRepo.getDatasets()[0] self.readGroupSet = self.dataset.getReadGroupSets()[0]
def otherSetup(cls): # extract ids from a simulated data repo with the same config repo = datarepo.SimulatedDataRepository() dataset = repo.getDatasets()[0] variantSet = dataset.getVariantSets()[0] variantSetId = variantSet.getId() cls.simulatedVariantSetId = variantSetId requests.packages.urllib3.disable_warnings() cls.opServer = server.OidcOpServerForTesting() cls.opServer.start()
def setUpClass(cls): cls.backend = backend.Backend( datarepo.SimulatedDataRepository(randomSeed=100, numDatasets=3, numVariantSets=3, numCalls=3, variantDensity=0.5, numReferenceSets=3, numReferencesPerReferenceSet=3, numReadGroupSets=3, numReadGroupsPerReadGroupSet=3, numAlignments=3, numRnaQuantSets=3)) cls.dataRepo = cls.backend.getDataRepository()
def add_local_client(self, local_client="simulated", datasets=None, featuresets=None, phenotypeassociationsets=None): """Add a g2p local client to manager.""" if isinstance(local_client, str) and local_client == 'simulated': repository = datarepo.SimulatedDataRepository() b = backend.Backend(repository) c = LocalClient(b, datasets, featuresets, phenotypeassociationsets) elif isinstance(local_client, LocalClient): c = local_client else: raise TypeError( 'Expected local_client to be "simulated" or LocalClient object' ) self.client_list.append(c)
import unittest from g2pf.clientManager import * from ga4gh.server import backend, datarepo from ga4gh.client import client b = backend.Backend(datarepo.SimulatedDataRepository()) class TestClientManager(unittest.TestCase): def setUp(self): self.http_client1 = HttpClient("http://1kgenomes.ga4gh.org") self.http_client2 = HttpClient("http://1kgenomes.ga4gh.org", datasets=["1kgenomes", "anotherOne"], featuresets=["f1", "f2"], phenotypeassociationsets=["p1", "p2"]) self.local_client1 = LocalClient(b) self.local_client2 = LocalClient(b, datasets=['1kgenomes', 'anotherOne'], featuresets=['f1', 'f2'], phenotypeassociationsets=['p1', 'p2']) self.manager = ClientManager() def test_add_clients(self): counts = list() counts.append(len(self.manager)) self.manager.add_http_client(self.http_client1) counts.append(len(self.manager)) self.manager.add_http_client(self.http_client2) counts.append(len(self.manager)) self.manager.add_local_client(self.local_client1)
def setUp(self): self.request = protocol.SearchVariantsRequest() self.backend = backend.Backend(datarepo.SimulatedDataRepository()) self.dataset = self.backend.getDataRepository().getDatasets()[0]