def searchVariantAnnotations(self, variantAnnotationSetId, referenceName=None, referenceId=None, start=None, end=None, effects=[]): """ Returns an iterator over the Annotations fulfilling the specified conditions from the specified AnnotationSet. """ request = protocol.SearchVariantAnnotationsRequest() request.variantAnnotationSetId = variantAnnotationSetId request.referenceName = referenceName request.referenceId = referenceId request.start = start request.end = end request.effects = effects for effect in request.effects: if 'id' not in effect: raise exceptions.BadRequestException( "Each ontology term should have an id set") request.pageSize = self._pageSize return self._runSearchRequest( request, "variantannotations", protocol.SearchVariantAnnotationsResponse)
def readsGenerator(self, request): """ Returns a generator over the (read, nextPageToken) pairs defined by the specified request """ if not request.reference_id: raise exceptions.UnmappedReadsNotSupported() if len(request.read_group_ids) < 1: raise exceptions.BadRequestException( "At least one readGroupId must be specified") elif len(request.read_group_ids) == 1: return self._readsGeneratorSingle(request) else: return self._readsGeneratorMultiple(request)
def search_variant_annotations(self, variant_annotation_set_id, reference_name="", reference_id="", start=0, end=0, effects=[]): """ Returns an iterator over the Variant Annotations fulfilling the specified conditions from the specified VariantSet. :param str variant_annotation_set_id: The ID of the :class:`ga4gh.protocol.VariantAnnotationSet` of interest. :param int start: Required. The beginning of the window (0-based, inclusive) for which overlapping variants should be returned. Genomic positions are non-negative integers less than reference length. Requests spanning the join of circular genomes are represented as two requests one on each side of the join (position 0). :param int end: Required. The end of the window (0-based, exclusive) for which overlapping variants should be returned. :param str reference_name: The name of the :class:`ga4gh.protocol.Reference` we wish to return variants from. :return: An iterator over the :class:`ga4gh.protocol.VariantAnnotation` objects defined by the query parameters. :rtype: iter """ request = protocol.SearchVariantAnnotationsRequest() request.variant_annotation_set_id = variant_annotation_set_id request.reference_name = reference_name request.reference_id = reference_id request.start = start request.end = end for effect in effects: request.effects.add().CopyFrom(protocol.OntologyTerm(**effect)) for effect in request.effects: if not effect.id: raise exceptions.BadRequestException( "Each ontology term should have an id set") request.page_size = pb.int(self._page_size) return self._run_search_request( request, "variantannotations", protocol.SearchVariantAnnotationsResponse)
def rnaQuantificationsGenerator(self, request): """ Returns a generator over the (rnaQuantification, nextPageToken) pairs defined by the specified request. """ if len(request.rna_quantification_set_id) < 1: raise exceptions.BadRequestException( "Rna Quantification Set Id must be specified") else: compoundId = datamodel.RnaQuantificationSetCompoundId.parse( request.rna_quantification_set_id) dataset = self.getDataRepository().getDataset( compoundId.dataset_id) rnaQuantSet = dataset.getRnaQuantificationSet( compoundId.rna_quantification_set_id) return self._topLevelObjectGenerator( request, rnaQuantSet.getNumRnaQuantifications(), rnaQuantSet.getRnaQuantificationByIndex)
def _readsGeneratorMultiple(self, request): compoundId = datamodel.ReadGroupCompoundId.parse( request.read_group_ids[0]) dataset = self.getDataRepository().getDataset(compoundId.dataset_id) readGroupSet = dataset.getReadGroupSet(compoundId.read_group_set_id) referenceSet = readGroupSet.getReferenceSet() if referenceSet is None: raise exceptions.ReadGroupSetNotMappedToReferenceSetException( readGroupSet.getId()) reference = referenceSet.getReference(request.reference_id) readGroupIds = readGroupSet.getReadGroupIds() if set(readGroupIds) != set(request.read_group_ids): raise exceptions.BadRequestException( "If multiple readGroupIds are specified, " "they must be all of the readGroupIds in a ReadGroupSet") intervalIterator = ReadsIntervalIterator(request, readGroupSet, reference) return intervalIterator