Exemplo n.º 1
0
 def testCallSetsSearch(self):
     path = '/callsets/search'
     for dataset in self.backend.getDatasets():
         for variantSet in dataset.getVariantSets():
             callSets = variantSet.getCallSets()
             self.assertGreater(len(callSets), 0)
             request = protocol.SearchCallSetsRequest()
             request.variantSetId = variantSet.getId()
             self.verifySearchMethod(request, path,
                                     protocol.SearchCallSetsResponse,
                                     callSets, self.verifyCallSetsEqual)
             # Check if we can search for the callset with a good name.
             for callSet in callSets:
                 request = protocol.SearchCallSetsRequest()
                 request.variantSetId = variantSet.getId()
                 request.name = callSet.getLocalId()
                 self.verifySearchMethod(request, path,
                                         protocol.SearchCallSetsResponse,
                                         [callSet],
                                         self.verifyCallSetsEqual)
             # Check if we can search for the callset with a bad name.
             for badId in self.getBadIds():
                 request = protocol.SearchCallSetsRequest()
                 request.variantSetId = variantSet.getId()
                 request.name = badId
                 self.verifySearchResultsEmpty(
                     request, path, protocol.SearchCallSetsResponse)
     # Check for searches within missing variantSets.
     for badId in self.getBadIds():
         request = protocol.SearchCallSetsRequest()
         request.variantSetId = badId
         self.verifySearchMethodFails(request, path)
Exemplo n.º 2
0
 def sendCallSetsSearch(self):
     response = self.sendVariantSetsSearch()
     variantSets = protocol.SearchVariantSetsResponse().fromJsonString(
         response.data).variantSets
     request = protocol.SearchCallSetsRequest()
     request.variantSetId = variantSets[0].id
     return self.sendPostRequest('/callsets/search', request)
Exemplo n.º 3
0
 def testSearchCallSets(self):
     request = protocol.SearchCallSetsRequest()
     request.variantSetId = self.variantSetId
     request.name = self.objectName
     request.pageSize = self.pageSize
     self.httpClient.searchCallSets(self.variantSetId, name=self.objectName)
     self.httpClient._runSearchRequest.assert_called_once_with(
         request, "callsets", protocol.SearchCallSetsResponse)
Exemplo n.º 4
0
 def testSearchCallSets(self):
     variantSetIds = [
         variantSet.id for variantSet in self.getVariantSets(pageSize=1)
     ]
     request = protocol.SearchCallSetsRequest()
     request.variantSetId = variantSetIds[0]
     responseStr = self._backend.runSearchCallSets(request.toJsonString())
     response = protocol.SearchCallSetsResponse.fromJsonString(responseStr)
     self.assertTrue(isinstance(response, protocol.SearchCallSetsResponse))
Exemplo n.º 5
0
 def getCallSets(self, variantSetId, pageSize=100):
     """
     Returns an iterator over the callsets in a specified
     variant set.
     """
     request = protocol.SearchCallSetsRequest()
     request.variantSetIds = [variantSetId]
     return self.resultIterator(request, pageSize,
                                self._backend.runSearchCallSets,
                                protocol.SearchCallSetsResponse, "callSets")
Exemplo n.º 6
0
 def testSearchCallSets(self):
     request = protocol.SearchCallSetsRequest()
     request.variant_set_id = self.variantSetId
     request.name = self.objectName
     request.bio_sample_id = self.bioSampleId
     request.page_size = self.pageSize
     self.httpClient.search_call_sets(self.variantSetId,
                                      name=self.objectName,
                                      bio_sample_id=self.bioSampleId)
     self.httpClient._run_search_request.assert_called_once_with(
         request, "callsets", protocol.SearchCallSetsResponse)
Exemplo n.º 7
0
    def searchCallSets(self, variantSetId, name=None):
        """
        Returns an iterator over the CallSets fulfilling the specified
        conditions from the specified VariantSet.

        :param str name: Only CallSets matching the specified name will
            be returned.
        :return: An iterator over the :class:`ga4gh.protocol.CallSet`
            objects defined by the query parameters.
        """
        request = protocol.SearchCallSetsRequest()
        request.variantSetId = variantSetId
        request.name = name
        request.pageSize = self._pageSize
        return self._runSearchRequest(
            request, "callsets", protocol.SearchCallSetsResponse)
Exemplo n.º 8
0
    def searchCallSets(self, variantSetId, name=None, bioSampleId=None):
        """
        Returns an iterator over the CallSets fulfilling the specified
        conditions from the specified VariantSet.

        :param str variantSetId: Find callsets belonging to the
            provided variant set.
        :param str name: Only CallSets matching the specified name will
            be returned.
        :param str bioSampleId: Only CallSets matching this id will
            be returned.
        :return: An iterator over the :class:`ga4gh.protocol.CallSet`
            objects defined by the query parameters.
        """
        request = protocol.SearchCallSetsRequest()
        request.variant_set_id = variantSetId
        request.name = pb.string(name)
        request.bio_sample_id = pb.string(bioSampleId)
        request.page_size = pb.int(self._pageSize)
        return self._runSearchRequest(
            request, "callsets", protocol.SearchCallSetsResponse)
Exemplo n.º 9
0
    def testCallSetsSearch(self):
        # TODO remove the @skipIf decorator here once calls have been
        # properly implemented in the simulator.
        request = protocol.SearchCallSetsRequest()
        request.name = None
        path = utils.applyVersion('/callsets/search')

        # when variantSetIds are wrong, no results
        request.variantSetIds = ["xxxx"]
        response = self.sendJsonPostRequest(path, request.toJsonString())
        self.assertEqual(200, response.status_code)
        responseData = protocol.SearchCallSetsResponse.fromJsonString(
            response.data)
        self.assertIsNone(responseData.nextPageToken)
        self.assertEqual([], responseData.callSets)

        # if no callset name is given return all callsets
        request.variantSetIds = self.variantSetIds[:1]
        response = self.sendJsonPostRequest(path, request.toJsonString())
        self.assertEqual(200, response.status_code)
        responseData = protocol.SearchCallSetsResponse.fromJsonString(
            response.data)
        self.assertTrue(
            protocol.SearchCallSetsResponse.validate(
                responseData.toJsonDict()))
        self.assertNotEqual([], responseData.callSets)
        # TODO test the length of responseData.callSets equal to all callsets

        # Verify all results are of the correct type and range
        for callSet in responseData.callSets:
            self.assertIs(type(callSet.info), dict)
            self.assertIs(type(callSet.variantSetIds), list)
            splits = callSet.id.split(".")
            variantSetId = '.'.join(splits[:2])
            callSetName = splits[-1]
            self.assertIn(variantSetId, callSet.variantSetIds)
            self.assertEqual(callSetName, callSet.name)
            self.assertEqual(callSetName, callSet.sampleId)
Exemplo n.º 10
0
Arquivo: cli.py Projeto: afirth/server
 def createSearchCallSetsRequest(self):
     request = protocol.SearchCallSetsRequest()
     setCommaSeparatedAttribute(request, self.args, 'variantSetIds')
     request.name = self.args.name
     return request
Exemplo n.º 11
0
 def createSearchCallSetsRequest(self):
     request = protocol.SearchCallSetsRequest()
     request.variantSetId = self.args.variantSetId
     request.name = self.args.name
     return request