<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def parse_afterqc_log(self, f):
 """ Parse the JSON output from AfterQC and save the summary statistics """

        try:
            parsed_json = json.load(f['f'])
        except:
            log.warn("Could not parse AfterQC JSON: '{}'".format(f['fn']))
            return None

        # AfterQC changed the name of their summary key at some point
        if 'summary' in parsed_json:
            summaryk = 'summary'
        elif 'afterqc_main_summary' in parsed_json:
            summaryk = 'afterqc_main_summary'
        else:
            log.warn("AfterQC JSON did not have a 'summary' or 'afterqc_main_summary' key, skipping: '{}'".format(f['fn']))
            return None

        s_name = f['s_name']
        self.add_data_source(f, s_name)
        self.afterqc_data[s_name] = {}
        for k in parsed_json[summaryk]:
            try:
                self.afterqc_data[s_name][k] = float(parsed_json[summaryk][k])
            except ValueError:
                self.afterqc_data[s_name][k] = parsed_json[summaryk][k]
        try:
            self.afterqc_data[s_name]['pct_good_bases'] = (self.afterqc_data[s_name]['good_bases'] / self.afterqc_data[s_name]['total_bases']) * 100.0
        except KeyError:
            pass