<commit_before>#!/usr/bin/env python
import re

with open("./glycan") as f:
    text = "".join(f.readlines())

descriptions = text.split("///\n")

m2name = ["met\tname\tpathway"]

for description in descriptions:
    if description == "":
        continue
    lines = description.split("\n")
    shift = 12
    last_name = None
    d = {}
    for line in lines:
        if line == "":
            continue
        name = line[:shift].strip()
        value = line[shift:]
        if name == "":
            name = last_name

        if name in d:
            d[name] += "\n" + value
        else:
            d[name] = value

        last_name = name

    met_id = d["ENTRY"].split()[0]

    escaped_name = ""
    if "NAME" in d:
        escaped_name = d["NAME"].replace("\n", " ") \
                                .replace('"', '\\"') \
                                .replace("<","") \
                                .replace(">","")

        if "FORMULA" in d:
            for name in d["NAME"].split("\n"):
                if name.endswith(";"):
                    name = name[:-1]

                name_full = name

                if name == "beta-Tyrosine":
                    pass
                elif name.startswith("beta-"):
                    name = name[len("beta-"):]
                elif name.startswith("alpha-"):
                    name = name[len("alpha-"):]




                name = "%s: %s" % (d["FORMULA"], name)

                if not name in anomers:
                    anomers[name] = []
                anomers[name].append((name_full, met_id))


    pathways = ""
    if "PATHWAY" in d:
        pathways = "+".join([p.split()[0] for p in d["PATHWAY"].split("\n")])

    m2name.append('%s\t"%s"\t"%s"' % (met_id, escaped_name, pathways))

with open("gly2name.tsv", "w") as f:
    f.write("%s\n" % "\n".join(m2name))<commit_msg>removed code for anomers in convert_glycan<commit_after>#!/usr/bin/env python
import re

with open("./glycan") as f:
    text = "".join(f.readlines())

descriptions = text.split("///\n")

m2name = ["met\tname\tpathway"]

for description in descriptions:
    if description == "":
        continue
    lines = description.split("\n")
    shift = 12
    last_name = None
    d = {}
    for line in lines:
        if line == "":
            continue
        name = line[:shift].strip()
        value = line[shift:]
        if name == "":
            name = last_name

        if name in d:
            d[name] += "\n" + value
        else:
            d[name] = value

        last_name = name

    met_id = d["ENTRY"].split()[0]

    escaped_name = ""
    if "NAME" in d:
        escaped_name = d["NAME"].replace("\n", " ") \
                                .replace('"', '\\"') \
                                .replace("<","") \
                                .replace(">","")


    pathways = ""
    if "PATHWAY" in d:
        pathways = "+".join([p.split()[0] for p in d["PATHWAY"].split("\n")])

    m2name.append('%s\t"%s"\t"%s"' % (met_id, escaped_name, pathways))

with open("gly2name.tsv", "w") as f:
    f.write("%s\n" % "\n".join(m2name))
{'fraction_non_alphanumeric': 0.17839922854387658, 'fraction_numerical': 0.00546448087431694, 'mean_word_length': 1.5177993527508091, 'pattern_counts': {'":': 7, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7296944', 'n_tokens_mistral': 1022, 'n_tokens_neox': 980, 'n_words': 221}