def _heavyQuery(): """ Very heavy query: all calls on chromosome 2 (11 pages, 90 seconds to fetch the entire thing on a high-end desktop machine) """ request = protocol.GASearchVariantsRequest() request.referenceName = '2' request.variantSetIds = ['1000g_2013'] request.callSetIds = None request.pageSize = 100 request.end = 100000 return request
def _heavyQuery(variantSetId, callSetIds): """ Very heavy query: calls for the specified list of callSetIds on chromosome 2 (11 pages, 90 seconds to fetch the entire thing on a high-end desktop machine) """ request = protocol.GASearchVariantsRequest() request.referenceName = '2' request.variantSetIds = [variantSetId] request.callSetIds = callSetIds request.pageSize = 100 request.end = 100000 return request
def getVariants( self, variantSetIds, referenceName, start=0, end=2 ** 32, pageSize=100, callSetIds=[]): """ Returns an iterator over the specified list of variants, abstracting out paging details. """ request = protocol.GASearchVariantsRequest() request.variantSetIds = variantSetIds request.referenceName = referenceName request.start = start request.end = end request.callSetIds = callSetIds return self.resultIterator( request, pageSize, self._backend.searchVariants, protocol.GASearchVariantsResponse, "variants")
def query(): variant_set_id = request.form['populationId'] variants_request = protocol.GASearchVariantsRequest() variants_request.variantSetIds = [request.form['populationId']] variants_request.referenceName = request.form['chrom'] variants_request.start = int(request.form['position']) - 1 # GA4GH API is zero-based variants_request.end = int(request.form['position']) response = variants_client.searchVariants(variants_request) for variant in response: for alt in variant.alternateBases: if alt == request.form['allele']: return "True" return "False"
def __init__(self, args): super(VariantSearchRunner, self).__init__(args) request = protocol.GASearchVariantsRequest() request.referenceName = args.referenceName request.variantName = args.variantName request.start = args.start request.end = args.end if self.usingWorkaroundsFor(client.HTTPClient.workaroundGoogle): request.maxCalls = args.maxCalls if args.callSetIds == []: request.callSetIds = [] elif args.callSetIds == '*': request.callSetIds = None else: request.callSetIds = args.callSetIds.split(",") setCommaSeparatedAttribute(request, args, 'variantSetIds') self.setHttpClient(request, args)
def __init__(self, args): svr = protocol.GASearchVariantsRequest() svr.referenceName = args.referenceName svr.variantName = args.variantName svr.start = args.start svr.end = args.end svr.pageSize = args.pageSize if args.callSetIds == []: svr.callSetIds = [] elif args.callSetIds == '*': svr.callSetIds = None else: svr.callSetIds = args.callSetIds.split(",") svr.variantSetIds = args.variantSetIds.split(",") self._request = svr self._verbosity = args.verbose self._httpClient = client.HTTPClient(args.baseUrl, args.verbose)
def testVariantsSearch(self): # TODO: As above, get these from the test backend API expectedIds = ['example_1'] referenceName = '1' request = protocol.GASearchVariantsRequest() request.referenceName = referenceName request.start = 0 request.end = 0 request.variantSetIds = expectedIds # Request windows is too small, no results response = self.sendJSONPostRequest('/variants/search', request.toJSONString()) self.assertEqual(200, response.status_code) responseData = protocol.GASearchVariantsResponse.fromJSONString( response.data) self.assertIsNone(responseData.nextPageToken) self.assertEqual([], responseData.variants) # Larger request window, expect results request.end = 2**16 response = self.sendJSONPostRequest('/variants/search', request.toJSONString()) self.assertEqual(200, response.status_code) responseData = protocol.GASearchVariantsResponse.fromJSONString( response.data) self.assertTrue( protocol.GASearchVariantsResponse.validate( responseData.toJSONDict())) self.assertNotEqual([], responseData.variants) # Verify all results are in the correct range, set and reference for variant in responseData.variants: self.assertGreaterEqual(variant.start, 0) self.assertLessEqual(variant.end, 2**16) self.assertTrue(variant.variantSetId in expectedIds) self.assertEqual(variant.referenceName, referenceName)