<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def update_phylo_model(self, stats_type, stats_file, frequency_type=None):
 """Parse a stats log and use it to update ``phylo_model``. ``pplacer`` expects its input to include the deatils of the phylogenetic model used for creating a tree in JSON format under the key ``phylo_model``, but no program actually outputs that format. This function takes a log generated by RAxML or FastTree, parses it, and inserts an appropriate JSON file into the refpkg. The first parameter must be 'RAxML', 'PhyML' or 'FastTree', depending on which program generated the log. It may also be None to attempt to guess which program generated the log. :param stats_type: Statistics file type. One of 'RAxML', 'FastTree', 'PhyML' :param stats_file: path to statistics/log file :param frequency_type: For ``stats_type == 'PhyML'``, amino acid alignments only: was the alignment inferred with ``model`` or ``empirical`` frequencies? """


        if frequency_type not in (None, 'model', 'empirical'):
            raise ValueError(
                'Unknown frequency type: "{0}"'.format(frequency_type))
        if frequency_type and stats_type not in (None, 'PhyML'):
            raise ValueError('Frequency type should only be specified for '
                             'PhyML alignments.')

        if stats_type is None:
            with open(stats_file) as fobj:
                for line in fobj:
                    if line.startswith('FastTree'):
                        stats_type = 'FastTree'
                        break
                    elif (line.startswith('This is RAxML') or
                          line.startswith('You are using RAxML')):
                        stats_type = 'RAxML'
                        break
                    elif 'PhyML' in line:
                        stats_type = 'PhyML'
                        break
                else:
                    raise ValueError(
                        "couldn't guess log type for %r" % (stats_file,))

        if stats_type == 'RAxML':
            parser = utils.parse_raxml
        elif stats_type == 'FastTree':
            parser = utils.parse_fasttree
        elif stats_type == 'PhyML':
            parser = functools.partial(utils.parse_phyml,
                                       frequency_type=frequency_type)
        else:
            raise ValueError('invalid log type: %r' % (stats_type,))

        with scratch_file(prefix='phylo_model', suffix='.json') as name:
            with open(name, 'w') as phylo_model, open(stats_file) as h:
                json.dump(parser(h), phylo_model, indent=4)
            self.update_file('phylo_model', name)