Skip to content

Instantly share code, notes, and snippets.

@canimus
Created January 14, 2024 19:31

Revisions

  1. canimus created this gist Jan 14, 2024.
    13 changes: 13 additions & 0 deletions format_genbank.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    def format_sequence(sequence: str):
    """Format a DNA sequence as genbank file"""
    counter = 1
    print(f"{counter}".rjust(4, " "), end=" ")
    for a,b in zip(range(0,len(sequence)+1, 10), range(10, len(sequence)+1, 10)):
    print(sequence[a:b], end="")
    if ((counter % 6) == 0) and (b < (len(sequence)-1)):
    print("")
    print(f'{((counter*10) + 1)}'.rjust(4, " "), end=" ")
    else:
    print(" ", end="")

    counter += 1