def testReadGroupSetsSearch(self): path = '/readgroupsets/search' for dataset in self.backend.getDatasets(): readGroupSets = dataset.getReadGroupSets() request = protocol.SearchReadGroupSetsRequest() request.datasetId = dataset.getId() self.verifySearchMethod(request, path, protocol.SearchReadGroupSetsResponse, readGroupSets, self.verifyReadGroupSetsEqual) # Check if we can search for the readGroupSet with a good name. for readGroupSet in readGroupSets: request = protocol.SearchReadGroupSetsRequest() request.datasetId = dataset.getId() request.name = readGroupSet.getLocalId() self.verifySearchMethod(request, path, protocol.SearchReadGroupSetsResponse, [readGroupSet], self.verifyReadGroupSetsEqual) # Check if we can search for the readGroupSet with a bad name. for badId in self.getBadIds(): request = protocol.SearchReadGroupSetsRequest() request.datasetId = dataset.getId() request.name = badId self.verifySearchResultsEmpty( request, path, protocol.SearchReadGroupSetsResponse) for badId in self.getBadIds(): request = protocol.SearchReadGroupSetsRequest() request.datasetId = badId self.verifySearchMethodFails(request, path)
def testReads(self): # search read group sets path = utils.applyVersion('/readgroupsets/search') request = protocol.SearchReadGroupSetsRequest() request.datasetId = 'simulatedDataset1' response = self.sendJsonPostRequest(path, request.toJsonString()) self.assertEqual(response.status_code, 200) responseData = protocol.SearchReadGroupSetsResponse.fromJsonString( response.data) readGroupSets = responseData.readGroupSets self.assertEqual(len(readGroupSets), 1) # search reads path = utils.applyVersion('/reads/search') request = protocol.SearchReadsRequest() readGroupId = readGroupSets[0].readGroups[0].id request.readGroupIds = [readGroupId] request.referenceId = "chr1" response = self.sendJsonPostRequest(path, request.toJsonString()) self.assertEqual(response.status_code, 200) responseData = protocol.SearchReadsResponse.fromJsonString( response.data) alignments = responseData.alignments self.assertEqual(len(alignments), self.numAlignmentsPerReadGroup) for alignment in alignments: self.assertEqual(alignment.readGroupId, readGroupId)
def testSearchReadGroupSets(self): request = protocol.SearchReadGroupSetsRequest() request.datasetId = self.datasetId request.name = self.objectName request.pageSize = self.pageSize self.httpClient.searchReadGroupSets( self.datasetId, name=self.objectName) self.httpClient._runSearchRequest.assert_called_once_with( request, "readgroupsets", protocol.SearchReadGroupSetsResponse)
def testSearchReadGroupSets(self): request = protocol.SearchReadGroupSetsRequest() request.dataset_id = self.datasetId request.name = self.objectName request.bio_sample_id = self.bioSampleId request.page_size = self.pageSize self.httpClient.search_read_group_sets(self.datasetId, name=self.objectName, bio_sample_id=self.bioSampleId) self.httpClient._run_search_request.assert_called_once_with( request, "readgroupsets", protocol.SearchReadGroupSetsResponse)
def searchReadGroupSets(self, datasetId, name=None): """ Returns an iterator over the ReadGroupSets fulfilling the specified conditions from the specified Dataset. :param str name: Only ReadGroupSets matching the specified name will be returned. :return: An iterator over the :class:`ga4gh.protocol.ReadGroupSet` objects defined by the query parameters. :rtype: iter """ request = protocol.SearchReadGroupSetsRequest() request.datasetId = datasetId request.name = name request.pageSize = self._pageSize return self._runSearchRequest( request, "readgroupsets", protocol.SearchReadGroupSetsResponse)
def searchReadGroupSets(self, datasetId, name=None, bioSampleId=None): """ Returns an iterator over the ReadGroupSets fulfilling the specified conditions from the specified Dataset. :param str name: Only ReadGroupSets matching the specified name will be returned. :param str bioSampleId: Only ReadGroups matching the specified bioSample will be included in the response. :return: An iterator over the :class:`ga4gh.protocol.ReadGroupSet` objects defined by the query parameters. :rtype: iter """ request = protocol.SearchReadGroupSetsRequest() request.dataset_id = datasetId request.name = pb.string(name) request.bio_sample_id = pb.string(bioSampleId) request.page_size = pb.int(self._pageSize) return self._runSearchRequest( request, "readgroupsets", protocol.SearchReadGroupSetsResponse)
def createSearchReadGroupSetsRequest(self): request = protocol.SearchReadGroupSetsRequest() setCommaSeparatedAttribute(request, self.args, 'datasetIds') request.name = self.args.name return request
def createSearchReadGroupSetsRequest(self): request = protocol.SearchReadGroupSetsRequest() request.datasetId = self.args.datasetId request.name = self.args.name return request