text
stringlengths
81
112k
Returns an individual with the specified name, or raises a IndividualNameNotFoundException if it does not exist. def getIndividualByName(self, name): """ Returns an individual with the specified name, or raises a IndividualNameNotFoundException if it does not exist. """ ...
Returns the Individual with the specified id, or raises a IndividualNotFoundException otherwise. def getIndividual(self, id_): """ Returns the Individual with the specified id, or raises a IndividualNotFoundException otherwise. """ if id_ not in self._individualIdMap: ...
Returns a ReadGroupSet with the specified name, or raises a ReadGroupSetNameNotFoundException if it does not exist. def getReadGroupSetByName(self, name): """ Returns a ReadGroupSet with the specified name, or raises a ReadGroupSetNameNotFoundException if it does not exist. """ ...
Returns the ReadGroupSet with the specified name, or raises a ReadGroupSetNotFoundException otherwise. def getReadGroupSet(self, id_): """ Returns the ReadGroupSet with the specified name, or raises a ReadGroupSetNotFoundException otherwise. """ if id_ not in self._readG...
Returns the RnaQuantification set with the specified name, or raises an exception otherwise. def getRnaQuantificationSetByName(self, name): """ Returns the RnaQuantification set with the specified name, or raises an exception otherwise. """ if name not in self._rnaQuanti...
Returns the RnaQuantification set with the specified name, or raises a RnaQuantificationSetNotFoundException otherwise. def getRnaQuantificationSet(self, id_): """ Returns the RnaQuantification set with the specified name, or raises a RnaQuantificationSetNotFoundException otherwise. ...
Parses the (probably) intended values out of the specified BAM header dictionary, which is incompletely parsed by pysam. This is caused by some tools incorrectly using spaces instead of tabs as a seperator. def parseMalformedBamHeader(headerDict): """ Parses the (probably) intended values out of th...
Returns an iterator over the specified reads def _getReadAlignments( self, reference, start, end, readGroupSet, readGroup): """ Returns an iterator over the specified reads """ # TODO If reference is None, return against all references, # including unmapped reads. ...
Convert a pysam ReadAlignment to a GA4GH ReadAlignment def convertReadAlignment(self, read, readGroupSet, readGroupId): """ Convert a pysam ReadAlignment to a GA4GH ReadAlignment """ samFile = self.getFileHandle(self._dataUrl) # TODO fill out remaining fields # TODO refi...
Adds the specified ReadGroup to this ReadGroupSet. def addReadGroup(self, readGroup): """ Adds the specified ReadGroup to this ReadGroupSet. """ id_ = readGroup.getId() self._readGroupIdMap[id_] = readGroup self._readGroupIds.append(id_)
Returns the ReadGroup with the specified id if it exists in this ReadGroupSet, or raises a ReadGroupNotFoundException otherwise. def getReadGroup(self, id_): """ Returns the ReadGroup with the specified id if it exists in this ReadGroupSet, or raises a ReadGroupNotFoundException otherwi...
Returns the GA4GH protocol representation of this ReadGroupSet. def toProtocolElement(self): """ Returns the GA4GH protocol representation of this ReadGroupSet. """ readGroupSet = protocol.ReadGroupSet() readGroupSet.id = self.getId() readGroupSet.read_groups.extend( ...
Returns a string ID suitable for use in the specified GA ReadAlignment object in this ReadGroupSet. def getReadAlignmentId(self, gaAlignment): """ Returns a string ID suitable for use in the specified GA ReadAlignment object in this ReadGroupSet. """ compoundId = datamod...
Returns the GA4GH protocol representation of this read group set's ReadStats. def getStats(self): """ Returns the GA4GH protocol representation of this read group set's ReadStats. """ stats = protocol.ReadStats() stats.aligned_read_count = self._numAlignedReads ...
Returns an iterator over the specified reads def getReadAlignments(self, reference, start=None, end=None): """ Returns an iterator over the specified reads """ return self._getReadAlignments(reference, start, end, self, None)
Populates the instance variables of this ReadGroupSet from the specified database row. def populateFromRow(self, readGroupSetRecord): """ Populates the instance variables of this ReadGroupSet from the specified database row. """ self._dataUrl = readGroupSetRecord.dataurl...
Populates the instance variables of this ReadGroupSet from the specified dataUrl and indexFile. If indexFile is not specified guess usual form. def populateFromFile(self, dataUrl, indexFile=None): """ Populates the instance variables of this ReadGroupSet from the specified dataU...
Returns the GA4GH protocol representation of this ReadGroup. def toProtocolElement(self): """ Returns the GA4GH protocol representation of this ReadGroup. """ # TODO this is very incomplete, but we don't have the # implementation to fill out the rest of the fields currently ...
Returns the GA4GH protocol representation of this read group's ReadStats. def getStats(self): """ Returns the GA4GH protocol representation of this read group's ReadStats. """ stats = protocol.ReadStats() stats.aligned_read_count = self.getNumAlignedReads() ...
Returns the GA4GH protocol representation of this read group's Experiment. def getExperiment(self): """ Returns the GA4GH protocol representation of this read group's Experiment. """ experiment = protocol.Experiment() experiment.id = self.getExperimentId() ...
Populate the instance variables using the specified SAM header. def populateFromHeader(self, readGroupHeader): """ Populate the instance variables using the specified SAM header. """ self._sampleName = readGroupHeader.get('SM', None) self._description = readGroupHeader.get('DS',...
Populate the instance variables using the specified DB row. def populateFromRow(self, readGroupRecord): """ Populate the instance variables using the specified DB row. """ self._sampleName = readGroupRecord.samplename self._biosampleId = readGroupRecord.biosampleid self....
Returns the filename of the specified path without its extensions. This is usually how we derive the default name for a given object. def getNameFromPath(filePath): """ Returns the filename of the specified path without its extensions. This is usually how we derive the default name for a given object. ...
Exits the repo manager with error status. def repoExitError(message): """ Exits the repo manager with error status. """ wrapper = textwrap.TextWrapper( break_on_hyphens=False, break_long_words=False) formatted = wrapper.fill("{}: error: {}".format(sys.argv[0], message)) sys.exit(formatt...
Runs the specified function that updates the repo with the specified arguments. This method ensures that all updates are transactional, so that if any part of the update fails no changes are made to the repo. def _updateRepo(self, func, *args, **kwargs): """ Runs the specified f...
Adds a new Ontology to this repo. def addOntology(self): """ Adds a new Ontology to this repo. """ self._openRepo() name = self._args.name filePath = self._getFilePath(self._args.filePath, self._args.relativePath) if name is N...
Adds a new dataset into this repo. def addDataset(self): """ Adds a new dataset into this repo. """ self._openRepo() dataset = datasets.Dataset(self._args.datasetName) dataset.setDescription(self._args.description) dataset.setAttributes(json.loads(self._args.attr...
Adds a new reference set into this repo. def addReferenceSet(self): """ Adds a new reference set into this repo. """ self._openRepo() name = self._args.name filePath = self._getFilePath(self._args.filePath, self._args.relativePath) ...
Adds a new ReadGroupSet into this repo. def addReadGroupSet(self): """ Adds a new ReadGroupSet into this repo. """ self._openRepo() dataset = self._repo.getDatasetByName(self._args.datasetName) dataUrl = self._args.dataFile indexFile = self._args.indexFile ...
Adds a new VariantSet into this repo. def addVariantSet(self): """ Adds a new VariantSet into this repo. """ self._openRepo() dataset = self._repo.getDatasetByName(self._args.datasetName) dataUrls = self._args.dataFiles name = self._args.name if len(dataU...
Adds a new phenotype association set to this repo. def addPhenotypeAssociationSet(self): """ Adds a new phenotype association set to this repo. """ self._openRepo() name = self._args.name if name is None: name = getNameFromPath(self._args.dirPath) dat...
Removes a phenotype association set from the repo def removePhenotypeAssociationSet(self): """ Removes a phenotype association set from the repo """ self._openRepo() dataset = self._repo.getDatasetByName(self._args.datasetName) phenotypeAssociationSet = dataset.getPhenot...
Removes a referenceSet from the repo. def removeReferenceSet(self): """ Removes a referenceSet from the repo. """ self._openRepo() referenceSet = self._repo.getReferenceSetByName( self._args.referenceSetName) def func(): self._updateRepo(self._re...
Removes a readGroupSet from the repo. def removeReadGroupSet(self): """ Removes a readGroupSet from the repo. """ self._openRepo() dataset = self._repo.getDatasetByName(self._args.datasetName) readGroupSet = dataset.getReadGroupSetByName( self._args.readGroup...
Removes a variantSet from the repo. def removeVariantSet(self): """ Removes a variantSet from the repo. """ self._openRepo() dataset = self._repo.getDatasetByName(self._args.datasetName) variantSet = dataset.getVariantSetByName(self._args.variantSetName) def fun...
Removes a dataset from the repo. def removeDataset(self): """ Removes a dataset from the repo. """ self._openRepo() dataset = self._repo.getDatasetByName(self._args.datasetName) def func(): self._updateRepo(self._repo.removeDataset, dataset) self._co...
Adds a new feature set into this repo def addFeatureSet(self): """ Adds a new feature set into this repo """ self._openRepo() dataset = self._repo.getDatasetByName(self._args.datasetName) filePath = self._getFilePath(self._args.filePath, ...
Removes a feature set from this repo def removeFeatureSet(self): """ Removes a feature set from this repo """ self._openRepo() dataset = self._repo.getDatasetByName(self._args.datasetName) featureSet = dataset.getFeatureSetByName(self._args.featureSetName) def f...
Adds a new continuous set into this repo def addContinuousSet(self): """ Adds a new continuous set into this repo """ self._openRepo() dataset = self._repo.getDatasetByName(self._args.datasetName) filePath = self._getFilePath(self._args.filePath, ...
Removes a continuous set from this repo def removeContinuousSet(self): """ Removes a continuous set from this repo """ self._openRepo() dataset = self._repo.getDatasetByName(self._args.datasetName) continuousSet = dataset.getContinuousSetByName( ...
Adds a new biosample into this repo def addBiosample(self): """ Adds a new biosample into this repo """ self._openRepo() dataset = self._repo.getDatasetByName(self._args.datasetName) biosample = bio_metadata.Biosample( dataset, self._args.biosampleName) ...
Removes a biosample from this repo def removeBiosample(self): """ Removes a biosample from this repo """ self._openRepo() dataset = self._repo.getDatasetByName(self._args.datasetName) biosample = dataset.getBiosampleByName(self._args.biosampleName) def func(): ...
Adds a new individual into this repo def addIndividual(self): """ Adds a new individual into this repo """ self._openRepo() dataset = self._repo.getDatasetByName(self._args.datasetName) individual = bio_metadata.Individual( dataset, self._args.individualName)...
Removes an individual from this repo def removeIndividual(self): """ Removes an individual from this repo """ self._openRepo() dataset = self._repo.getDatasetByName(self._args.datasetName) individual = dataset.getIndividualByName(self._args.individualName) def f...
Adds a new peer into this repo def addPeer(self): """ Adds a new peer into this repo """ self._openRepo() try: peer = peers.Peer( self._args.url, json.loads(self._args.attributes)) except exceptions.BadUrlException: raise exception...
Removes a peer by URL from this repo def removePeer(self): """ Removes a peer by URL from this repo """ self._openRepo() def func(): self._updateRepo(self._repo.removePeer, self._args.url) self._confirmDelete("Peer", self._args.url, func)
Removes an ontology from the repo. def removeOntology(self): """ Removes an ontology from the repo. """ self._openRepo() ontology = self._repo.getOntologyByName(self._args.ontologyName) def func(): self._updateRepo(self._repo.removeOntology, ontology) ...
Adds an rnaQuantification into this repo def addRnaQuantification(self): """ Adds an rnaQuantification into this repo """ self._openRepo() dataset = self._repo.getDatasetByName(self._args.datasetName) biosampleId = "" if self._args.biosampleName: bios...
Initialize an empty RNA quantification set def initRnaQuantificationSet(self): """ Initialize an empty RNA quantification set """ store = rnaseq2ga.RnaSqliteStore(self._args.filePath) store.createTables()
Adds an rnaQuantificationSet into this repo def addRnaQuantificationSet(self): """ Adds an rnaQuantificationSet into this repo """ self._openRepo() dataset = self._repo.getDatasetByName(self._args.datasetName) if self._args.name is None: name = getNameFromPat...
Removes an rnaQuantificationSet from this repo def removeRnaQuantificationSet(self): """ Removes an rnaQuantificationSet from this repo """ self._openRepo() dataset = self._repo.getDatasetByName(self._args.datasetName) rnaQuantSet = dataset.getRnaQuantificationSetByName(...
Reads RNA Quantification data in one of several formats and stores the data in a sqlite database for use by the GA4GH reference server. Supports the following quantification output types: Cufflinks, kallisto, RSEM. def rnaseq2ga(quantificationFilename, sqlFilename, localName, rnaType, datase...
Adds an RNAQuantification to the db. Datafields is a tuple in the order: id, feature_set_ids, description, name, read_group_ids, programs, biosample_id def addRNAQuantification(self, datafields): """ Adds an RNAQuantification to the db. Datafields is a tuple in the ord...
Adds an Expression to the db. Datafields is a tuple in the order: id, rna_quantification_id, name, expression, is_normalized, raw_read_count, score, units, conf_low, conf_hi def addExpression(self, datafields): """ Adds an Expression to the db. Datafields is a tuple in the order: ...
Index columns that are queried. The expression index can take a long time. def createIndices(self): """ Index columns that are queried. The expression index can take a long time. """ sql = '''CREATE INDEX name_index ON Expression (name)''' self....
Reads the quantification results file and adds entries to the specified database. def writeExpression(self, rnaQuantificationId, quantfilename): """ Reads the quantification results file and adds entries to the specified database. """ isNormalized = self._isNormalized ...
Fetch sequences from NCBI using the eself interface. An interbase interval may be optionally provided with startIndex and endIndex. NCBI eself will return just the requested subsequence, which might greatly reduce payload sizes (especially with chromosome-scale sequences). When wrapped is True, return ...
Creates a new bam header based on the specified header from the parent BAM file. def createBamHeader(self, baseHeader): """ Creates a new bam header based on the specified header from the parent BAM file. """ header = dict(baseHeader) newSequences = [] fo...
Creates the repository for all the data we've just downloaded. def createRepo(self): """ Creates the repository for all the data we've just downloaded. """ repo = datarepo.SqlDataRepository(self.repoPath) repo.open("w") repo.initialise() referenceSet = reference...
A helper function used just to help modularize the code a bit. 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 SqlDataReposito...
TODO Document this critical function! What does it do? What does it assume? def configure(configFile=None, baseConfig="ProductionConfig", port=8000, extraConfig={}): """ TODO Document this critical function! What does it do? What does it assume? """ file_handler = StreamHandler() ...
Returns a Flask response object for the specified data and HTTP status. def getFlaskResponse(responseString, httpStatus=200): """ Returns a Flask response object for the specified data and HTTP status. """ return flask.Response(responseString, status=httpStatus, mimetype=MIMETYPE)
Handles the specified HTTP POST request, which maps to the specified protocol handler endpoint and protocol request class. def handleHttpPost(request, endpoint): """ Handles the specified HTTP POST request, which maps to the specified protocol handler endpoint and protocol request class. """ if...
Handles an exception that occurs somewhere in the process of handling a request. def handleException(exception): """ Handles an exception that occurs somewhere in the process of handling a request. """ serverException = exception if not isinstance(exception, exceptions.BaseServerException):...
If we are not logged in, this generates the redirect URL to the OIDC provider and returns the redirect response :return: A redirect response to the OIDC provider def startLogin(): """ If we are not logged in, this generates the redirect URL to the OIDC provider and returns the redirect response ...
The request will have a parameter 'key' if it came from the command line client, or have a session key of 'key' if it's the browser. If the token is not found, start the login process. If there is no oidcClient, we are running naked and we don't check. If we're being redirected to the oidcCallback we d...
Handles the specified flask request for one of the GET URLs Invokes the specified endpoint to generate a response. def handleFlaskGetRequest(id_, flaskRequest, endpoint): """ Handles the specified flask request for one of the GET URLs Invokes the specified endpoint to generate a response. """ i...
Handles the specified flask request for one of the POST URLS Invokes the specified endpoint to generate a response. def handleFlaskPostRequest(flaskRequest, endpoint): """ Handles the specified flask request for one of the POST URLS Invokes the specified endpoint to generate a response. """ if ...
Returns the list of ReferenceSets for this server. def getVariantAnnotationSets(self, datasetId): """ Returns the list of ReferenceSets for this server. """ # TODO this should be displayed per-variant set, not per dataset. variantAnnotationSets = [] dataset = app.backend...
This decorator wraps a view function so that it is protected when Auth0 is enabled. This means that any request will be expected to have a signed token in the authorization header if the `AUTH0_ENABLED` configuration setting is True. The authorization header will have the form: "authorization: Bea...
A function that threads the header through decoding and returns a tuple of the token and payload if successful. This does not fully authenticate a request. :param auth_header: :param client_id: :param client_secret: :return: (token, profile) def decode_header(auth_header, client_id, client_secr...
Logs out the current session by removing it from the cache. This is expected to only occur when a session has def logout(cache): """ Logs out the current session by removing it from the cache. This is expected to only occur when a session has """ cache.set(flask.session['auth0_key'], None) ...
This function will generate a view function that can be used to handle the return from Auth0. The "callback" is a redirected session from auth0 that includes the token we can use to authenticate that session. If the session is properly authenticated Auth0 will provide a code so our application can iden...
This function will generate a view function that can be used to handle the return from Auth0. The "callback" is a redirected session from auth0 that includes the token we can use to authenticate that session. If the session is properly authenticated Auth0 will provide a code so our application can iden...
Renders a view from the app and a key that lets the current session grab its token. :param app: :param key: :return: Rendered view def render_key(app, key=""): """ Renders a view from the app and a key that lets the current session grab its token. :param app: :param key: :return...
Takes the header and tries to return an active token and decoded payload. :param auth_header: :param client_id: :param client_secret: :return: (token, profile) def _decode_header(auth_header, client_id, client_secret): """ Takes the header and tries to return an active token and decoded ...
Accepts the cache and ID token and checks to see if the profile is currently logged in. If so, return the token, otherwise throw a NotAuthenticatedException. :param cache: :param token: :return: def is_active(cache, token): """ Accepts the cache and ID token and checks to see if the profile...
Adds the specified reference to this ReferenceSet. def addReference(self, reference): """ Adds the specified reference to this ReferenceSet. """ id_ = reference.getId() self._referenceIdMap[id_] = reference self._referenceNameMap[reference.getLocalId()] = reference ...
Sets the species, an OntologyTerm, to the specified value, given as a JSON string. See the documentation for details of this field. def setSpeciesFromJson(self, speciesJson): """ Sets the species, an OntologyTerm, to the specified value, given as a JSON string. See the...
Returns the reference with the specified name. def getReferenceByName(self, name): """ Returns the reference with the specified name. """ if name not in self._referenceNameMap: raise exceptions.ReferenceNameNotFoundException(name) return self._referenceNameMap[name]
Returns the Reference with the specified ID or raises a ReferenceNotFoundException if it does not exist. def getReference(self, id_): """ Returns the Reference with the specified ID or raises a ReferenceNotFoundException if it does not exist. """ if id_ not in self._refe...
Returns the MD5 checksum for this reference set. This checksum is calculated by making a list of `Reference.md5checksum` for all `Reference`s in this set. We then sort this list, and take the MD5 hash of all the strings concatenated together. def getMd5Checksum(self): """ Return...
Returns the GA4GH protocol representation of this ReferenceSet. def toProtocolElement(self): """ Returns the GA4GH protocol representation of this ReferenceSet. """ ret = protocol.ReferenceSet() ret.assembly_id = pb.string(self.getAssemblyId()) ret.description = pb.strin...
Returns the GA4GH protocol representation of this Reference. def toProtocolElement(self): """ Returns the GA4GH protocol representation of this Reference. """ reference = protocol.Reference() reference.id = self.getId() reference.is_derived = self.getIsDerived() ...
Checks to ensure that the query range is valid within this reference. If not, raise ReferenceRangeErrorException. def checkQueryRange(self, start, end): """ Checks to ensure that the query range is valid within this reference. If not, raise ReferenceRangeErrorException. """ ...
Populates the instance variables of this ReferencSet from the data URL. def populateFromFile(self, dataUrl): """ Populates the instance variables of this ReferencSet from the data URL. """ self._dataUrl = dataUrl fastaFile = self.getFastaFile() for refere...
Populates this reference set from the values in the specified DB row. def populateFromRow(self, referenceSetRecord): """ Populates this reference set from the values in the specified DB row. """ self._dataUrl = referenceSetRecord.dataurl self._description = refer...
Populates this reference from the values in the specified DB row. def populateFromRow(self, referenceRecord): """ Populates this reference from the values in the specified DB row. """ self._length = referenceRecord.length self._isDerived = bool(referenceRecord.isderived) ...
Given a set of results from our search query, return the `details` (feature,environment,phenotype) def _extractAssociationsDetails(self, associations): """ Given a set of results from our search query, return the `details` (feature,environment,phenotype) """ detailedURIR...
Given a list of uriRefs, return a list of dicts: {'subject': s, 'predicate': p, 'object': o } all values are strings def _detailTuples(self, uriRefs): """ Given a list of uriRefs, return a list of dicts: {'subject': s, 'predicate': p, 'object': o } all values are strings...
Given a binding from the sparql query result, create a dict of plain text def _bindingsToDict(self, bindings): """ Given a binding from the sparql query result, create a dict of plain text """ myDict = {} for key, val in bindings.iteritems(): myDict[k...
Given a filename, add it to the graph def _addDataFile(self, filename): """ Given a filename, add it to the graph """ if filename.endswith('.ttl'): self._rdfGraph.parse(filename, format='n3') else: self._rdfGraph.parse(filename, format='xml')
Given a uriRef, return a dict of all the details for that Ref use the uriRef as the 'id' of the dict def _getDetails(self, uriRef, associations_details): """ Given a uriRef, return a dict of all the details for that Ref use the uriRef as the 'id' of the dict """ associat...
Formats several external identifiers for query def _formatExternalIdentifiers(self, element, element_type): """ Formats several external identifiers for query """ elementClause = None elements = [] if not issubclass(element.__class__, dict): element = protoco...
Formats a single external identifier for query def _formatExternalIdentifier(self, element, element_type): """ Formats a single external identifier for query """ if "http" not in element['database']: term = "{}:{}".format(element['database'], element['identifier']) ...
Formats the ontology terms for query def _formatOntologyTerm(self, element, element_type): """ Formats the ontology terms for query """ elementClause = None if isinstance(element, dict) and element.get('terms'): elements = [] for _term in element['terms']...
Formats the ontology term object for query def _formatOntologyTermObject(self, terms, element_type): """ Formats the ontology term object for query """ elementClause = None if not isinstance(terms, collections.Iterable): terms = [terms] elements = [] ...
Formats a set of identifiers for query def _formatIds(self, element, element_type): """ Formats a set of identifiers for query """ elementClause = None if isinstance(element, collections.Iterable): elements = [] for _id in element: element...
Formats elements passed into parts of a query for filtering def _formatEvidence(self, elements): """ Formats elements passed into parts of a query for filtering """ elementClause = None filters = [] for evidence in elements: if evidence.description: ...
Given a url identifier return identifier portion Leverages prefixes already in graph namespace Returns None if no match Ex. "http://www.drugbank.ca/drugs/DB01268" -> "DB01268" def _getIdentifier(self, url): """ Given a url identifier return identifier portion Leverages ...