text_prompt
stringlengths
157
13.1k
code_prompt
stringlengths
7
19.8k
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def isUrl(urlString): """ Attempts to return whether a given URL string is valid by checking for the presence of the URL scheme and netloc using the urlparse mod...
parsed = urlparse.urlparse(urlString) urlparseValid = parsed.netloc != '' and parsed.scheme != '' regex = re.compile( r'^(?:http|ftp)s?://' # http:// or https:// r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)' r'+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' # domain... r'localhos...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def setUrl(self, url): """ Attempt to safely set the URL by string. """
if isUrl(url): self._url = url else: raise exceptions.BadUrlException(url) return self
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def setAttributesJson(self, attributesJson): """ Sets the attributes dictionary from a JSON string. """
try: self._attributes = json.loads(attributesJson) except: raise exceptions.InvalidJsonException(attributesJson) return self
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def populateFromRow(self, peerRecord): """ This method accepts a model record and sets class variables. """
self.setUrl(peerRecord.url) \ .setAttributesJson(peerRecord.attributes) return self
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def _protocolListGenerator(self, request, objectList): """ Returns a generator over the objects in the specified list using _protocolObjectGenerator to generate ...
return self._protocolObjectGenerator( request, len(objectList), lambda index: objectList[index])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def _objectListGenerator(self, request, objectList): """ Returns a generator over the objects in the specified list using _topLevelObjectGenerator to generate pa...
return self._topLevelObjectGenerator( request, len(objectList), lambda index: objectList[index])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def runGetRequest(self, obj): """ Runs a get request by converting the specified datamodel object into its protocol representation. """
protocolElement = obj.toProtocolElement() jsonString = protocol.toJson(protocolElement) return jsonString
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def runListReferenceBases(self, requestJson): """ Runs a listReferenceBases request for the specified ID and request arguments. """
# In the case when an empty post request is made to the endpoint # we instantiate an empty ListReferenceBasesRequest. if not requestJson: request = protocol.ListReferenceBasesRequest() else: try: request = protocol.fromJson( re...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def runGetCallSet(self, id_): """ Returns a callset with the given id """
compoundId = datamodel.CallSetCompoundId.parse(id_) dataset = self.getDataRepository().getDataset(compoundId.dataset_id) variantSet = dataset.getVariantSet(compoundId.variant_set_id) callSet = variantSet.getCallSet(id_) return self.runGetRequest(callSet)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def runGetInfo(self, request): """ Returns information about the service including protocol version. """
return protocol.toJson(protocol.GetInfoResponse( protocol_version=protocol.version))
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def runAddAnnouncement(self, flaskrequest): """ Takes a flask request from the frontend and attempts to parse into an AnnouncePeerRequest. If successful, it will...
announcement = {} # We want to parse the request ourselves to collect a little more # data about it. try: requestData = protocol.fromJson( flaskrequest.get_data(), protocol.AnnouncePeerRequest) announcement['hostname'] = flaskrequest.host_url ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def runListPeers(self, request): """ Takes a ListPeersRequest and returns a ListPeersResponse using a page_token and page_size if provided. """
return self.runSearchRequest( request, protocol.ListPeersRequest, protocol.ListPeersResponse, self.peersGenerator)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def runGetVariant(self, id_): """ Returns a variant with the given id """
compoundId = datamodel.VariantCompoundId.parse(id_) dataset = self.getDataRepository().getDataset(compoundId.dataset_id) variantSet = dataset.getVariantSet(compoundId.variant_set_id) gaVariant = variantSet.getVariant(compoundId) # TODO variant is a special case here, as it's ret...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def runGetBiosample(self, id_): """ Runs a getBiosample request for the specified ID. """
compoundId = datamodel.BiosampleCompoundId.parse(id_) dataset = self.getDataRepository().getDataset(compoundId.dataset_id) biosample = dataset.getBiosample(id_) return self.runGetRequest(biosample)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def runGetIndividual(self, id_): """ Runs a getIndividual request for the specified ID. """
compoundId = datamodel.BiosampleCompoundId.parse(id_) dataset = self.getDataRepository().getDataset(compoundId.dataset_id) individual = dataset.getIndividual(id_) return self.runGetRequest(individual)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def runGetFeature(self, id_): """ Returns JSON string of the feature object corresponding to the feature compoundID passed in. """
compoundId = datamodel.FeatureCompoundId.parse(id_) dataset = self.getDataRepository().getDataset(compoundId.dataset_id) featureSet = dataset.getFeatureSet(compoundId.feature_set_id) gaFeature = featureSet.getFeature(compoundId) jsonString = protocol.toJson(gaFeature) re...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def runGetReadGroupSet(self, id_): """ Returns a readGroupSet with the given id_ """
compoundId = datamodel.ReadGroupSetCompoundId.parse(id_) dataset = self.getDataRepository().getDataset(compoundId.dataset_id) readGroupSet = dataset.getReadGroupSet(id_) return self.runGetRequest(readGroupSet)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def runGetReadGroup(self, id_): """ Returns a read group with the given id_ """
compoundId = datamodel.ReadGroupCompoundId.parse(id_) dataset = self.getDataRepository().getDataset(compoundId.dataset_id) readGroupSet = dataset.getReadGroupSet(compoundId.read_group_set_id) readGroup = readGroupSet.getReadGroup(id_) return self.runGetRequest(readGroup)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def runGetReference(self, id_): """ Runs a getReference request for the specified ID. """
compoundId = datamodel.ReferenceCompoundId.parse(id_) referenceSet = self.getDataRepository().getReferenceSet( compoundId.reference_set_id) reference = referenceSet.getReference(id_) return self.runGetRequest(reference)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def runGetReferenceSet(self, id_): """ Runs a getReferenceSet request for the specified ID. """
referenceSet = self.getDataRepository().getReferenceSet(id_) return self.runGetRequest(referenceSet)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def runGetFeatureSet(self, id_): """ Runs a getFeatureSet request for the specified ID. """
compoundId = datamodel.FeatureSetCompoundId.parse(id_) dataset = self.getDataRepository().getDataset(compoundId.dataset_id) featureSet = dataset.getFeatureSet(id_) return self.runGetRequest(featureSet)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def runGetContinuousSet(self, id_): """ Runs a getContinuousSet request for the specified ID. """
compoundId = datamodel.ContinuousSetCompoundId.parse(id_) dataset = self.getDataRepository().getDataset(compoundId.dataset_id) continuousSet = dataset.getContinuousSet(id_) return self.runGetRequest(continuousSet)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def runGetDataset(self, id_): """ Runs a getDataset request for the specified ID. """
dataset = self.getDataRepository().getDataset(id_) return self.runGetRequest(dataset)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def runGetRnaQuantification(self, id_): """ Runs a getRnaQuantification request for the specified ID. """
compoundId = datamodel.RnaQuantificationCompoundId.parse(id_) dataset = self.getDataRepository().getDataset(compoundId.dataset_id) rnaQuantificationSet = dataset.getRnaQuantificationSet( compoundId.rna_quantification_set_id) rnaQuantification = rnaQuantificationSet.getRnaQua...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def runGetRnaQuantificationSet(self, id_): """ Runs a getRnaQuantificationSet request for the specified ID. """
compoundId = datamodel.RnaQuantificationSetCompoundId.parse(id_) dataset = self.getDataRepository().getDataset(compoundId.dataset_id) rnaQuantificationSet = dataset.getRnaQuantificationSet(id_) return self.runGetRequest(rnaQuantificationSet)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def runGetExpressionLevel(self, id_): """ Runs a getExpressionLevel request for the specified ID. """
compoundId = datamodel.ExpressionLevelCompoundId.parse(id_) dataset = self.getDataRepository().getDataset(compoundId.dataset_id) rnaQuantificationSet = dataset.getRnaQuantificationSet( compoundId.rna_quantification_set_id) rnaQuantification = rnaQuantificationSet.getRnaQuant...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def runSearchReadGroupSets(self, request): """ Runs the specified SearchReadGroupSetsRequest. """
return self.runSearchRequest( request, protocol.SearchReadGroupSetsRequest, protocol.SearchReadGroupSetsResponse, self.readGroupSetsGenerator)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def runSearchIndividuals(self, request): """ Runs the specified search SearchIndividualsRequest. """
return self.runSearchRequest( request, protocol.SearchIndividualsRequest, protocol.SearchIndividualsResponse, self.individualsGenerator)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def runSearchBiosamples(self, request): """ Runs the specified SearchBiosamplesRequest. """
return self.runSearchRequest( request, protocol.SearchBiosamplesRequest, protocol.SearchBiosamplesResponse, self.biosamplesGenerator)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def runSearchReads(self, request): """ Runs the specified SearchReadsRequest. """
return self.runSearchRequest( request, protocol.SearchReadsRequest, protocol.SearchReadsResponse, self.readsGenerator)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def runSearchReferenceSets(self, request): """ Runs the specified SearchReferenceSetsRequest. """
return self.runSearchRequest( request, protocol.SearchReferenceSetsRequest, protocol.SearchReferenceSetsResponse, self.referenceSetsGenerator)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def runSearchReferences(self, request): """ Runs the specified SearchReferenceRequest. """
return self.runSearchRequest( request, protocol.SearchReferencesRequest, protocol.SearchReferencesResponse, self.referencesGenerator)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def runSearchVariantSets(self, request): """ Runs the specified SearchVariantSetsRequest. """
return self.runSearchRequest( request, protocol.SearchVariantSetsRequest, protocol.SearchVariantSetsResponse, self.variantSetsGenerator)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def runSearchVariantAnnotationSets(self, request): """ Runs the specified SearchVariantAnnotationSetsRequest. """
return self.runSearchRequest( request, protocol.SearchVariantAnnotationSetsRequest, protocol.SearchVariantAnnotationSetsResponse, self.variantAnnotationSetsGenerator)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def runSearchVariants(self, request): """ Runs the specified SearchVariantRequest. """
return self.runSearchRequest( request, protocol.SearchVariantsRequest, protocol.SearchVariantsResponse, self.variantsGenerator)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def runSearchVariantAnnotations(self, request): """ Runs the specified SearchVariantAnnotationsRequest. """
return self.runSearchRequest( request, protocol.SearchVariantAnnotationsRequest, protocol.SearchVariantAnnotationsResponse, self.variantAnnotationsGenerator)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def runSearchCallSets(self, request): """ Runs the specified SearchCallSetsRequest. """
return self.runSearchRequest( request, protocol.SearchCallSetsRequest, protocol.SearchCallSetsResponse, self.callSetsGenerator)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def runSearchDatasets(self, request): """ Runs the specified SearchDatasetsRequest. """
return self.runSearchRequest( request, protocol.SearchDatasetsRequest, protocol.SearchDatasetsResponse, self.datasetsGenerator)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def runSearchFeatureSets(self, request): """ Returns a SearchFeatureSetsResponse for the specified SearchFeatureSetsRequest object. """
return self.runSearchRequest( request, protocol.SearchFeatureSetsRequest, protocol.SearchFeatureSetsResponse, self.featureSetsGenerator)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def runSearchFeatures(self, request): """ Returns a SearchFeaturesResponse for the specified SearchFeaturesRequest object. :param request: JSON string representi...
return self.runSearchRequest( request, protocol.SearchFeaturesRequest, protocol.SearchFeaturesResponse, self.featuresGenerator)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def runSearchContinuousSets(self, request): """ Returns a SearchContinuousSetsResponse for the specified SearchContinuousSetsRequest object. """
return self.runSearchRequest( request, protocol.SearchContinuousSetsRequest, protocol.SearchContinuousSetsResponse, self.continuousSetsGenerator)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def runSearchContinuous(self, request): """ Returns a SearchContinuousResponse for the specified SearchContinuousRequest object. :param request: JSON string repr...
return self.runSearchRequest( request, protocol.SearchContinuousRequest, protocol.SearchContinuousResponse, self.continuousGenerator)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def runSearchRnaQuantificationSets(self, request): """ Returns a SearchRnaQuantificationSetsResponse for the specified SearchRnaQuantificationSetsRequest object....
return self.runSearchRequest( request, protocol.SearchRnaQuantificationSetsRequest, protocol.SearchRnaQuantificationSetsResponse, self.rnaQuantificationSetsGenerator)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def runSearchRnaQuantifications(self, request): """ Returns a SearchRnaQuantificationResponse for the specified SearchRnaQuantificationRequest object. """
return self.runSearchRequest( request, protocol.SearchRnaQuantificationsRequest, protocol.SearchRnaQuantificationsResponse, self.rnaQuantificationsGenerator)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def runSearchExpressionLevels(self, request): """ Returns a SearchExpressionLevelResponse for the specified SearchExpressionLevelRequest object. """
return self.runSearchRequest( request, protocol.SearchExpressionLevelsRequest, protocol.SearchExpressionLevelsResponse, self.expressionLevelsGenerator)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def populateFromRow(self, dataset): """ Populates the instance variables of this Dataset from the specified database row. """
self._description = dataset.description self.setAttributesJson(dataset.attributes)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def addVariantSet(self, variantSet): """ Adds the specified variantSet to this dataset. """
id_ = variantSet.getId() self._variantSetIdMap[id_] = variantSet self._variantSetNameMap[variantSet.getLocalId()] = variantSet self._variantSetIds.append(id_)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def addBiosample(self, biosample): """ Adds the specified biosample to this dataset. """
id_ = biosample.getId() self._biosampleIdMap[id_] = biosample self._biosampleIds.append(id_) self._biosampleNameMap[biosample.getName()] = biosample
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def addIndividual(self, individual): """ Adds the specified individual to this dataset. """
id_ = individual.getId() self._individualIdMap[id_] = individual self._individualIds.append(id_) self._individualNameMap[individual.getName()] = individual
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def addFeatureSet(self, featureSet): """ Adds the specified featureSet to this dataset. """
id_ = featureSet.getId() self._featureSetIdMap[id_] = featureSet self._featureSetIds.append(id_) name = featureSet.getLocalId() self._featureSetNameMap[name] = featureSet
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def addContinuousSet(self, continuousSet): """ Adds the specified continuousSet to this dataset. """
id_ = continuousSet.getId() self._continuousSetIdMap[id_] = continuousSet self._continuousSetIds.append(id_) name = continuousSet.getLocalId() self._continuousSetNameMap[name] = continuousSet
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def addReadGroupSet(self, readGroupSet): """ Adds the specified readGroupSet to this dataset. """
id_ = readGroupSet.getId() self._readGroupSetIdMap[id_] = readGroupSet self._readGroupSetNameMap[readGroupSet.getLocalId()] = readGroupSet self._readGroupSetIds.append(id_)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def addRnaQuantificationSet(self, rnaQuantSet): """ Adds the specified rnaQuantification set to this dataset. """
id_ = rnaQuantSet.getId() self._rnaQuantificationSetIdMap[id_] = rnaQuantSet self._rnaQuantificationSetIds.append(id_) name = rnaQuantSet.getLocalId() self._rnaQuantificationSetNameMap[name] = rnaQuantSet
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def getVariantSet(self, id_): """ Returns the VariantSet with the specified name, or raises a VariantSetNotFoundException otherwise. """
if id_ not in self._variantSetIdMap: raise exceptions.VariantSetNotFoundException(id_) return self._variantSetIdMap[id_]
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def getVariantSetByName(self, name): """ Returns a VariantSet with the specified name, or raises a VariantSetNameNotFoundException if it does not exist. """
if name not in self._variantSetNameMap: raise exceptions.VariantSetNameNotFoundException(name) return self._variantSetNameMap[name]
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def addPhenotypeAssociationSet(self, phenotypeAssociationSet): """ Adds the specified g2p association set to this backend. """
id_ = phenotypeAssociationSet.getId() self._phenotypeAssociationSetIdMap[id_] = phenotypeAssociationSet self._phenotypeAssociationSetNameMap[ phenotypeAssociationSet.getLocalId()] = phenotypeAssociationSet self._phenotypeAssociationSetIds.append(id_)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def getFeatureSet(self, id_): """ Returns the FeatureSet with the specified id, or raises a FeatureSetNotFoundException otherwise. """
if id_ not in self._featureSetIdMap: raise exceptions.FeatureSetNotFoundException(id_) return self._featureSetIdMap[id_]
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def getFeatureSetByName(self, name): """ Returns the FeatureSet with the specified name, or raises an exception otherwise. """
if name not in self._featureSetNameMap: raise exceptions.FeatureSetNameNotFoundException(name) return self._featureSetNameMap[name]
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def getContinuousSet(self, id_): """ Returns the ContinuousSet with the specified id, or raises a ContinuousSetNotFoundException otherwise. """
if id_ not in self._continuousSetIdMap: raise exceptions.ContinuousSetNotFoundException(id_) return self._continuousSetIdMap[id_]
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def getContinuousSetByName(self, name): """ Returns the ContinuousSet with the specified name, or raises an exception otherwise. """
if name not in self._continuousSetNameMap: raise exceptions.ContinuousSetNameNotFoundException(name) return self._continuousSetNameMap[name]
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def getBiosampleByName(self, name): """ Returns a Biosample with the specified name, or raises a BiosampleNameNotFoundException if it does not exist. """
if name not in self._biosampleNameMap: raise exceptions.BiosampleNameNotFoundException(name) return self._biosampleNameMap[name]
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def getBiosample(self, id_): """ Returns the Biosample with the specified id, or raises a BiosampleNotFoundException otherwise. """
if id_ not in self._biosampleIdMap: raise exceptions.BiosampleNotFoundException(id_) return self._biosampleIdMap[id_]
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def getIndividualByName(self, name): """ Returns an individual with the specified name, or raises a IndividualNameNotFoundException if it does not exist. """
if name not in self._individualNameMap: raise exceptions.IndividualNameNotFoundException(name) return self._individualNameMap[name]
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def getIndividual(self, id_): """ Returns the Individual with the specified id, or raises a IndividualNotFoundException otherwise. """
if id_ not in self._individualIdMap: raise exceptions.IndividualNotFoundException(id_) return self._individualIdMap[id_]
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def getReadGroupSetByName(self, name): """ Returns a ReadGroupSet with the specified name, or raises a ReadGroupSetNameNotFoundException if it does not exist. ""...
if name not in self._readGroupSetNameMap: raise exceptions.ReadGroupSetNameNotFoundException(name) return self._readGroupSetNameMap[name]
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def getReadGroupSet(self, id_): """ Returns the ReadGroupSet with the specified name, or raises a ReadGroupSetNotFoundException otherwise. """
if id_ not in self._readGroupSetIdMap: raise exceptions.ReadGroupNotFoundException(id_) return self._readGroupSetIdMap[id_]
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def getRnaQuantificationSetByName(self, name): """ Returns the RnaQuantification set with the specified name, or raises an exception otherwise. """
if name not in self._rnaQuantificationSetNameMap: raise exceptions.RnaQuantificationSetNameNotFoundException(name) return self._rnaQuantificationSetNameMap[name]
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def getRnaQuantificationSet(self, id_): """ Returns the RnaQuantification set with the specified name, or raises a RnaQuantificationSetNotFoundException otherwis...
if id_ not in self._rnaQuantificationSetIdMap: raise exceptions.RnaQuantificationSetNotFoundException(id_) return self._rnaQuantificationSetIdMap[id_]
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def addReadGroup(self, readGroup): """ Adds the specified ReadGroup to this ReadGroupSet. """
id_ = readGroup.getId() self._readGroupIdMap[id_] = readGroup self._readGroupIds.append(id_)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def getReadGroup(self, id_): """ Returns the ReadGroup with the specified id if it exists in this ReadGroupSet, or raises a ReadGroupNotFoundException otherwise....
if id_ not in self._readGroupIdMap: raise exceptions.ReadGroupNotFoundException(id_) return self._readGroupIdMap[id_]
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def toProtocolElement(self): """ Returns the GA4GH protocol representation of this ReadGroupSet. """
readGroupSet = protocol.ReadGroupSet() readGroupSet.id = self.getId() readGroupSet.read_groups.extend( [readGroup.toProtocolElement() for readGroup in self.getReadGroups()] ) readGroupSet.name = self.getLocalId() readGroupSet.dataset_id = self.ge...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def getReadAlignmentId(self, gaAlignment): """ Returns a string ID suitable for use in the specified GA ReadAlignment object in this ReadGroupSet. """
compoundId = datamodel.ReadAlignmentCompoundId( self.getCompoundId(), gaAlignment.fragment_name) return str(compoundId)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def getStats(self): """ Returns the GA4GH protocol representation of this read group set's ReadStats. """
stats = protocol.ReadStats() stats.aligned_read_count = self._numAlignedReads stats.unaligned_read_count = self._numUnalignedReads return stats
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def populateFromRow(self, readGroupSetRecord): """ Populates the instance variables of this ReadGroupSet from the specified database row. """
self._dataUrl = readGroupSetRecord.dataurl self._indexFile = readGroupSetRecord.indexfile self._programs = [] for jsonDict in json.loads(readGroupSetRecord.programs): program = protocol.fromJson(json.dumps(jsonDict), protocol.Program) ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def populateFromFile(self, dataUrl, indexFile=None): """ Populates the instance variables of this ReadGroupSet from the specified dataUrl and indexFile. If index...
self._dataUrl = dataUrl self._indexFile = indexFile if indexFile is None: self._indexFile = dataUrl + ".bai" samFile = self.getFileHandle(self._dataUrl) self._setHeaderFields(samFile) if 'RG' not in samFile.header or len(samFile.header['RG']) == 0: ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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 readGroup = protocol.ReadGroup() readGroup.id = self.getId() readGroup.created = self._creationTime readGroup.updated = self._updateTime dataset = ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def getStats(self): """ Returns the GA4GH protocol representation of this read group's ReadStats. """
stats = protocol.ReadStats() stats.aligned_read_count = self.getNumAlignedReads() stats.unaligned_read_count = self.getNumUnalignedReads() # TODO base_count requires iterating through all reads return stats
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def getExperiment(self): """ Returns the GA4GH protocol representation of this read group's Experiment. """
experiment = protocol.Experiment() experiment.id = self.getExperimentId() experiment.instrument_model = pb.string(self.getInstrumentModel()) experiment.sequencing_center = pb.string(self.getSequencingCenter()) experiment.description = pb.string(self.getExperimentDescription()) ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def populateFromHeader(self, readGroupHeader): """ Populate the instance variables using the specified SAM header. """
self._sampleName = readGroupHeader.get('SM', None) self._description = readGroupHeader.get('DS', None) if 'PI' in readGroupHeader: self._predictedInsertSize = int(readGroupHeader['PI']) self._instrumentModel = readGroupHeader.get('PL', None) self._sequencingCenter = ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def populateFromRow(self, readGroupRecord): """ Populate the instance variables using the specified DB row. """
self._sampleName = readGroupRecord.samplename self._biosampleId = readGroupRecord.biosampleid self._description = readGroupRecord.description self._predictedInsertSize = readGroupRecord.predictedinsertsize stats = protocol.fromJson(readGroupRecord.stats, protocol.ReadStats) ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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 ...
if len(filePath) == 0: raise ValueError("Cannot have empty path for name") fileName = os.path.split(os.path.normpath(filePath))[1] # We need to handle things like .fa.gz, so we can't use # os.path.splitext ret = fileName.split(".")[0] assert ret != "" return ret
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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(formatted)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def _updateRepo(self, func, *args, **kwargs): """ Runs the specified function that updates the repo with the specified arguments. This method ensures that all up...
# TODO how do we make this properly transactional? self._repo.open(datarepo.MODE_WRITE) try: func(*args, **kwargs) self._repo.commit() finally: self._repo.close()
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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 None: name = getNameFromPath(filePath) ontology = ontologies.Ontology(name) ontology.populateFro...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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.attributes)) self._updateRepo(self._repo.insertDataset, dataset)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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) if name is None: name = getNameFromPath(self._args.filePath) referenceSet = references.HtslibReferenceSet(name) ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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 parsed = urlparse.urlparse(dataUrl) # TODO, add https support and others when they have been # tested. if parsed....
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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) dataset = self._repo.getDatasetByName(self._args.datasetName) phenotypeAssociationSet = \ genotype_phenotype.RdfPhenotypeAssociationSet( da...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def removePhenotypeAssociationSet(self): """ Removes a phenotype association set from the repo """
self._openRepo() dataset = self._repo.getDatasetByName(self._args.datasetName) phenotypeAssociationSet = dataset.getPhenotypeAssociationSetByName( self._args.name) def func(): self._updateRepo( self._repo.removePhenotypeAssociationSet, ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def removeReferenceSet(self): """ Removes a referenceSet from the repo. """
self._openRepo() referenceSet = self._repo.getReferenceSetByName( self._args.referenceSetName) def func(): self._updateRepo(self._repo.removeReferenceSet, referenceSet) self._confirmDelete("ReferenceSet", referenceSet.getLocalId(), func)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def removeReadGroupSet(self): """ Removes a readGroupSet from the repo. """
self._openRepo() dataset = self._repo.getDatasetByName(self._args.datasetName) readGroupSet = dataset.getReadGroupSetByName( self._args.readGroupSetName) def func(): self._updateRepo(self._repo.removeReadGroupSet, readGroupSet) self._confirmDelete("ReadG...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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 func(): self._updateRepo(self._repo.removeVariantSet, variantSet) self._confirmDelete("VariantSet", variantSet.getL...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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._confirmDelete("Dataset", dataset.getLocalId(), func)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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, self._args.relativePath) name = getNameFromPath(self._args.filePath) featureSet = sequence_annotations.Gff3DbFeat...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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 func(): self._updateRepo(self._repo.removeFeatureSet, featureSet) self._confirmDelete("FeatureSet", featureSet.getL...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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, self._args.relativePath) name = getNameFromPath(self._args.filePath) continuousSet = continuous.FileContinuousSet...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def removeContinuousSet(self): """ Removes a continuous set from this repo """
self._openRepo() dataset = self._repo.getDatasetByName(self._args.datasetName) continuousSet = dataset.getContinuousSetByName( self._args.continuousSetName) def func(): self._updateRepo(self._repo.removeContinuousSet, continuousSet) self....
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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) biosample.populateFromJson(self._args.biosample) self._updateRepo(self._repo.insertBiosample, biosample)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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(): self._updateRepo(self._repo.removeBiosample, biosample) self._confirmDelete("Biosample", biosample.getLocalId(...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: 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) individual.populateFromJson(self._args.individual) self._updateRepo(self._repo.insertIndividual, individual)