<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def save_dtrajs(self, prefix='', output_dir='.', output_format='ascii', extension='.dtraj'):
 r"""Saves calculated discrete trajectories. Filenames are taken from given reader. If data comes from memory dtrajs are written to a default filename. Parameters prefix : str prepend prefix to filenames. output_dir : str (optional) save files to this directory. Defaults to current working directory. output_format : str if format is 'ascii' dtrajs will be written as csv files, otherwise they will be written as NumPy .npy files. extension : str file extension to append (eg. '.itraj') """


        clustering = self._chain[-1]
        reader = self._chain[0]
        from pyemma.coordinates.clustering.interface import AbstractClustering
        assert isinstance(clustering, AbstractClustering)

        trajfiles = None
        if isinstance(reader, FeatureReader):
            trajfiles = reader.filenames

        clustering.save_dtrajs(
            trajfiles, prefix, output_dir, output_format, extension)