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) print("NEXT PAGE TOKEN: ") print(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 testSearchFeatures(self): featureSets = self.getAllFeatureSets() for featureSet in featureSets: path = "features/search" request = protocol.SearchFeaturesRequest() request.feature_set_id = featureSet.id request.start = 0 request.end = 2**16 request.feature_types.extend(["exon"]) request.reference_name = "chr1" responseData = self.sendSearchRequest( path, request, protocol.SearchFeaturesResponse) for feature in responseData.features: self.assertIn( feature.feature_type.term, request.feature_types, "Term should be present {} {} \n{}\n{}".format( feature.feature_type.term, request.feature_types, feature, request)) path = "features/search" request = protocol.SearchFeaturesRequest() request.feature_set_id = featureSet.id request.start = 0 request.end = 2**16 request.feature_types.extend(["gene", "exon"]) request.reference_name = "chr1" responseData = self.sendSearchRequest( path, request, protocol.SearchFeaturesResponse) for feature in responseData.features: self.assertIn(feature.feature_type.term, request.feature_types) request = protocol.SearchFeaturesRequest() request.feature_set_id = featureSet.id request.start = 0 request.end = 2**16 request.feature_types.extend(["exon"]) request.reference_name = "chr1" responseData = self.sendSearchRequest( path, request, protocol.SearchFeaturesResponse) for feature in responseData.features: self.assertIn(feature.feature_type.term, request.feature_types)
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 testSearchFeaturesByGeneSymbol(self): ran = False featureSets = self.getAllFeatureSets() for featureSet in featureSets: path = "features/search" request = protocol.SearchFeaturesRequest() request.feature_set_id = featureSet.id request.gene_symbol = "BAD GENE SYMBOL" responseData = self.sendSearchRequest( path, request, protocol.SearchFeaturesResponse) self.assertEqual(0, len(responseData.features)) request.gene_symbol = "DDX11L16" responseData = self.sendSearchRequest( path, request, protocol.SearchFeaturesResponse) for feature in responseData.features: ran = True self.assertEqual(feature.gene_symbol, request.gene_symbol) self.assertTrue(ran)
def testSearchFeaturesByName(self): ran = False featureSets = self.getAllFeatureSets() for featureSet in featureSets: path = "features/search" request = protocol.SearchFeaturesRequest() request.feature_set_id = featureSet.id request.name = "BAD NAME" responseData = self.sendSearchRequest( path, request, protocol.SearchFeaturesResponse) self.assertEqual(0, len(responseData.features)) request.name = "exon:ENSTR0000507418.3:5" responseData = self.sendSearchRequest( path, request, protocol.SearchFeaturesResponse) for feature in responseData.features: ran = True self.assertEqual(feature.name, request.name) self.assertTrue(ran)
def testSearchFeatures(self): request = protocol.SearchFeaturesRequest() request.feature_set_id = self.featureSetId request.parent_id = self.parentId request.page_size = self.pageSize request.reference_name = self.referenceName request.start = self.start request.end = self.end request.name = self.objectName request.gene_symbol = self.geneSymbol request.feature_types.append(self.feature) self.httpClient.search_features(self.featureSetId, parent_id=self.parentId, reference_name=self.referenceName, start=self.start, end=self.end, feature_types=[self.feature], name=self.objectName, gene_symbol=self.geneSymbol) self.httpClient._run_search_request.assert_called_once_with( request, "features", protocol.SearchFeaturesResponse)
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