Exemplo n.º 1
0
 def setUpClass(cls):
     cls.numReferences = 25
     cls.backend = backend.SimulatedBackend(
         randomSeed=100,
         numDatasets=0,
         numReferenceSets=1,
         numReferencesPerReferenceSet=cls.numReferences)
Exemplo n.º 2
0
 def setUpClass(cls):
     cls.backend = backend.SimulatedBackend(
         randomSeed=100, numDatasets=3,
         numVariantSets=3, numCalls=3, variantDensity=0.5,
         numReferenceSets=3, numReferencesPerReferenceSet=3,
         numReadGroupSets=3, numReadGroupsPerReadGroupSet=3,
         numAlignments=3)
Exemplo n.º 3
0
 def setUp(self):
     self.request = protocol.SearchReadsRequest()
     self.backend = backend.SimulatedBackend(numAlignments=0)
     referenceSet = self.backend.getReferenceSetByIndex(0)
     reference = referenceSet.getReferenceByIndex(0)
     self.request.referenceId = reference.getId()
     self.dataset = self.backend.getDatasets()[0]
     self.readGroupSet = self.dataset.getReadGroupSets()[0]
 def setUp(self):
     self.request = protocol.SearchReadsRequest()
     self.request.referenceId = "chr1"
     self.backend = backend.SimulatedBackend()
     self.datasetId = self.backend.getDatasetIds()[0]
     self.dataset = self.backend.getDataset(self.datasetId)
     self.readGroupSetLocalId = "aReadGroupSet"
     self.readGroupLocalId = "aReadGroup"
     self.readGroupSet = reads.AbstractReadGroupSet(
         self.dataset, self.readGroupSetLocalId)
Exemplo n.º 5
0
def configure(configFile=None, baseConfig="ProductionConfig", extraConfig={}):
    """
    TODO Document this critical function! What does it do? What does
    it assume?
    """
    configStr = 'ga4gh.serverconfig:{0}'.format(baseConfig)
    app.config.from_object(configStr)
    if os.environ.get('GA4GH_CONFIGURATION') is not None:
        app.config.from_envvar('GA4GH_CONFIGURATION')
    if configFile is not None:
        app.config.from_pyfile(configFile)
    app.config.update(extraConfig.items())
    # Setup CORS
    cors.CORS(app, allow_headers='Content-Type')
    app.serverStatus = ServerStatus()
    # Allocate the backend
    # TODO is this a good way to determine what type of backend we should
    # instantiate? We should think carefully about this. The approach of
    # using the special strings __SIMULATED__ and __EMPTY__ seems OK for
    # now, but is certainly not ideal.
    dataSource = app.config["DATA_SOURCE"]
    if dataSource == "__SIMULATED__":
        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"]
        theBackend = backend.SimulatedBackend(randomSeed, numCalls,
                                              variantDensity, numVariantSets)
    elif dataSource == "__EMPTY__":
        theBackend = backend.EmptyBackend()
    else:
        theBackend = backend.FileSystemBackend(dataSource)
    theBackend.setRequestValidation(app.config["REQUEST_VALIDATION"])
    theBackend.setResponseValidation(app.config["RESPONSE_VALIDATION"])
    theBackend.setDefaultPageSize(app.config["DEFAULT_PAGE_SIZE"])
    theBackend.setMaxResponseLength(app.config["MAX_RESPONSE_LENGTH"])
    app.backend = theBackend
Exemplo n.º 6
0
 def setUp(self):
     self._backend = backend.SimulatedBackend(numCalls=100,
                                              numVariantSets=10)
Exemplo n.º 7
0
 def setUp(self):
     self.request = protocol.SearchVariantsRequest()
     self.backend = backend.SimulatedBackend()
     self.dataset = self.backend.getDatasets()[0]
 def setUp(self):
     self.request = protocol.SearchVariantsRequest()
     self.backend = backend.SimulatedBackend()
     self.datasetId = self.backend.getDatasetIds()[0]
     self.dataset = self.backend.getDataset(self.datasetId)
     self.variantSetLocalId = 'variantSet'
Exemplo n.º 9
0
def configure(configFile=None,
              baseConfig="ProductionConfig",
              port=8000,
              extraConfig={}):
    """
    TODO Document this critical function! What does it do? What does
    it assume?
    """
    configStr = 'ga4gh.serverconfig:{0}'.format(baseConfig)
    app.config.from_object(configStr)
    if os.environ.get('GA4GH_CONFIGURATION') is not None:
        app.config.from_envvar('GA4GH_CONFIGURATION')
    if configFile is not None:
        app.config.from_pyfile(configFile)
    app.config.update(extraConfig.items())
    # Setup file handle cache max size
    datamodel.fileHandleCache.setMaxCacheSize(
        app.config["FILE_HANDLE_CACHE_MAX_SIZE"])
    # Setup CORS
    cors.CORS(app, allow_headers='Content-Type')
    app.serverStatus = ServerStatus()
    # Allocate the backend
    # TODO is this a good way to determine what type of backend we should
    # instantiate? We should think carefully about this. The approach of
    # using the special strings __SIMULATED__ and __EMPTY__ seems OK for
    # now, but is certainly not ideal.
    dataSource = app.config["DATA_SOURCE"]
    if dataSource == "__SIMULATED__":
        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"]
        numAlignments = app.config[
            "SIMULATED_BACKEND_NUM_ALIGNMENTS_PER_READ_GROUP"]
        theBackend = backend.SimulatedBackend(randomSeed, numCalls,
                                              variantDensity, numVariantSets,
                                              numReferenceSets,
                                              numReferencesPerReferenceSet,
                                              numAlignments)
    elif dataSource == "__EMPTY__":
        theBackend = backend.EmptyBackend()
    else:
        theBackend = backend.FileSystemBackend(dataSource)
    theBackend.setRequestValidation(app.config["REQUEST_VALIDATION"])
    theBackend.setResponseValidation(app.config["RESPONSE_VALIDATION"])
    theBackend.setDefaultPageSize(app.config["DEFAULT_PAGE_SIZE"])
    theBackend.setMaxResponseLength(app.config["MAX_RESPONSE_LENGTH"])
    app.backend = theBackend
    app.secret_key = os.urandom(SECRET_KEY_LENGTH)
    app.oidcClient = None
    app.tokenMap = None
    app.myPort = port
    if "OIDC_PROVIDER" in app.config:
        # The oic client. If we're testing, we don't want to verify
        # SSL certificates
        app.oidcClient = oic.oic.Client(
            verify_ssl=('TESTING' not in app.config))
        app.tokenMap = {}
        try:
            app.oidcClient.provider_config(app.config['OIDC_PROVIDER'])
        except requests.exceptions.ConnectionError:
            configResponse = message.ProviderConfigurationResponse(
                issuer=app.config['OIDC_PROVIDER'],
                authorization_endpoint=app.config['OIDC_AUTHZ_ENDPOINT'],
                token_endpoint=app.config['OIDC_TOKEN_ENDPOINT'],
                revocation_endpoint=app.config['OIDC_TOKEN_REV_ENDPOINT'])
            app.oidcClient.handle_provider_config(configResponse,
                                                  app.config['OIDC_PROVIDER'])

        # The redirect URI comes from the configuration.
        # If we are testing, then we allow the automatic creation of a
        # redirect uri if none is configured
        redirectUri = app.config.get('OIDC_REDIRECT_URI')
        if redirectUri is None and 'TESTING' in app.config:
            redirectUri = 'https://{0}:{1}/oauth2callback'.format(
                socket.gethostname(), app.myPort)
        app.oidcClient.redirect_uris = [redirectUri]
        if redirectUri is []:
            raise exceptions.ConfigurationException(
                'OIDC configuration requires a redirect uri')

        # We only support dynamic registration while testing.
        if ('registration_endpoint' in app.oidcClient.provider_info
                and 'TESTING' in app.config):
            app.oidcClient.register(
                app.oidcClient.provider_info["registration_endpoint"],
                redirect_uris=[redirectUri])
        else:
            response = message.RegistrationResponse(
                client_id=app.config['OIDC_CLIENT_ID'],
                client_secret=app.config['OIDC_CLIENT_SECRET'],
                redirect_uris=[redirectUri],
                verify_ssl=False)
            app.oidcClient.store_registration_info(response)
Exemplo n.º 10
0
 def setUp(self):
     self.request = protocol.SearchVariantsRequest()
     self.backend = backend.SimulatedBackend()
     self.datasetId = self.backend.getDatasetIds()[0]
     self.variantSetId = "{}:variantSetId".format(self.datasetId)
Exemplo n.º 11
0
 def setUp(self):
     self.request = protocol.SearchReadsRequest()
     self.backend = backend.SimulatedBackend()
     self.datasetId = self.backend.getDatasetIds()[0]
     self.readGroupId = "{}:readGroupId".format(self.datasetId)