def generate_top(bases, output):
    """Generates a topology file for oxrna

    Args:
        bases -- list<Base>
        output -- str: path to the output file
    Returns:
        str -- path to the created file
    """
    path = output.split(".conf")[0]
    if not path.endswith(".top"):
         path += ".top"
    print("Generating a topology file {}".format(path))

    f = open(path, "w")
    strands = 1
    for s in range(1, strands + 1):
        num = len(bases)
        f.write("{} {}\n".format(num, strands))
        for i, b in enumerate(bases):
            prev = i - 1
            next = i + 1 if i < num - 1 else -1
            f.write("{} {} {} {}\n".format(s, b.type, prev, next))
    f.close()
    return path