The Computer Language
24.11 Benchmarks Game

reverse-complement MicroPython #4 program

source code

# The Computer Language Benchmarks Game
# https://salsa.debian.org/benchmarksgame-team/benchmarksgame/
#
# contributed by Jacob Lee, Steven Bethard, et al
# 2to3, fixed by Daniele Varrazzo
# modified by Daniel Nanz

import sys


def show(seq, table=bytes.maketrans(b'ACBDGHKMNSRUTWVYacbdghkmnsrutwvy',
                                    b'TGVHCDMKNSYAAWBRTGVHCDMKNSYAAWBR'),
         write=sys.stdout.buffer.write, nl=b'\n'):
    
    [header, s] = seq.split(nl, 1)
    s = s.translate(table, nl)[: : -1]
    
    write(b'>' + header + nl)
    for i in range(0, len(s), 60):
        write(s[i : i + 60] + nl)



def main():
    
    sys.stdin = sys.stdin.detach()
    seqs = b''.join([line for line in sys.stdin]).split(b'>')[1 : ]
    
    for seq in seqs:
        show(seq)        


main()
    

notes, command-line, and program output

NOTES:
64-bit Ubuntu quad core
MicroPython v1.24.0
preview.44.ge9c898cb3


 Thu, 20 Jun 2024 19:59:48 GMT

COMMAND LINE:
 /opt/src/micropython/micropython  -X emit=native revcomp.micropython-4.micropython 0 < revcomp-input250000.txt

PROGRAM FAILED 


PROGRAM OUTPUT:

AttributeError: type object 'bytes' has no attribute 'maketrans'