# Buggy code
def parse_tag_info(self, f):
    """Parse HOMER tagdirectory taginfo.txt file to extract statistics in the first 11 lines."""
    # General Stats Table
    tag_info = dict()
    counter = 0
    for l in f["f"]:
        if counter == 1:
            s = l.split("\t")
            tag_info["UniqPositions"] = float(s[1].strip())
            tag_info["TotalPositions"] = float(s[2].strip())
        if counter == 4:
            s = l.split("\t")
            tag_info["fragmentLengthEstimate"] = float(s[0].strip().split("=")[1])
        if counter == 5:
            s = l.split("\t")
            tag_info["peakSizeEstimate"] = float(s[0].strip().split("=")[1])
        if counter == 6:
            s = l.split("\t")
            tag_info["tagsPerBP"] = float(s[0].strip().split("=")[1])
        if counter == 7:
            s = l.split("\t")
            tag_info["averageTagsPerPosition"] = float(s[0].strip().split("=")[1])
        if counter == 8:
            s = l.split("\t")
            tag_info["averageTagLength"] = float(s[0].strip().split("=")[1])
        if counter == 9:
            s = l.split("\t")
            tag_info["gsizeEstimate"] = float(s[0].strip().split("=")[1])
        if counter == 10:
            s = l.split("\t")
            tag_info["averageFragmentGCcontent"] = float(s[0].strip().split("=")[1])
        if counter == 11:
            break
        counter = counter + 1
    return tag_info


# Traceback (IndexError)
szha0069@biomate1:~/test_seq_files/analysis/tags$ multiqc .
[WARNING]         multiqc : MultiQC Version v1.4 now available!
[INFO   ]         multiqc : This is MultiQC v1.3
[INFO   ]         multiqc : Template    : default
[INFO   ]         multiqc : Searching '.'
Searching 33 files..  [####################################]  100%
[ERROR  ]         multiqc : Oops! The 'homer' 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 homer raised an exception: Traceback (most recent call last):
File "/mnt/software/apps/multiqc-1.3/bin/multiqc", line 412, in multiqc
output = mod()
File "/mnt/software/apps/multiqc-1.3/lib/python3.5/site-packages/multiqc/modules/homer/homer.py", line 60, in __init__
n['Homer_tagDir'] = self.homer_tagdirectory()
File "/mnt/software/apps/multiqc-1.3/lib/python3.5/site-packages/multiqc/modules/homer/tagdirectory.py", line 24, in homer_tagdirectory
self.parse_tagInfo_data()
File "/mnt/software/apps/multiqc-1.3/lib/python3.5/site-packages/multiqc/modules/homer/tagdirectory.py", line 142, in parse_tagInfo_data
parsed_data = self.parse_tag_info(f)
File "/mnt/software/apps/multiqc-1.3/lib/python3.5/site-packages/multiqc/modules/homer/tagdirectory.py", line 349, in parse_tag_info
tag_info['gsizeEstimate'] = float(s[0].strip().split("=")[1])
IndexError: list index out of range
============================================================
[WARNING]         multiqc : No analysis results found. Cleaning up..
[INFO   ]         multiqc : MultiQC complete

# Fixed code
def parse_tag_info(self, f):
    """Parse HOMER tagdirectory taginfo.txt file to extract statistics in the first 11 lines."""
    # General Stats Table
    tag_info = dict()
    for l in f["f"]:
        s = l.split("=")
        if len(s) > 1:
            if s[0].strip() == "genome":
                ss = s[1].split("\t")
                if len(ss) > 2:
                    tag_info["genome"] = ss[0].strip()
                    try:
                        tag_info["UniqPositions"] = float(ss[1].strip())
                        tag_info["TotalPositions"] = float(ss[2].strip())
                    except:
                        tag_info["UniqPositions"] = ss[1].strip()
                        tag_info["TotalPositions"] = ss[2].strip()
            try:
                tag_info[s[0].strip()] = float(s[1].strip())
            except ValueError:
                tag_info[s[0].strip()] = s[1].strip()
    return tag_info