def parserunstats(self):
        """Parses the XML run statistics file (GenerateFASTQRunStatistics.xml). In some cases, the file is not
        available. Equivalent data can be pulled from Basespace.Generate a text file  name indexingQC.txt containing
        the copied tables from the Indexing QC tab of the run on Basespace"""
        # metadata = GenObject()
        # If the default file GenerateFASTQRunStatistics.xml is present, parse it
        if os.path.isfile(os.path.join(self.path, "GenerateFASTQRunStatistics.xml")):
            # Create a list of keys for which values are to be extracted
            datalist = ["SampleNumber", "SampleID", "SampleName", "NumberOfClustersPF"]
            # Load the file as an xml ElementTree object
            runstatistics = ElementTree.ElementTree(file=os.path.join(self.path, "GenerateFASTQRunStatistics.xml"))
            # Iterate through all the elements in the object
            # .iterfind() allow for the matching and iterating though matches
            # This is stored as a float to allow subsequent calculations
            tclusterspf = [float(element.text) for element in runstatistics.iterfind("RunStats/NumberOfClustersPF")][0]
            # Iterate through all the elements (strains) in the OverallSamples/SummarizedSampleStatistics category
            for element in runstatistics.iterfind("OverallSamples/SummarizedSampleStatistics"):
                # List comprehension. Essentially iterate through each element for each category in datalist:
                # (element.iter(category) and pull out the value for nestedelement
                straindata = [nestedelement.text for category in datalist for nestedelement in element.iter(category)]
                # Try and replicate the Illumina rules to create file names from "Sample_Name"
                samplename = samplenamer(straindata, 1)
                # Calculate the percentage of clusters associated with each strain
                # noinspection PyTypeChecker
                percentperstrain = "{:.2f}".format((float(straindata[3]) / tclusterspf * 100))
                try:
                    # Use the sample number -1 as the index in the list of objects created in parsesamplesheet
                    strainindex = int(straindata[0]) - 1
                    # Set run to the .run object of self.samples[index]
                    run = self.samples[strainindex].run
                    # An assertion that compares the sample computed above to the previously entered sample name
                    # to ensure that the samples are the same
                    assert self.samples[strainindex].name == samplename, \
                        "Sample name does not match object name {0!r:s}".format(straindata[1])
                    # Add the appropriate values to the strain metadata object
                    run.SampleNumber = straindata[0]
                    run.NumberofClustersPF = straindata[3]
                    run.TotalClustersinRun = tclusterspf
                    run.PercentOfClusters = percentperstrain
                    run.flowcell = self.flowcell
                    run.instrument = self.instrument
                except IndexError:
                    pass
        else:
            strainindex = 0
            for i in range(len(self.samples)):
                # Set run to the .run object of self.samples[index]
                run = self.samples[strainindex].run
                # Update the object with the variables
                run.SampleNumber = strainindex + 1
                run.NumberofClustersPF = 'NA'
                run.TotalClustersinRun = 'NA'
                run.PercentOfClusters = 'NA'
                run.flowcell = self.flowcell
                run.instrument = self.instrument
                strainindex += 1
Parses the XML run statistics file (GenerateFASTQRunStatistics.xml). In some cases, the file is not
        available. Equivalent data can be pulled from Basespace.Generate a text file  name indexingQC.txt containing
        the copied tables from the Indexing QC tab of the run on Basespace