# Buggy code
def quast_contigs_barplot(self):
    """Make a bar plot showing the number and length of contigs for each assembly"""

    # Prep the data
    data = dict()
    categories = []
    for s_name, d in self.quast_data.items():
        nums_by_t = dict()
        for k, v in d.items():
            m = re.match("# contigs \(>= (\d+) bp\)", k)
            if m:
                nums_by_t[int(m.groups()[0])] = v

        tresholds = sorted(nums_by_t.keys(), reverse=True)
        p = dict()
        cats = []
        for i, t in enumerate(tresholds):
            if i == 0:
                c = ">= " + str(t) + " bp"
                cats.append(c)
                p[c] = nums_by_t[t]
            else:
                c = str(t) + "-" + str(tresholds[i - 1]) + " bp"
                cats.append(c)
                p[c] = nums_by_t[t] - nums_by_t[tresholds[i - 1]]
        if not categories:
            categories = cats
        elif set(cats) != set(categories):
            log.warning(
                "Different contig threshold categories for samples, skip plotting barplot".format(
                    s_name
                )
            )
            continue
        data[s_name] = p

    pconfig = {
        "id": "quast_num_contigs",
        "title": "QUAST: Number of Contigs",
        "ylab": "# Contigs",
        "yDecimals": False,
    }

    return bargraph.plot(data, categories, pconfig)


# Traceback (TypeError)
[INFO   ]         multiqc : This is MultiQC v1.5
============================================================
Module quast raised an exception: Traceback (most recent call last):
File "/home/kevin/anaconda3/envs/assembly-env/bin/multiqc", line 442, in multiqc
output = mod()
File "/home/kevin/anaconda3/envs/assembly-env/lib/python2.7/site-packages/multiqc/modules/quast/quast.py", line 72, in __init__
plot = self.quast_contigs_barplot()
File "/home/kevin/anaconda3/envs/assembly-env/lib/python2.7/site-packages/multiqc/modules/quast/quast.py", line 279, in quast_contigs_barplot
p[c] = nums_by_t[t] - nums_by_t[tresholds[i - 1]]
TypeError: unsupported operand type(s) for -: 'unicode' and 'float'
============================================================
[WARNING]         multiqc : No analysis results found. Cleaning up..
[INFO   ]         multiqc : MultiQC complete

# Fixed code
def quast_contigs_barplot(self):
    """Make a bar plot showing the number and length of contigs for each assembly"""

    # Prep the data
    data = dict()
    categories = []
    for s_name, d in self.quast_data.items():
        nums_by_t = dict()
        for k, v in d.items():
            m = re.match("# contigs \(>= (\d+) bp\)", k)
            if m and v != "-":
                nums_by_t[int(m.groups()[0])] = int(v)

        tresholds = sorted(nums_by_t.keys(), reverse=True)
        p = dict()
        cats = []
        for i, t in enumerate(tresholds):
            if i == 0:
                c = ">= " + str(t) + " bp"
                cats.append(c)
                p[c] = nums_by_t[t]
            else:
                c = str(t) + "-" + str(tresholds[i - 1]) + " bp"
                cats.append(c)
                p[c] = nums_by_t[t] - nums_by_t[tresholds[i - 1]]
        if not categories:
            categories = cats
        data[s_name] = p

    pconfig = {
        "id": "quast_num_contigs",
        "title": "QUAST: Number of Contigs",
        "ylab": "# Contigs",
        "yDecimals": False,
    }

    return bargraph.plot(data, categories, pconfig)