Comment

Comment by samuell

Hmm, a bit of a rough experience.

I had a few lines of python code, to count the fraction of A:s and C:s in a DNA (fasta) file adapted from [1]:

    with open("chry_multiplied.fa") as infile:
        a: int = 0
        t: int = 0
        g: int = 0
        c: int = 0
        for line in infile:
            if line[0] != '>' and len(line) != line.count("N") + 1:
                g += line.count("G")
                c += line.count("C")
                a += line.count("A")
                t += line.count("T")
        total_base_count = a + t + c + g
        gc_count = g + c
        gc_fraction = float(gc_count) / total_base_count
        print( gc_fraction * 100 )
Result:

    $ mojo run gc.mojo 
    gc.mojo:1:6: error: use of unknown declaration 'open'
    with open("chry_multiplied.fa") as infile:
    ...
"open" must be one of the most used Python functions ... :/

[1] https://github.com/samuell/gccontent-benchmark

parent samuell 3 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton