Question: Processing a gzip file Now complete the function pull_basic_and_predictor_fields_gzip to repeat the above function but use the gzipped file named: test_4families_annovar.vcf.gz. The file is too

Processing a gzip file Now complete the function pull_basic_and_predictor_fields_gzip to repeat the above function but use the gzipped file named: test_4families_annovar.vcf.gz. The file is too large to unzip and use, so we will use it as is. To read the file one file at a time, use the following code: import gzip with gzip.open(filename,'rt') as fp: for line in fp: pass The output of this function is given in expected_mini_project1_gzip.json. Note that you will have to parse the whole file again, but only pull out the fields used in the pull_basic_and_predictor_fields Save the output as mini_project1_gzip.json -- use indent=2, sort_keys=True

def pull_basic_and_predictor_fields_gzip(filename):

# BEGIN SOLUTION

#YourCodeHere

# END SOLUTION

IT should pass this test:

def test_pull_basic_and_predictor_fields_gzip(self):

import json

filename = 'test_4families_annovar.vcf.gz'

if os.path.exists('mini_project1_gzip.json'):

os.remove('mini_project1_gzip.json')

self.mini_project1.pull_basic_and_predictor_fields_gzip(filename)

expected_result = json.load(open('expected_mini_project1_gzip.json'))

value = json.load(open('mini_project1_gzip.json'))

self.assertEqual(expected_result, value)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Computer Network Questions!