def readlength(self):
        """Calculates the read length of the fastq files. Short reads will not be able to be assembled properly with the
        default parameters used for spades."""
        logging.info('Estimating read lengths of FASTQ files')
        # Iterate through the samples
        for sample in self.samples:
            sample.run.Date = 'NA'
            sample.run.InvestigatorName = 'NA'
            sample.run.TotalClustersinRun = 'NA'
            sample.run.NumberofClustersPF = 'NA'
            sample.run.PercentOfClusters = 'NA'
            sample.run.SampleProject = 'NA'
            # Only perform this step if the forward and reverse lengths have not been loaded into the metadata
            if not GenObject.isattr(sample.run, 'forwardlength') and not GenObject.isattr(sample.run, 'reverselength'):
                # Initialise the .header attribute for each sample
                sample.header = GenObject()
                sample.commands = GenObject()
                # Set /dev/null
                devnull = open(os.devnull, 'wb')
                # Only process the samples if the file type is a list
                if type(sample.general.fastqfiles) is list:
                    # Set the forward fastq to be the first entry in the list
                    forwardfastq = sorted(sample.general.fastqfiles)[0]
                    # If the files are gzipped, then zcat must be used instead of cat
                    if '.gz' in forwardfastq:
                        command = 'zcat'
                    else:
                        command = 'cat'
                    # Read in the output of the (z)cat of the fastq file piped through head to read only the first 1000
                    # lines. Will make a string of the first 1000 lines in the file
                    forwardreads = subprocess.Popen("{} {} | head -n 1000".format(command, forwardfastq),
                                                    shell=True,
                                                    stdout=subprocess.PIPE,
                                                    stderr=devnull).communicate()[0].rstrip()
                    # Set the length of the reads as follows: the highest value (max) of the length of the sequence. The
                    # sequence was extracted from the rest of the lines in the fastq file. Example of first four lines:
                    """
                    @M02466:126:000000000-AKF4P:1:1101:11875:1838 1:N:0:1
                    TCATAACGCAGTGAAACGCTTTAACAAAAGCGGAGACACGCCACTATTTGTCAATATTTCGTATGATACATTTTTAGAAAATCAAGAAGAGTTGCACGA
                    +
                    AA,B89C,@++B,,,,C,:BFF9,C,,,,,6+++++:,C,8C+BE,EFF9FC,6E,EFGF@F<F@9F9E<FFGGGC8,,,,CC<,,,,,,6CE,C<C,,
                    """
                    # The line with the sequence information occurs every four lines (1, 5, 9, etc). This can be
                    # represented by linenumber % 4 == 1
                    try:
                        # Added due to weird 2to3 conversion issues, was coming
                        forwardreads = forwardreads.decode('utf-8')
                    except UnicodeDecodeError:
                        sample.run.forwardlength = 0
                    # up as a bytes object when we need it as a string.
                    try:
                        forwardlength = max([len(sequence) for iterator, sequence in enumerate(forwardreads.split('\n'))
                                             if iterator % 4 == 1])
                        sample.run.forwardlength = forwardlength
                    except (ValueError, TypeError):
                        sample.run.forwardlength = 0
                    # For paired end analyses, also calculate the length of the reverse reads
                    if len(sample.general.fastqfiles) == 2:
                        reversefastq = sorted(sample.general.fastqfiles)[1]
                        reversereads = subprocess.Popen("{} {} | head -n 1000".format(command, reversefastq),
                                                        shell=True,
                                                        stdout=subprocess.PIPE,
                                                        stderr=devnull).communicate()[0].rstrip()
                        try:
                            reversereads = reversereads.decode('utf-8')
                        except UnicodeDecodeError:
                            sample.run.reverselength = 0
                        try:
                            sample.run.reverselength = max([len(sequence) for iterator, sequence in
                                                            enumerate(reversereads.split('\n')) if iterator % 4 == 1])
                        except (ValueError, TypeError):
                            sample.run.reverselength = 0
                    # Populate metadata of single end reads with 'NA'
                    else:
                        sample.run.reverselength = 0
Calculates the read length of the fastq files. Short reads will not be able to be assembled properly with the
        default parameters used for spades.