Parse the lengths of all contigs for each sample, as well as the total GC%

def fasta_stats(self):
        """
        Parse the lengths of all contigs for each sample, as well as the total GC%
        """
        for sample in self.metadata:
            # Initialise variables to store appropriate values parsed from contig records
            contig_lengths = list()
            fasta_sequence = str()
            for contig, record in sample[self.analysistype].record_dict.items():
                # Append the length of the contig to the list
                contig_lengths.append(len(record.seq))
                # Add the contig sequence to the string
                fasta_sequence += record.seq
            # Set the reverse sorted (e.g. largest to smallest) list of contig sizes as the value
            sample[self.analysistype].contig_lengths = sorted(contig_lengths, reverse=True)
            try:
                # Calculate the GC% of the total genome sequence using GC - format to have two decimal places
                sample[self.analysistype].gc = float('{:0.2f}'.format(GC(fasta_sequence)))
            except TypeError:
                sample[self.analysistype].gc = 'NA'