<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def fastas(self, download=False):
 """ Dict of filepaths for all fasta files associated with code. Parameters download : bool If True, downloads the fasta file from the PDB. If False, uses the ampal Protein.fasta property Defaults to False - this is definitely the recommended behaviour. Notes ----- Calls self.mmols, and so downloads mmol files if not already present. See .fasta property of isambard.ampal.base_ampal.Protein for more information. Returns ------- fastas_dict : dict, or None. Keys : int mmol number Values : str Filepath for the corresponding fasta file. """

        fastas_dict = {}
        fasta_dir = os.path.join(self.parent_dir, 'fasta')
        if not os.path.exists(fasta_dir):
            os.makedirs(fasta_dir)
        for i, mmol_file in self.mmols.items():
            mmol_name = os.path.basename(mmol_file)
            fasta_file_name = '{0}.fasta'.format(mmol_name)
            fasta_file = os.path.join(fasta_dir, fasta_file_name)
            if not os.path.exists(fasta_file):
                if download:
                    pdb_url = "http://www.rcsb.org/pdb/files/fasta.txt?structureIdList={0}".format(self.code.upper())
                    r = requests.get(pdb_url)
                    if r.status_code == 200:
                        fasta_string = r.text
                    else:
                        fasta_string = None
                else:
                    a = convert_pdb_to_ampal(mmol_file)
                    # take first object if AmpalContainer (i.e. NMR structure).
                    if type(a) == AmpalContainer:
                        a = a[0]
                    fasta_string = a.fasta
                with open(fasta_file, 'w') as foo:
                    foo.write(fasta_string)
            fastas_dict[i] = fasta_file
        return fastas_dict