# Buggy code
def parse_qorts(self, f):
    s_names = None
    for l in f["f"]:
        s = l.split("\t")
        if s_names is None:
            s_names = [self.clean_s_name(s_name, f["root"]) for s_name in s[1:]]
            if len(s_names) == 1 and s_names[0] == "COUNT":
                s_names = [f["s_name"]]
            for s_name in s_names:
                if s_name in self.qorts_data:
                    log.debug(
                        "Duplicate sample name found! Overwriting: {}".format(s_name)
                    )
                self.qorts_data[s_name] = dict()
        else:
            for i, s_name in enumerate(s_names):
                self.qorts_data[s_name][s[0]] = float(s[i + 1])
    # Add some extra fields
    for i, s_name in enumerate(s_names):
        if (
            "Genes_Total" in self.qorts_data[s_name]
            and "Genes_WithNonzeroCounts" in self.qorts_data[s_name]
        ):
            self.qorts_data[s_name]["Genes_PercentWithNonzeroCounts"] = (
                self.qorts_data[s_name]["Genes_WithNonzeroCounts"]
                / self.qorts_data[s_name]["Genes_Total"]
            ) * 100.0


# Traceback (ValueError)
multiqc input/pipeline5a-exemplar6 -o multiqc-pipeline5a-exemplar6
[INFO   ]         multiqc : This is MultiQC v1.3
[INFO   ]         multiqc : Template    : default
[INFO   ]         multiqc : Searching 'input/pipeline5a-exemplar6'
Searching 662 files..  [####################################]  100%
[ERROR  ]         multiqc : Oops! The 'qorts' MultiQC module broke...
Please copy the following traceback and report it at https://github.com/ewels/MultiQC/issues
(if possible, include a log file that triggers the error)
============================================================
Module qorts raised an exception: Traceback (most recent call last):
File "/sw/lsa/centos7/python-anaconda2/created-20170421b/bin/multiqc", line 412, in multiqc
output = mod()
File "/sw/lsa/centos7/python-anaconda2/created-20170421b/lib/python2.7/site-packages/multiqc/modules/qorts/qorts.py", line 29, in __init__
self.parse_qorts(f)
File "/sw/lsa/centos7/python-anaconda2/created-20170421b/lib/python2.7/site-packages/multiqc/modules/qorts/qorts.py", line 64, in parse_qorts
self.qorts_data[s_name][s[0]] = float(s[i+1])
ValueError: could not convert string to float: Code for the strandedness rule used. 0 if data is unstranded, 1 if data is fr_firstStrand, 2 if data is fr_secondStrand.
============================================================
[INFO   ]            star : Found 6 reports
[INFO   ]          fastqc : Found 24 reports
[INFO   ]         multiqc : Compressing plot data
[INFO   ]         multiqc : Report      : multiqc-pipeline5a-exemplar6/multiqc_report.html
[INFO   ]         multiqc : Data        : multiqc-pipeline5a-exemplar6/multiqc_data
[INFO   ]         multiqc : MultiQC complete

# Fixed code
def parse_qorts(self, f):
    s_names = None
    for l in f["f"]:
        s = l.split("\t")
        if s_names is None:
            s_names = [self.clean_s_name(s_name, f["root"]) for s_name in s[1:]]
            if len(s_names) <= 2 and s_names[0] == "COUNT":
                if f["fn"] == "QC.summary.txt":
                    s_names = [
                        self.clean_s_name(
                            os.path.basename(os.path.normpath(f["root"])), f["root"]
                        )
                    ]
                else:
                    s_names = [f["s_name"]]
            for s_name in s_names:
                if s_name in self.qorts_data:
                    log.debug(
                        "Duplicate sample name found! Overwriting: {}".format(s_name)
                    )
                self.qorts_data[s_name] = dict()
        else:
            for i, s_name in enumerate(s_names):
                self.qorts_data[s_name][s[0]] = float(s[i + 1])
    # Add some extra fields
    for i, s_name in enumerate(s_names):
        if (
            "Genes_Total" in self.qorts_data[s_name]
            and "Genes_WithNonzeroCounts" in self.qorts_data[s_name]
        ):
            self.qorts_data[s_name]["Genes_PercentWithNonzeroCounts"] = (
                self.qorts_data[s_name]["Genes_WithNonzeroCounts"]
                / self.qorts_data[s_name]["Genes_Total"]
            ) * 100.0