def testGenotypeSearchFeaturePagingAll(self): """ Loop through all pages """ request = self._createPagingRequest() request.page_size = 1 feature_set_id = request.feature_set_id postUrl = "features/search" response = self.sendSearchRequest( postUrl, request, protocol.SearchFeaturesResponse) self.assertEqual(1, len(response.features)) self.assertIsNotNone(response.next_page_token) pageCount = 1 while response.next_page_token: previous_id = response.features[0].id request = protocol.SearchFeaturesRequest() request.feature_set_id = feature_set_id request.page_size = 1 request.page_token = response.next_page_token request.name = "KIT *wild" response = self.sendSearchRequest( postUrl, request, protocol.SearchFeaturesResponse) self.assertEqual(1, len(response.features)) self.assertNotEqual(previous_id, response.features[0].id) pageCount += 1 self.assertEqual(3, pageCount)
def testGenotypesSearchByNameKIT(self): request = protocol.SearchFeaturesRequest() datasetName, featureSet = self.getCGDDataSetFeatureSet() request.feature_set_id = featureSet.id request.name = \ "KIT *wild" postUrl = "features/search" response = self.sendSearchRequest(postUrl, request, protocol.SearchFeaturesResponse) self.assertEqual(3, len(response.features))
def testGenotypesSearchByNameError(self): """ Search for feature by name with a malformed regular expression. """ # setup phenotype query request = protocol.SearchFeaturesRequest() datasetName, featureSet = self.getCGDDataSetFeatureSet() request.feature_set_id = featureSet.id request.name = "*" # invalid regular expression postUrl = "features/search" response = self.sendJsonPostRequest(postUrl, protocol.toJson(request)) self.assertEqual(400, response.status_code)
def testGenotypesSearchByName(self): # setup phenotype query request = protocol.SearchFeaturesRequest() datasetName, featureSet = self.getCGDDataSetFeatureSet() request.feature_set_id = featureSet.id request.name = "RET M918T missense mutation" postUrl = "features/search" response = self.sendSearchRequest(postUrl, request, protocol.SearchFeaturesResponse) self.assertEqual(1, len(response.features)) self.assertEqual( "http://cancer.sanger.ac.uk/cosmic/mutation/overview?id=965", datamodel.FeatureCompoundId.parse( response.features[0].id).featureId) self.assertEqual(request.name, response.features[0].name)
def _createPagingRequest(self): request = protocol.SearchFeaturesRequest() datasetName, featureSet = self.getCGDDataSetFeatureSet() request.feature_set_id = featureSet.id request.name = "KIT *wild" return request