INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
Returns server - style compound ID for an internal featureId. | def getCompoundIdForFeatureId(self, featureId):
"""
Returns server-style compound ID for an internal featureId.
:param long featureId: id of feature in database
:return: string representing ID for the specified GA4GH protocol
Feature object in this FeatureSet.
"""
... |
Fetches a simulated feature by ID. | def getFeature(self, compoundId):
"""
Fetches a simulated feature by ID.
:param compoundId: any non-null string
:return: A simulated feature with id set to the same value as the
passed-in compoundId.
":raises: exceptions.ObjectWithIdNotFoundException if None is passe... |
Returns a set number of simulated features. | def getFeatures(self, referenceName=None, start=None, end=None,
startIndex=None, maxResults=None,
featureTypes=None, parentId=None,
name=None, geneSymbol=None, numFeatures=10):
"""
Returns a set number of simulated features.
:param ref... |
Populates the instance variables of this FeatureSet from the specified data URL. | def populateFromFile(self, dataUrl):
"""
Populates the instance variables of this FeatureSet from the specified
data URL.
"""
self._dbFilePath = dataUrl
self._db = Gff3DbBackend(self._dbFilePath) |
Populates the instance variables of this FeatureSet from the specified DB row. | 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._db = Gff3DbBackend(self._dbFil... |
Returns a protocol. Feature object corresponding to a compoundId: param compoundId: a datamodel. FeatureCompoundId object: return: a Feature object.: raises: exceptions. ObjectWithIdNotFoundException if invalid compoundId is provided. | def getFeature(self, compoundId):
"""
Returns a protocol.Feature object corresponding to a compoundId
:param compoundId: a datamodel.FeatureCompoundId object
:return: a Feature object.
:raises: exceptions.ObjectWithIdNotFoundException if invalid
compoundId is provided... |
: param feature: The DB Row representing a feature: return: the corresponding GA4GH protocol. Feature object | def _gaFeatureForFeatureDbRecord(self, feature):
"""
:param feature: The DB Row representing a feature
:return: the corresponding GA4GH protocol.Feature object
"""
gaFeature = protocol.Feature()
gaFeature.id = self.getCompoundIdForFeatureId(feature['id'])
if featu... |
method passed to runSearchRequest to fulfill the request: param str referenceName: name of reference ( ex: chr1 ): param start: castable to int start position on reference: param end: castable to int end position on reference: param startIndex: none or castable to int: param maxResults: none or castable to int: param f... | def getFeatures(self, referenceName=None, start=None, end=None,
startIndex=None, maxResults=None,
featureTypes=None, parentId=None,
name=None, geneSymbol=None):
"""
method passed to runSearchRequest to fulfill the request
:param str ref... |
Add an rnaQuantification to this rnaQuantificationSet | def addRnaQuantification(self, rnaQuantification):
"""
Add an rnaQuantification to this rnaQuantificationSet
"""
id_ = rnaQuantification.getId()
self._rnaQuantificationIdMap[id_] = rnaQuantification
self._rnaQuantificationIds.append(id_) |
Converts this rnaQuant into its GA4GH protocol equivalent. | def toProtocolElement(self):
"""
Converts this rnaQuant into its GA4GH protocol equivalent.
"""
protocolElement = protocol.RnaQuantificationSet()
protocolElement.id = self.getId()
protocolElement.dataset_id = self._parentContainer.getId()
protocolElement.name = se... |
Populates the instance variables of this RnaQuantificationSet from the specified data URL. | def populateFromFile(self, dataUrl):
"""
Populates the instance variables of this RnaQuantificationSet from the
specified data URL.
"""
self._dbFilePath = dataUrl
self._db = SqliteRnaBackend(self._dbFilePath)
self.addRnaQuants() |
Populates the instance variables of this RnaQuantificationSet from the specified DB row. | def populateFromRow(self, quantificationSetRecord):
"""
Populates the instance variables of this RnaQuantificationSet from the
specified DB row.
"""
self._dbFilePath = quantificationSetRecord.dataurl
self.setAttributesJson(quantificationSetRecord.attributes)
self.... |
Converts this rnaQuant into its GA4GH protocol equivalent. | def toProtocolElement(self):
"""
Converts this rnaQuant into its GA4GH protocol equivalent.
"""
protocolElement = protocol.RnaQuantification()
protocolElement.id = self.getId()
protocolElement.name = self._name
protocolElement.description = self._description
... |
data elements are: Id annotations description name readGroupId where annotations is a comma separated list | def addRnaQuantMetadata(self, fields):
"""
data elements are:
Id, annotations, description, name, readGroupId
where annotations is a comma separated list
"""
self._featureSetIds = fields["feature_set_ids"].split(',')
self._description = fields["description"]
... |
input is tab file with no header. Columns are: Id annotations description name readGroupId where annotation is a comma separated list | def getRnaQuantMetadata(self):
"""
input is tab file with no header. Columns are:
Id, annotations, description, name, readGroupId
where annotation is a comma separated list
"""
rnaQuantId = self.getLocalId()
with self._db as dataSource:
rnaQuantReturn... |
Populates the instance variables of this FeatureSet from the specified data URL. | def populateFromFile(self, dataUrl):
"""
Populates the instance variables of this FeatureSet from the specified
data URL.
"""
self._dbFilePath = dataUrl
self._db = SqliteRnaBackend(self._dbFilePath)
self.getRnaQuantMetadata() |
Populates the instance variables of this FeatureSet from the specified DB row. | def populateFromRow(self, row):
"""
Populates the instance variables of this FeatureSet from the specified
DB row.
"""
self._dbFilePath = row[b'dataUrl']
self._db = SqliteRnaBackend(self._dbFilePath)
self.getRnaQuantMetadata() |
Returns the list of ExpressionLevels in this RNA Quantification. | def getExpressionLevels(
self, threshold=0.0, names=[], startIndex=0, maxResults=0):
"""
Returns the list of ExpressionLevels in this RNA Quantification.
"""
rnaQuantificationId = self.getLocalId()
with self._db as dataSource:
expressionsReturned = dataSou... |
: param rnaQuantificationId: string restrict search by id: return an array of dictionaries representing the returned data. | def searchRnaQuantificationsInDb(
self, rnaQuantificationId=""):
"""
:param rnaQuantificationId: string restrict search by id
:return an array of dictionaries, representing the returned data.
"""
sql = ("SELECT * FROM RnaQuantification")
sql_args = ()
... |
: param rnaQuantificationId: the RNA Quantification ID: return: dictionary representing an RnaQuantification object or None if no match is found. | def getRnaQuantificationById(self, rnaQuantificationId):
"""
:param rnaQuantificationId: the RNA Quantification ID
:return: dictionary representing an RnaQuantification object,
or None if no match is found.
"""
sql = ("SELECT * FROM RnaQuantification WHERE id = ?")
... |
: param rnaQuantId: string restrict search by quantification id: param threshold: float minimum expression values to return: return an array of dictionaries representing the returned data. | def searchExpressionLevelsInDb(
self, rnaQuantId, names=[], threshold=0.0, startIndex=0,
maxResults=0):
"""
:param rnaQuantId: string restrict search by quantification id
:param threshold: float minimum expression values to return
:return an array of dictionaries,... |
: param expressionId: the ExpressionLevel ID: return: dictionary representing an ExpressionLevel object or None if no match is found. | def getExpressionLevelById(self, expressionId):
"""
:param expressionId: the ExpressionLevel ID
:return: dictionary representing an ExpressionLevel object,
or None if no match is found.
"""
sql = ("SELECT * FROM Expression WHERE id = ?")
query = self._dbconn.e... |
Populates this CallSet from the specified DB row. | def populateFromRow(self, callSetRecord):
"""
Populates this CallSet from the specified DB row.
"""
self._biosampleId = callSetRecord.biosampleid
self.setAttributesJson(callSetRecord.attributes) |
Returns the representation of this CallSet as the corresponding ProtocolElement. | def toProtocolElement(self):
"""
Returns the representation of this CallSet as the corresponding
ProtocolElement.
"""
variantSet = self.getParentContainer()
gaCallSet = protocol.CallSet(
biosample_id=self.getBiosampleId())
if variantSet.getCreationTime... |
Adds the specified variantAnnotationSet to this dataset. | def addVariantAnnotationSet(self, variantAnnotationSet):
"""
Adds the specified variantAnnotationSet to this dataset.
"""
id_ = variantAnnotationSet.getId()
self._variantAnnotationSetIdMap[id_] = variantAnnotationSet
self._variantAnnotationSetIds.append(id_) |
Returns the AnnotationSet in this dataset with the specified id | def getVariantAnnotationSet(self, id_):
"""
Returns the AnnotationSet in this dataset with the specified 'id'
"""
if id_ not in self._variantAnnotationSetIdMap:
raise exceptions.AnnotationSetNotFoundException(id_)
return self._variantAnnotationSetIdMap[id_] |
Adds the specfied CallSet to this VariantSet. | def addCallSet(self, callSet):
"""
Adds the specfied CallSet to this VariantSet.
"""
callSetId = callSet.getId()
self._callSetIdMap[callSetId] = callSet
self._callSetNameMap[callSet.getLocalId()] = callSet
self._callSetIds.append(callSetId)
self._callSetId... |
Adds a CallSet for the specified sample name. | def addCallSetFromName(self, sampleName):
"""
Adds a CallSet for the specified sample name.
"""
callSet = CallSet(self, sampleName)
self.addCallSet(callSet) |
Returns a CallSet with the specified name or raises a CallSetNameNotFoundException if it does not exist. | def getCallSetByName(self, name):
"""
Returns a CallSet with the specified name, or raises a
CallSetNameNotFoundException if it does not exist.
"""
if name not in self._callSetNameMap:
raise exceptions.CallSetNameNotFoundException(name)
return self._callSetNam... |
Returns a CallSet with the specified id or raises a CallSetNotFoundException if it does not exist. | def getCallSet(self, id_):
"""
Returns a CallSet with the specified id, or raises a
CallSetNotFoundException if it does not exist.
"""
if id_ not in self._callSetIdMap:
raise exceptions.CallSetNotFoundException(id_)
return self._callSetIdMap[id_] |
Converts this VariantSet into its GA4GH protocol equivalent. | def toProtocolElement(self):
"""
Converts this VariantSet into its GA4GH protocol equivalent.
"""
protocolElement = protocol.VariantSet()
protocolElement.id = self.getId()
protocolElement.dataset_id = self.getParentContainer().getId()
protocolElement.reference_set... |
Convenience method to set the common fields in a GA Variant object from this variant set. | def _createGaVariant(self):
"""
Convenience method to set the common fields in a GA Variant
object from this variant set.
"""
ret = protocol.Variant()
if self._creationTime:
ret.created = self._creationTime
if self._updatedTime:
ret.updated... |
Returns an ID string suitable for the specified GA Variant object in this variant set. | def getVariantId(self, gaVariant):
"""
Returns an ID string suitable for the specified GA Variant
object in this variant set.
"""
md5 = self.hashVariant(gaVariant)
compoundId = datamodel.VariantCompoundId(
self.getCompoundId(), gaVariant.reference_name,
... |
Returns the callSetId for the specified sampleName in this VariantSet. | def getCallSetId(self, sampleName):
"""
Returns the callSetId for the specified sampleName in this
VariantSet.
"""
compoundId = datamodel.CallSetCompoundId(
self.getCompoundId(), sampleName)
return str(compoundId) |
Produces an MD5 hash of the ga variant object to distinguish it from other variants at the same genomic coordinate. | def hashVariant(cls, gaVariant):
"""
Produces an MD5 hash of the ga variant object to distinguish
it from other variants at the same genomic coordinate.
"""
hash_str = gaVariant.reference_bases + \
str(tuple(gaVariant.alternate_bases))
return hashlib.md5(hash_... |
Generate a random variant for the specified position using the specified random number generator. This generator should be seeded with a value that is unique to this position so that the same variant will always be produced regardless of the order it is generated in. | def generateVariant(self, referenceName, position, randomNumberGenerator):
"""
Generate a random variant for the specified position using the
specified random number generator. This generator should be seeded
with a value that is unique to this position so that the same variant
w... |
Populates this VariantSet from the specified DB row. | def populateFromRow(self, variantSetRecord):
"""
Populates this VariantSet from the specified DB row.
"""
self._created = variantSetRecord.created
self._updated = variantSetRecord.updated
self.setAttributesJson(variantSetRecord.attributes)
self._chromFileMap = {}
... |
Populates this variant set using the specified lists of data files and indexes. These must be in the same order such that the jth index file corresponds to the jth data file. | def populateFromFile(self, dataUrls, indexFiles):
"""
Populates this variant set using the specified lists of data
files and indexes. These must be in the same order, such that
the jth index file corresponds to the jth data file.
"""
assert len(dataUrls) == len(indexFiles... |
Populates this VariantSet by examing all the VCF files in the specified directory. This is mainly used for as a convenience for testing purposes. | def populateFromDirectory(self, vcfDirectory):
"""
Populates this VariantSet by examing all the VCF files in the
specified directory. This is mainly used for as a convenience
for testing purposes.
"""
pattern = os.path.join(vcfDirectory, "*.vcf.gz")
dataFiles = []... |
Perform consistency check on the variant set | def checkConsistency(self):
"""
Perform consistency check on the variant set
"""
for referenceName, (dataUrl, indexFile) in self._chromFileMap.items():
varFile = pysam.VariantFile(dataUrl, index_filename=indexFile)
try:
for chrom in varFile.index:
... |
Populates the instance variables of this VariantSet from the specified pysam VariantFile object. | def _populateFromVariantFile(self, varFile, dataUrl, indexFile):
"""
Populates the instance variables of this VariantSet from the specified
pysam VariantFile object.
"""
if varFile.index is None:
raise exceptions.NotIndexedException(dataUrl)
for chrom in varFi... |
Updates the variant annotation set associated with this variant using information in the specified pysam variantFile. | def _updateVariantAnnotationSets(self, variantFile, dataUrl):
"""
Updates the variant annotation set associated with this variant using
information in the specified pysam variantFile.
"""
# TODO check the consistency of this between VCF files.
if not self.isAnnotated():
... |
Updates the metadata for his variant set based on the specified variant file | def _updateMetadata(self, variantFile):
"""
Updates the metadata for his variant set based on the specified
variant file
"""
metadata = self._getMetadataFromVcf(variantFile)
if self._metadata is None:
self._metadata = metadata |
Checks that metadata is consistent | def _checkMetadata(self, variantFile):
"""
Checks that metadata is consistent
"""
metadata = self._getMetadataFromVcf(variantFile)
if self._metadata is not None and self._metadata != metadata:
raise exceptions.InconsistentMetaDataException(
variantFile... |
Checks callSetIds for consistency | def _checkCallSetIds(self, variantFile):
"""
Checks callSetIds for consistency
"""
if len(self._callSetIdMap) > 0:
callSetIds = set([
self.getCallSetId(sample)
for sample in variantFile.header.samples])
if callSetIds != set(self._ca... |
Updates the call set IDs based on the specified variant file. | def _updateCallSetIds(self, variantFile):
"""
Updates the call set IDs based on the specified variant file.
"""
if len(self._callSetIdMap) == 0:
for sample in variantFile.header.samples:
self.addCallSetFromName(sample) |
Converts the specified pysam variant record into a GA4GH Variant object. Only calls for the specified list of callSetIds will be included. | def convertVariant(self, record, callSetIds):
"""
Converts the specified pysam variant record into a GA4GH Variant
object. Only calls for the specified list of callSetIds will
be included.
"""
variant = self._createGaVariant()
variant.reference_name = record.conti... |
Returns an iterator over the pysam VCF records corresponding to the specified query. | def getPysamVariants(self, referenceName, startPosition, endPosition):
"""
Returns an iterator over the pysam VCF records corresponding to the
specified query.
"""
if referenceName in self._chromFileMap:
varFileName = self._chromFileMap[referenceName]
refe... |
Returns an iterator over the specified variants. The parameters correspond to the attributes of a GASearchVariantsRequest object. | def getVariants(self, referenceName, startPosition, endPosition,
callSetIds=[]):
"""
Returns an iterator over the specified variants. The parameters
correspond to the attributes of a GASearchVariantsRequest object.
"""
if callSetIds is None:
callSe... |
Returns the id of a metadata | def getMetadataId(self, metadata):
"""
Returns the id of a metadata
"""
return str(datamodel.VariantSetMetadataCompoundId(
self.getCompoundId(), 'metadata:' + metadata.key)) |
Convenience method to set the common fields in a GA VariantAnnotation object from this variant set. | def _createGaVariantAnnotation(self):
"""
Convenience method to set the common fields in a GA VariantAnnotation
object from this variant set.
"""
ret = protocol.VariantAnnotation()
ret.created = self._creationTime
ret.variant_annotation_set_id = self.getId()
... |
Converts this VariantAnnotationSet into its GA4GH protocol equivalent. | def toProtocolElement(self):
"""
Converts this VariantAnnotationSet into its GA4GH protocol equivalent.
"""
protocolElement = protocol.VariantAnnotationSet()
protocolElement.id = self.getId()
protocolElement.variant_set_id = self._variantSet.getId()
protocolElemen... |
Produces an MD5 hash of the gaVariant and gaVariantAnnotation objects | def hashVariantAnnotation(cls, gaVariant, gaVariantAnnotation):
"""
Produces an MD5 hash of the gaVariant and gaVariantAnnotation objects
"""
treffs = [treff.id for treff in gaVariantAnnotation.transcript_effects]
return hashlib.md5(
"{}\t{}\t{}\t".format(
... |
Produces a stringified compoundId representing a variant annotation.: param gaVariant: protocol. Variant: param gaAnnotation: protocol. VariantAnnotation: return: compoundId String | def getVariantAnnotationId(self, gaVariant, gaAnnotation):
"""
Produces a stringified compoundId representing a variant
annotation.
:param gaVariant: protocol.Variant
:param gaAnnotation: protocol.VariantAnnotation
:return: compoundId String
"""
md5 = s... |
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. | 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 ... |
Populates this VariantAnnotationSet from the specified DB row. | def populateFromRow(self, annotationSetRecord):
"""
Populates this VariantAnnotationSet from the specified DB row.
"""
self._annotationType = annotationSetRecord.annotationtype
self._analysis = protocol.fromJson(
annotationSetRecord.analysis, protocol.Analysis)
... |
Assembles metadata within the VCF header into a GA4GH Analysis object. | 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... |
Generator for iterating through variant annotations in this variant annotation set.: param referenceName:: param startPosition:: param endPosition:: return: generator of protocol. VariantAnnotation | 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... |
Accepts a position string ( start/ length ) and returns a GA4GH AlleleLocation with populated fields.: param pos:: return: protocol. AlleleLocation | 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 an annotation in HGVS notation and returns an AlleleLocation with populated fields.: param hgvsc:: return: | 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 hgvsp:: return: protocol. AlleleLocation | 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... |
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 location: return: effect protocol. Tra... | 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... |
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 () | 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()
"""
... |
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 ] | 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 [
... |
Converts the specfied pysam variant record into a GA4GH variant annotation object using the specified function to convert the transcripts. | 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._... |
Return name = value for a single attribute | 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 semi - colon - separated string for attributes including url - style quoting | 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()]) |
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. | 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:
... |
Link a feature with its parents. | 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 children | 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),
... |
finish loading the set constructing the tree | 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) |
Sort order for Features by genomic coordinate disambiguated by feature type ( alphabetically ). | def _recSortKey(r):
"""
Sort order for Features, by genomic coordinate,
disambiguated by feature type (alphabetically).
"""
return r.seqname, r.start, -r.end, r.type |
Writes a single record to a file provided by the filehandle fh. | 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) |
Write set to a GFF3 format file. | 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) |
open input file optionally with decompression | 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... |
Returns tuple of tuple of ( attr value ) multiple are returned to handle multi - value attributes. | 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: '"... |
Parse the attributes and values | 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 one record. | 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)),
... |
Run the parse and return the resulting Gff3Set object. | 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... |
Adds the specified dataset to this data repository. | 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 reference set to this data repository. | 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... |
Add an ontology map to this data repository. | 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()) |
Select the first peer in the datarepo with the given url simulating the behavior of selecting by URL. This is only used during testing. | 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... |
Returns a dataset with the specified ID or raises a DatasetNotFoundException if it does not exist. | 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 the dataset with the specified name. | 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 ontology with the specified ID. | 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 an ontology by name | def getOntologyByName(self, name):
"""
Returns an ontology by name
"""
if name not in self._ontologyNameMap:
raise exceptions.OntologyNameNotFoundException(name)
return self._ontologyNameMap[name] |
Retuns the ReferenceSet with the specified ID or raises a ReferenceSetNotFoundException if it does not exist. | 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... |
Returns the reference set with the specified name. | 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 readgroup set with the specified ID. | 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. | 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_) |
Prints a summary of this data repository to stdout. | 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... |
Return an iterator over all read groups in the data repo | 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 features in the data repo | 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 call sets in the data repo | 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 variant annotation sets in the data repo | 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 rna quantifications | 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 expression levels | 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... |
Finds a peer by URL and return the first peer record with that URL. | 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] |
Get the list of peers using an SQL offset and limit. Returns a list of peer datamodel objects in a list. | 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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.