<commit_before>"""
Annotation file formatters
"""
class GFFFormatter(object):
    """Formatter for GFF annotation files"""
    def __init__(self):
        """Creates a new GFFFormater instance"""
        pass

    def format(self, input_file, **kwargs):
        """Format and print GFF file contents"""
        from BCBio import GFF
        from cats.styles import colors

        fp = open(input_file)

        # output buffer
        buffer = ""

        # Output templates
        _gene = colors.BLUE + "[%s] %s (%d features)\n"
        _mrna = colors.CYAN + "%s: %s (%d features)\n"
        _feat = colors.RED + "%s %d - %d\n"

        # parse each entry in GFF file
        for entry in GFF.parse(fp):
            buffer += colors.BLUE_DARK + entry.id + "\n"
            for gene in entry.features:
                buffer += _gene % (gene.type, gene.id, len(gene.sub_features))
                for mrna in gene.sub_features:
                    buffer += _mrna % (mrna.type, mrna.id, 
                                       len(mrna.sub_features))
                    for feature in mrna.sub_features:
                        loc = feature.location
                        buffer += _feat % (feature.type, loc.start, loc.end)

        # close file handle
        fp.close()

        return buffer<commit_msg>Updated GFF parser display original file contents as-is by default<commit_after>"""
Annotation file formatters
"""
class GFFFormatter(object):
    """Formatter for GFF annotation files"""
    def __init__(self):
        """Creates a new GFFFormater instance"""
        pass

    def format(self, input_file, **kwargs):
        """Format and print GFF file contents"""
        from BCBio import GFF
        from cats.styles import colors
        from io import StringIO

        fp = open(input_file)

        # string and output buffers
        contents = StringIO()
        output = ""

        # Read contents of file into a string buffer
        contents.write(fp.read())
        contents.seek(0)
        fp.seek(0)

        # Output templates
        #_gene = colors.BLUE + "[%s] %s (%d features)\n"
        #_mrna = colors.CYAN + "%s: %s (%d features)\n"
        #_feat = colors.RED + "%s %d - %d\n"

        # Output file contents, using GFFParser to navigate hierarchy
        for entry in GFF.parse(fp):
            for gene in entry.features:
                #output += _gene % (gene.type, gene.id, len(gene.sub_features))
                output += colors.BLUE + contents.readline()
                for mrna in gene.sub_features:
                    #output += _mrna % (mrna.type, mrna.id, 
                    #                   len(mrna.sub_features))
                    output += colors.CYAN + contents.readline()
                    for feature in mrna.sub_features:
                        #loc = feature.location
                        #output += _feat % (feature.type, loc.start, loc.end)
                        output += colors.RED + contents.readline()

        # close file and string handles
        fp.close()
        contents.close()

        return output

{'fraction_non_alphanumeric': 0.10626614987080103, 'fraction_numerical': 0.0006459948320413437, 'mean_word_length': 1.6767502160760588, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2247232', 'n_tokens_mistral': 880, 'n_tokens_neox': 832, 'n_words': 257}