sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
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 ...
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.
entailment
def populateFromRow(self, annotationSetRecord): """ Populates this VariantAnnotationSet from the specified DB row. """ self._annotationType = annotationSetRecord.annotationtype self._analysis = protocol.fromJson( annotationSetRecord.analysis, protocol.Analysis) ...
Populates this VariantAnnotationSet from the specified DB row.
entailment
def _getAnnotationAnalysis(self, varFile): """ Assembles metadata within the VCF header into a GA4GH Analysis object. :return: protocol.Analysis """ header = varFile.header analysis = protocol.Analysis() formats = header.formats.items() infos = header.inf...
Assembles metadata within the VCF header into a GA4GH Analysis object. :return: protocol.Analysis
entailment
def getVariantAnnotations(self, referenceName, startPosition, endPosition): """ Generator for iterating through variant annotations in this variant annotation set. :param referenceName: :param startPosition: :param endPosition: :return: generator of protocol.Varia...
Generator for iterating through variant annotations in this variant annotation set. :param referenceName: :param startPosition: :param endPosition: :return: generator of protocol.VariantAnnotation
entailment
def convertLocation(self, pos): """ Accepts a position string (start/length) and returns a GA4GH AlleleLocation with populated fields. :param pos: :return: protocol.AlleleLocation """ if isUnspecified(pos): return None coordLen = pos.split('/')...
Accepts a position string (start/length) and returns a GA4GH AlleleLocation with populated fields. :param pos: :return: protocol.AlleleLocation
entailment
def convertLocationHgvsC(self, hgvsc): """ Accepts an annotation in HGVS notation and returns an AlleleLocation with populated fields. :param hgvsc: :return: """ if isUnspecified(hgvsc): return None match = re.match(".*c.(\d+)(\D+)>(\D+)", hgvs...
Accepts an annotation in HGVS notation and returns an AlleleLocation with populated fields. :param hgvsc: :return:
entailment
def convertLocationHgvsP(self, hgvsp): """ Accepts an annotation in HGVS notation and returns an AlleleLocation with populated fields. :param hgvsp: :return: protocol.AlleleLocation """ if isUnspecified(hgvsp): return None match = re.match(".*p...
Accepts an annotation in HGVS notation and returns an AlleleLocation with populated fields. :param hgvsp: :return: protocol.AlleleLocation
entailment
def addLocations(self, effect, protPos, cdnaPos): """ Adds locations to a GA4GH transcript effect object by parsing HGVS annotation fields in concert with and supplied position values. :param effect: protocol.TranscriptEffect :param protPos: String representing protein po...
Adds locations to a GA4GH transcript effect object by parsing HGVS annotation fields in concert with and supplied position values. :param effect: protocol.TranscriptEffect :param protPos: String representing protein position from VCF :param cdnaPos: String representing coding DNA...
entailment
def convertTranscriptEffect(self, annStr, hgvsG): """ Takes the ANN string of a SnpEff generated VCF, splits it and returns a populated GA4GH transcript effect object. :param annStr: String :param hgvsG: String :return: effect protocol.TranscriptEffect() """ ...
Takes the ANN string of a SnpEff generated VCF, splits it and returns a populated GA4GH transcript effect object. :param annStr: String :param hgvsG: String :return: effect protocol.TranscriptEffect()
entailment
def convertSeqOntology(self, seqOntStr): """ Splits a string of sequence ontology effects and creates an ontology term record for each, which are built into an array of return soTerms. :param seqOntStr: :return: [protocol.OntologyTerm] """ return [ ...
Splits a string of sequence ontology effects and creates an ontology term record for each, which are built into an array of return soTerms. :param seqOntStr: :return: [protocol.OntologyTerm]
entailment
def convertVariantAnnotation(self, record): """ Converts the specfied pysam variant record into a GA4GH variant annotation object using the specified function to convert the transcripts. """ variant = self._variantSet.convertVariant(record, []) annotation = self._...
Converts the specfied pysam variant record into a GA4GH variant annotation object using the specified function to convert the transcripts.
entailment
def _attributeStr(self, name): """ Return name=value for a single attribute """ return "{}={}".format( _encodeAttr(name), ",".join([_encodeAttr(v) for v in self.attributes[name]]))
Return name=value for a single attribute
entailment
def _attributeStrs(self): """ Return name=value, semi-colon-separated string for attributes, including url-style quoting """ return ";".join([self._attributeStr(name) for name in self.attributes.iterkeys()])
Return name=value, semi-colon-separated string for attributes, including url-style quoting
entailment
def featureName(self): """ ID attribute from GFF3 or None if record doesn't have it. Called "Name" rather than "Id" within GA4GH, as there is no guarantee of either uniqueness or existence. """ featId = self.attributes.get("ID") if featId is not None: ...
ID attribute from GFF3 or None if record doesn't have it. Called "Name" rather than "Id" within GA4GH, as there is no guarantee of either uniqueness or existence.
entailment
def _linkFeature(self, feature): """ Link a feature with its parents. """ parentNames = feature.attributes.get("Parent") if parentNames is None: self.roots.add(feature) else: for parentName in parentNames: self._linkToParent(feature...
Link a feature with its parents.
entailment
def _linkToParent(self, feature, parentName): """ Link a feature with its children """ parentParts = self.byFeatureName.get(parentName) if parentParts is None: raise GFF3Exception( "Parent feature does not exist: {}".format(parentName), ...
Link a feature with its children
entailment
def linkChildFeaturesToParents(self): """ finish loading the set, constructing the tree """ # features maybe disjoint for featureParts in self.byFeatureName.itervalues(): for feature in featureParts: self._linkFeature(feature)
finish loading the set, constructing the tree
entailment
def _recSortKey(r): """ Sort order for Features, by genomic coordinate, disambiguated by feature type (alphabetically). """ return r.seqname, r.start, -r.end, r.type
Sort order for Features, by genomic coordinate, disambiguated by feature type (alphabetically).
entailment
def _writeRec(self, fh, rec): """ Writes a single record to a file provided by the filehandle fh. """ fh.write(str(rec) + "\n") for child in sorted(rec.children, key=self._recSortKey): self._writeRec(fh, child)
Writes a single record to a file provided by the filehandle fh.
entailment
def write(self, fh): """ Write set to a GFF3 format file. :param file fh: file handle for file to write to """ fh.write(GFF3_HEADER+"\n") for root in sorted(self.roots, key=self._recSortKey): self._writeRec(fh, root)
Write set to a GFF3 format file. :param file fh: file handle for file to write to
entailment
def _open(self): """ open input file, optionally with decompression """ if self.fileName.endswith(".gz"): return gzip.open(self.fileName) elif self.fileName.endswith(".bz2"): return bz2.BZ2File(self.fileName) else: return open(self.file...
open input file, optionally with decompression
entailment
def _parseAttrVal(self, attrStr): """ Returns tuple of tuple of (attr, value), multiple are returned to handle multi-value attributes. """ m = self.SPLIT_ATTR_RE.match(attrStr) if m is None: raise GFF3Exception( "can't parse attribute/value: '"...
Returns tuple of tuple of (attr, value), multiple are returned to handle multi-value attributes.
entailment
def _parseAttrs(self, attrsStr): """ Parse the attributes and values """ attributes = dict() for attrStr in self.SPLIT_ATTR_COL_RE.split(attrsStr): name, vals = self._parseAttrVal(attrStr) if name in attributes: raise GFF3Exception( ...
Parse the attributes and values
entailment
def _parseRecord(self, gff3Set, line): """ Parse one record. """ row = line.split("\t") if len(row) != self.GFF3_NUM_COLS: raise GFF3Exception( "Wrong number of columns, expected {}, got {}".format( self.GFF3_NUM_COLS, len(row)), ...
Parse one record.
entailment
def parse(self): """ Run the parse and return the resulting Gff3Set object. """ fh = self._open() try: gff3Set = Gff3Set(self.fileName) for line in fh: self.lineNumber += 1 self._parseLine(gff3Set, line[0:-1]) finall...
Run the parse and return the resulting Gff3Set object.
entailment
def addDataset(self, dataset): """ Adds the specified dataset to this data repository. """ id_ = dataset.getId() self._datasetIdMap[id_] = dataset self._datasetNameMap[dataset.getLocalId()] = dataset self._datasetIds.append(id_)
Adds the specified dataset to this data repository.
entailment
def addReferenceSet(self, referenceSet): """ Adds the specified reference set to this data repository. """ id_ = referenceSet.getId() self._referenceSetIdMap[id_] = referenceSet self._referenceSetNameMap[referenceSet.getLocalId()] = referenceSet self._referenceSet...
Adds the specified reference set to this data repository.
entailment
def addOntology(self, ontology): """ Add an ontology map to this data repository. """ self._ontologyNameMap[ontology.getName()] = ontology self._ontologyIdMap[ontology.getId()] = ontology self._ontologyIds.append(ontology.getId())
Add an ontology map to this data repository.
entailment
def getPeer(self, url): """ Select the first peer in the datarepo with the given url simulating the behavior of selecting by URL. This is only used during testing. """ peers = filter(lambda x: x.getUrl() == url, self.getPeers()) if len(peers) == 0: raise excep...
Select the first peer in the datarepo with the given url simulating the behavior of selecting by URL. This is only used during testing.
entailment
def getDataset(self, id_): """ Returns a dataset with the specified ID, or raises a DatasetNotFoundException if it does not exist. """ if id_ not in self._datasetIdMap: raise exceptions.DatasetNotFoundException(id_) return self._datasetIdMap[id_]
Returns a dataset with the specified ID, or raises a DatasetNotFoundException if it does not exist.
entailment
def getDatasetByName(self, name): """ Returns the dataset with the specified name. """ if name not in self._datasetNameMap: raise exceptions.DatasetNameNotFoundException(name) return self._datasetNameMap[name]
Returns the dataset with the specified name.
entailment
def getOntology(self, id_): """ Returns the ontology with the specified ID. """ if id_ not in self._ontologyIdMap: raise exceptions.OntologyNotFoundException(id_) return self._ontologyIdMap[id_]
Returns the ontology with the specified ID.
entailment
def getOntologyByName(self, name): """ Returns an ontology by name """ if name not in self._ontologyNameMap: raise exceptions.OntologyNameNotFoundException(name) return self._ontologyNameMap[name]
Returns an ontology by name
entailment
def getReferenceSet(self, id_): """ Retuns the ReferenceSet with the specified ID, or raises a ReferenceSetNotFoundException if it does not exist. """ if id_ not in self._referenceSetIdMap: raise exceptions.ReferenceSetNotFoundException(id_) return self._refer...
Retuns the ReferenceSet with the specified ID, or raises a ReferenceSetNotFoundException if it does not exist.
entailment
def getReferenceSetByName(self, name): """ Returns the reference set with the specified name. """ if name not in self._referenceSetNameMap: raise exceptions.ReferenceSetNameNotFoundException(name) return self._referenceSetNameMap[name]
Returns the reference set with the specified name.
entailment
def getReadGroupSet(self, id_): """ Returns the readgroup set with the specified ID. """ compoundId = datamodel.ReadGroupSetCompoundId.parse(id_) dataset = self.getDataset(compoundId.dataset_id) return dataset.getReadGroupSet(id_)
Returns the readgroup set with the specified ID.
entailment
def getVariantSet(self, id_): """ Returns the readgroup set with the specified ID. """ compoundId = datamodel.VariantSetCompoundId.parse(id_) dataset = self.getDataset(compoundId.dataset_id) return dataset.getVariantSet(id_)
Returns the readgroup set with the specified ID.
entailment
def printSummary(self): """ Prints a summary of this data repository to stdout. """ print("Ontologies:") for ontology in self.getOntologys(): print( "", ontology.getOntologyPrefix(), ontology.getName(), o...
Prints a summary of this data repository to stdout.
entailment
def allReadGroups(self): """ Return an iterator over all read groups in the data repo """ for dataset in self.getDatasets(): for readGroupSet in dataset.getReadGroupSets(): for readGroup in readGroupSet.getReadGroups(): yield readGroup
Return an iterator over all read groups in the data repo
entailment
def allFeatures(self): """ Return an iterator over all features in the data repo """ for dataset in self.getDatasets(): for featureSet in dataset.getFeatureSets(): for feature in featureSet.getFeatures(): yield feature
Return an iterator over all features in the data repo
entailment
def allCallSets(self): """ Return an iterator over all call sets in the data repo """ for dataset in self.getDatasets(): for variantSet in dataset.getVariantSets(): for callSet in variantSet.getCallSets(): yield callSet
Return an iterator over all call sets in the data repo
entailment
def allVariantAnnotationSets(self): """ Return an iterator over all variant annotation sets in the data repo """ for dataset in self.getDatasets(): for variantSet in dataset.getVariantSets(): for vaSet in variantSet.getVariantAnnotationSets(): ...
Return an iterator over all variant annotation sets in the data repo
entailment
def allRnaQuantifications(self): """ Return an iterator over all rna quantifications """ for dataset in self.getDatasets(): for rnaQuantificationSet in dataset.getRnaQuantificationSets(): for rnaQuantification in \ rnaQuantificationSet....
Return an iterator over all rna quantifications
entailment
def allExpressionLevels(self): """ Return an iterator over all expression levels """ for dataset in self.getDatasets(): for rnaQuantificationSet in dataset.getRnaQuantificationSets(): for rnaQuantification in \ rnaQuantificationSet.getR...
Return an iterator over all expression levels
entailment
def getPeer(self, url): """ Finds a peer by URL and return the first peer record with that URL. """ peers = list(models.Peer.select().where(models.Peer.url == url)) if len(peers) == 0: raise exceptions.PeerNotFoundException(url) return peers[0]
Finds a peer by URL and return the first peer record with that URL.
entailment
def getPeers(self, offset=0, limit=1000): """ Get the list of peers using an SQL offset and limit. Returns a list of peer datamodel objects in a list. """ select = models.Peer.select().order_by( models.Peer.url).limit(limit).offset(offset) return [peers.Peer(p...
Get the list of peers using an SQL offset and limit. Returns a list of peer datamodel objects in a list.
entailment
def tableToTsv(self, model): """ Takes a model class and attempts to create a table in TSV format that can be imported into a spreadsheet program. """ first = True for item in model.select(): if first: header = "".join( ["{}...
Takes a model class and attempts to create a table in TSV format that can be imported into a spreadsheet program.
entailment
def clearAnnouncements(self): """ Flushes the announcement table. """ try: q = models.Announcement.delete().where( models.Announcement.id > 0) q.execute() except Exception as e: raise exceptions.RepoManagerException(e)
Flushes the announcement table.
entailment
def insertAnnouncement(self, announcement): """ Adds an announcement to the registry for later analysis. """ url = announcement.get('url', None) try: peers.Peer(url) except: raise exceptions.BadUrlException(url) try: # TODO get ...
Adds an announcement to the registry for later analysis.
entailment
def open(self, mode=MODE_READ): """ Opens this repo in the specified mode. TODO: figure out the correct semantics of this and document the intended future behaviour as well as the current transitional behaviour. """ if mode not in [MODE_READ, MODE_WRITE]: ...
Opens this repo in the specified mode. TODO: figure out the correct semantics of this and document the intended future behaviour as well as the current transitional behaviour.
entailment
def verify(self): """ Verifies that the data in the repository is consistent. """ # TODO this should emit to a log that we can configure so we can # have verbosity levels. We should provide a way to configure # where we look at various chromosomes and so on. This will be ...
Verifies that the data in the repository is consistent.
entailment
def insertOntology(self, ontology): """ Inserts the specified ontology into this repository. """ try: models.Ontology.create( id=ontology.getName(), name=ontology.getName(), dataurl=ontology.getDataUrl(), ...
Inserts the specified ontology into this repository.
entailment
def removeOntology(self, ontology): """ Removes the specified ontology term map from this repository. """ q = models.Ontology.delete().where(id == ontology.getId()) q.execute()
Removes the specified ontology term map from this repository.
entailment
def insertReference(self, reference): """ Inserts the specified reference into this repository. """ models.Reference.create( id=reference.getId(), referencesetid=reference.getParentContainer().getId(), name=reference.getLocalId(), length=re...
Inserts the specified reference into this repository.
entailment
def insertReferenceSet(self, referenceSet): """ Inserts the specified referenceSet into this repository. """ try: models.Referenceset.create( id=referenceSet.getId(), name=referenceSet.getLocalId(), description=referenceSet.getD...
Inserts the specified referenceSet into this repository.
entailment
def insertDataset(self, dataset): """ Inserts the specified dataset into this repository. """ try: models.Dataset.create( id=dataset.getId(), name=dataset.getLocalId(), description=dataset.getDescription(), attri...
Inserts the specified dataset into this repository.
entailment
def removeDataset(self, dataset): """ Removes the specified dataset from this repository. This performs a cascading removal of all items within this dataset. """ for datasetRecord in models.Dataset.select().where( models.Dataset.id == dataset.getId()): ...
Removes the specified dataset from this repository. This performs a cascading removal of all items within this dataset.
entailment
def removePhenotypeAssociationSet(self, phenotypeAssociationSet): """ Remove a phenotype association set from the repo """ q = models.Phenotypeassociationset.delete().where( models.Phenotypeassociationset.id == phenotypeAssociationSet.getId()) q.execute()
Remove a phenotype association set from the repo
entailment
def removeFeatureSet(self, featureSet): """ Removes the specified featureSet from this repository. """ q = models.Featureset.delete().where( models.Featureset.id == featureSet.getId()) q.execute()
Removes the specified featureSet from this repository.
entailment
def removeContinuousSet(self, continuousSet): """ Removes the specified continuousSet from this repository. """ q = models.ContinuousSet.delete().where( models.ContinuousSet.id == continuousSet.getId()) q.execute()
Removes the specified continuousSet from this repository.
entailment
def insertReadGroup(self, readGroup): """ Inserts the specified readGroup into the DB. """ statsJson = json.dumps(protocol.toJsonDict(readGroup.getStats())) experimentJson = json.dumps( protocol.toJsonDict(readGroup.getExperiment())) try: models.Re...
Inserts the specified readGroup into the DB.
entailment
def removeReadGroupSet(self, readGroupSet): """ Removes the specified readGroupSet from this repository. This performs a cascading removal of all items within this readGroupSet. """ for readGroupSetRecord in models.Readgroupset.select().where( models.Readg...
Removes the specified readGroupSet from this repository. This performs a cascading removal of all items within this readGroupSet.
entailment
def removeVariantSet(self, variantSet): """ Removes the specified variantSet from this repository. This performs a cascading removal of all items within this variantSet. """ for variantSetRecord in models.Variantset.select().where( models.Variantset.id == ...
Removes the specified variantSet from this repository. This performs a cascading removal of all items within this variantSet.
entailment
def removeBiosample(self, biosample): """ Removes the specified biosample from this repository. """ q = models.Biosample.delete().where( models.Biosample.id == biosample.getId()) q.execute()
Removes the specified biosample from this repository.
entailment
def removeIndividual(self, individual): """ Removes the specified individual from this repository. """ q = models.Individual.delete().where( models.Individual.id == individual.getId()) q.execute()
Removes the specified individual from this repository.
entailment
def insertReadGroupSet(self, readGroupSet): """ Inserts a the specified readGroupSet into this repository. """ programsJson = json.dumps( [protocol.toJsonDict(program) for program in readGroupSet.getPrograms()]) statsJson = json.dumps(protocol.toJsonDict(...
Inserts a the specified readGroupSet into this repository.
entailment
def removeReferenceSet(self, referenceSet): """ Removes the specified referenceSet from this repository. This performs a cascading removal of all references within this referenceSet. However, it does not remove any of the ReadGroupSets or items that refer to this ReferenceSet. Th...
Removes the specified referenceSet from this repository. This performs a cascading removal of all references within this referenceSet. However, it does not remove any of the ReadGroupSets or items that refer to this ReferenceSet. These must be deleted before the referenceSet can be remov...
entailment
def insertVariantAnnotationSet(self, variantAnnotationSet): """ Inserts a the specified variantAnnotationSet into this repository. """ analysisJson = json.dumps( protocol.toJsonDict(variantAnnotationSet.getAnalysis())) try: models.Variantannotationset.crea...
Inserts a the specified variantAnnotationSet into this repository.
entailment
def insertCallSet(self, callSet): """ Inserts a the specified callSet into this repository. """ try: models.Callset.create( id=callSet.getId(), name=callSet.getLocalId(), variantsetid=callSet.getParentContainer().getId(), ...
Inserts a the specified callSet into this repository.
entailment
def insertVariantSet(self, variantSet): """ Inserts a the specified variantSet into this repository. """ # We cheat a little here with the VariantSetMetadata, and encode these # within the table as a JSON dump. These should really be stored in # their own table me...
Inserts a the specified variantSet into this repository.
entailment
def insertFeatureSet(self, featureSet): """ Inserts a the specified featureSet into this repository. """ # TODO add support for info and sourceUri fields. try: models.Featureset.create( id=featureSet.getId(), datasetid=featureSet.getPar...
Inserts a the specified featureSet into this repository.
entailment
def insertContinuousSet(self, continuousSet): """ Inserts a the specified continuousSet into this repository. """ # TODO add support for info and sourceUri fields. try: models.ContinuousSet.create( id=continuousSet.getId(), datasetid=co...
Inserts a the specified continuousSet into this repository.
entailment
def insertBiosample(self, biosample): """ Inserts the specified Biosample into this repository. """ try: models.Biosample.create( id=biosample.getId(), datasetid=biosample.getParentContainer().getId(), name=biosample.getLocalId(...
Inserts the specified Biosample into this repository.
entailment
def insertIndividual(self, individual): """ Inserts the specified individual into this repository. """ try: models.Individual.create( id=individual.getId(), datasetId=individual.getParentContainer().getId(), name=individual.getL...
Inserts the specified individual into this repository.
entailment
def insertPhenotypeAssociationSet(self, phenotypeAssociationSet): """ Inserts the specified phenotype annotation set into this repository. """ datasetId = phenotypeAssociationSet.getParentContainer().getId() attributes = json.dumps(phenotypeAssociationSet.getAttributes()) ...
Inserts the specified phenotype annotation set into this repository.
entailment
def insertRnaQuantificationSet(self, rnaQuantificationSet): """ Inserts a the specified rnaQuantificationSet into this repository. """ try: models.Rnaquantificationset.create( id=rnaQuantificationSet.getId(), datasetid=rnaQuantificationSet.getP...
Inserts a the specified rnaQuantificationSet into this repository.
entailment
def removeRnaQuantificationSet(self, rnaQuantificationSet): """ Removes the specified rnaQuantificationSet from this repository. This performs a cascading removal of all items within this rnaQuantificationSet. """ q = models.Rnaquantificationset.delete().where( ...
Removes the specified rnaQuantificationSet from this repository. This performs a cascading removal of all items within this rnaQuantificationSet.
entailment
def insertPeer(self, peer): """ Accepts a peer datamodel object and adds it to the registry. """ try: models.Peer.create( url=peer.getUrl(), attributes=json.dumps(peer.getAttributes())) except Exception as e: raise exception...
Accepts a peer datamodel object and adds it to the registry.
entailment
def removePeer(self, url): """ Remove peers by URL. """ q = models.Peer.delete().where( models.Peer.url == url) q.execute()
Remove peers by URL.
entailment
def initialise(self): """ Initialise this data repository, creating any necessary directories and file paths. """ self._checkWriteMode() self._createSystemTable() self._createNetworkTables() self._createOntologyTable() self._createReferenceSetTable...
Initialise this data repository, creating any necessary directories and file paths.
entailment
def load(self): """ Loads this data repository into memory. """ self._readSystemTable() self._readOntologyTable() self._readReferenceSetTable() self._readReferenceTable() self._readDatasetTable() self._readReadGroupSetTable() self._readRead...
Loads this data repository into memory.
entailment
def populateFromRow(self, featureSetRecord): """ Populates the instance variables of this FeatureSet from the specified DB row. """ self._dbFilePath = featureSetRecord.dataurl self.setAttributesJson(featureSetRecord.attributes) self.populateFromFile(self._dbFilePa...
Populates the instance variables of this FeatureSet from the specified DB row.
entailment
def populateFromFile(self, dataUrl): """ Populates the instance variables of this FeatureSet from the specified data URL. Initialize dataset, using the passed dict of sources [{source,format}] see rdflib.parse() for more If path is set, this backend will load itself ...
Populates the instance variables of this FeatureSet from the specified data URL. Initialize dataset, using the passed dict of sources [{source,format}] see rdflib.parse() for more If path is set, this backend will load itself
entailment
def getFeature(self, compoundId): """ find a feature and return ga4gh representation, use compoundId as featureId """ feature = self._getFeatureById(compoundId.featureId) feature.id = str(compoundId) return feature
find a feature and return ga4gh representation, use compoundId as featureId
entailment
def _getFeatureById(self, featureId): """ find a feature and return ga4gh representation, use 'native' id as featureId """ featureRef = rdflib.URIRef(featureId) featureDetails = self._detailTuples([featureRef]) feature = {} for detail in featureDetails: ...
find a feature and return ga4gh representation, use 'native' id as featureId
entailment
def _filterSearchFeaturesRequest(self, reference_name, gene_symbol, name, start, end): """ formulate a sparql query string based on parameters """ filters = [] query = self._baseQuery() filters = [] location = self._findLocatio...
formulate a sparql query string based on parameters
entailment
def _findLocation(self, reference_name, start, end): """ return a location key form the locationMap """ try: # TODO - sequence_annotations does not have build? return self._locationMap['hg19'][reference_name][start][end] except: return None
return a location key form the locationMap
entailment
def _initializeLocationCache(self): """ CGD uses Faldo ontology for locations, it's a bit complicated. This function sets up an in memory cache of all locations, which can be queried via: locationMap[build][chromosome][begin][end] = location["_id"] """ # cache of ...
CGD uses Faldo ontology for locations, it's a bit complicated. This function sets up an in memory cache of all locations, which can be queried via: locationMap[build][chromosome][begin][end] = location["_id"]
entailment
def addValue(self, protocolElement): """ Appends the specified protocolElement to the value list for this response. """ self._numElements += 1 self._bufferSize += protocolElement.ByteSize() attr = getattr(self._protoObject, self._valueListName) obj = attr....
Appends the specified protocolElement to the value list for this response.
entailment
def isFull(self): """ Returns True if the response buffer is full, and False otherwise. The buffer is full if either (1) the number of items in the value list is >= pageSize or (2) the total length of the serialised elements in the page is >= maxBufferSize. If page_size ...
Returns True if the response buffer is full, and False otherwise. The buffer is full if either (1) the number of items in the value list is >= pageSize or (2) the total length of the serialised elements in the page is >= maxBufferSize. If page_size or max_response_length were not set in...
entailment
def getSerializedResponse(self): """ Returns a string version of the SearchResponse that has been built by this SearchResponseBuilder. """ self._protoObject.next_page_token = pb.string(self._nextPageToken) s = protocol.toJson(self._protoObject) return s
Returns a string version of the SearchResponse that has been built by this SearchResponseBuilder.
entailment
def populateFromRow(self, ontologyRecord): """ Populates this Ontology using values in the specified DB row. """ self._id = ontologyRecord.id self._dataUrl = ontologyRecord.dataurl self._readFile()
Populates this Ontology using values in the specified DB row.
entailment
def getGaTermByName(self, name): """ Returns a GA4GH OntologyTerm object by name. :param name: name of the ontology term, ex. "gene". :return: GA4GH OntologyTerm object. """ # TODO what is the correct value when we have no mapping?? termIds = self.getTermIds(name...
Returns a GA4GH OntologyTerm object by name. :param name: name of the ontology term, ex. "gene". :return: GA4GH OntologyTerm object.
entailment
def _heavyQuery(variantSetId, callSetIds): """ Very heavy query: calls for the specified list of callSetIds on chromosome 2 (11 pages, 90 seconds to fetch the entire thing on a high-end desktop machine) """ request = protocol.SearchVariantsRequest() request.reference_name = '2' request.v...
Very heavy query: calls for the specified list of callSetIds on chromosome 2 (11 pages, 90 seconds to fetch the entire thing on a high-end desktop machine)
entailment
def timeOneSearch(queryString): """ Returns (search result as JSON string, time elapsed during search) """ startTime = time.clock() resultString = backend.runSearchVariants(queryString) endTime = time.clock() elapsedTime = endTime - startTime return resultString, elapsedTime
Returns (search result as JSON string, time elapsed during search)
entailment
def benchmarkOneQuery(request, repeatLimit=3, pageLimit=3): """ Repeat the query several times; perhaps don't go through *all* the pages. Returns minimum time to run backend.searchVariants() to execute the query (as far as pageLimit allows), *not* including JSON processing to prepare queries or par...
Repeat the query several times; perhaps don't go through *all* the pages. Returns minimum time to run backend.searchVariants() to execute the query (as far as pageLimit allows), *not* including JSON processing to prepare queries or parse responses.
entailment
def getExceptionClass(errorCode): """ Converts the specified error code into the corresponding class object. Raises a KeyError if the errorCode is not found. """ classMap = {} for name, class_ in inspect.getmembers(sys.modules[__name__]): if inspect.isclass(class_) and issubclass(class_,...
Converts the specified error code into the corresponding class object. Raises a KeyError if the errorCode is not found.
entailment
def toProtocolElement(self): """ Converts this exception into the GA4GH protocol type so that it can be communicated back to the client. """ error = protocol.GAException() error.error_code = self.getErrorCode() error.message = self.getMessage() return erro...
Converts this exception into the GA4GH protocol type so that it can be communicated back to the client.
entailment
def _init_goterm_ref(self, rec_curr, name, lnum): """Initialize new reference and perform checks.""" if rec_curr is None: return GOTerm() msg = "PREVIOUS {REC} WAS NOT TERMINATED AS EXPECTED".format(REC=name) self._die(msg, lnum)
Initialize new reference and perform checks.
entailment
def _init_typedef(self, typedef_curr, name, lnum): """Initialize new typedef and perform checks.""" if typedef_curr is None: return TypeDef() msg = "PREVIOUS {REC} WAS NOT TERMINATED AS EXPECTED".format(REC=name) self._die(msg, lnum)
Initialize new typedef and perform checks.
entailment