Skip to main content
Added timings for fastx_read from mappy
Source Link
bli
  • 3.2k
  • 2
  • 16
  • 36

fastx_read from mappy

I realize (27/08/2020) that I hadn't added a benchmark for fastx_read from mappy which I regularly use since quite some time already:

$ time python3 -c "from mappy import fastx_read; print(sum(seq.count('A') for (_, seq, _) in fastx_read('genome.fa')))"
32371810

real    0m0.731s
user    0m0.648s
sys     0m0.080s
$ time python3 -c "from pyfastx import Fastq; print(sum(seq.count('N') for (_, seq, _) in Fastq('SRR077487_2.filt.fastq.gz', build_index=False)))"
306072

real    0m51.140s
user    0m50.784s
sys     0m0.352s

fastx_read from mappy (added 27/08/2020)

$ time python3 -c "from mappy import fastx_read; print(sum(seq.count('N') for (_, seq, _) in fastx_read('SRR077487_2.filt.fastq.gz')))"
306072

real    0m52.336s
user    0m52.024s
sys     0m0.300s

(Update 27/08/2020) pyfastx seemsand mappy seem quite convenient too, and are only slightly slower than pyGATB.

$ time python3 -c "from pyfastx import Fastq; print(sum(seq.count('N') for (_, seq, _) in Fastq('SRR077487_2.filt.fastq.gz', build_index=False)))"
306072

real    0m51.140s
user    0m50.784s
sys     0m0.352s

(Update 27/08/2020) pyfastx seems quite convenient too, and only slightly slower than pyGATB.

fastx_read from mappy

I realize (27/08/2020) that I hadn't added a benchmark for fastx_read from mappy which I regularly use since quite some time already:

$ time python3 -c "from mappy import fastx_read; print(sum(seq.count('A') for (_, seq, _) in fastx_read('genome.fa')))"
32371810

real    0m0.731s
user    0m0.648s
sys     0m0.080s
$ time python3 -c "from pyfastx import Fastq; print(sum(seq.count('N') for (_, seq, _) in Fastq('SRR077487_2.filt.fastq.gz', build_index=False)))"
306072

real    0m51.140s
user    0m50.784s
sys     0m0.352s

fastx_read from mappy (added 27/08/2020)

$ time python3 -c "from mappy import fastx_read; print(sum(seq.count('N') for (_, seq, _) in fastx_read('SRR077487_2.filt.fastq.gz')))"
306072

real    0m52.336s
user    0m52.024s
sys     0m0.300s

(Update 27/08/2020) pyfastx and mappy seem quite convenient too, and are only slightly slower than pyGATB.

Added timings for pyfastx-based solutions.
Source Link
bli
  • 3.2k
  • 2
  • 16
  • 36

pyfastx

I read about pyfastx today (27/08/2020), which has a sequence reader.

$ time python3 -c "from pyfastx import Fasta; print(sum(seq.count('A') for (_, seq) in Fasta('genome.fa', build_index=False)))"
32371810

real    0m0.781s
user    0m0.740s
sys     0m0.040s

(The timing is done using python 3.6, on the same machine as previous timings from 3 years ago, so it should be comparable.)

$ time python -c "from gzip import open as gzopen; from Bio.SeqIO.QualityIO import FastqGeneralIterator; print(sum(seq.count('N') for (_, seq, _) in FastqGeneralIterator(gzopen('SRR077487_2.filt.fastq.gz'))))"
306072

real    3m18.103s
user    3m17.676s
sys     0m0.428s

pyfastx (added 27/08/2020)

$ time python3 -c "from pyfastx import Fastq; print(sum(seq.count('N') for (_, seq, _) in Fastq('SRR077487_2.filt.fastq.gz', build_index=False)))"
306072

real    0m51.140s
user    0m50.784s
sys     0m0.352s

(Update 27/08/2020) pyfastx seems quite convenient too, and only slightly slower than pyGATB.

$ time python -c "from gzip import open as gzopen; from Bio.SeqIO.QualityIO import FastqGeneralIterator; print(sum(seq.count('N') for (_, seq, _) in FastqGeneralIterator(gzopen('SRR077487_2.filt.fastq.gz'))))"
306072

real    3m18.103s
user    3m17.676s
sys     0m0.428s

pyfastx

I read about pyfastx today (27/08/2020), which has a sequence reader.

$ time python3 -c "from pyfastx import Fasta; print(sum(seq.count('A') for (_, seq) in Fasta('genome.fa', build_index=False)))"
32371810

real    0m0.781s
user    0m0.740s
sys     0m0.040s

(The timing is done using python 3.6, on the same machine as previous timings from 3 years ago, so it should be comparable.)

$ time python -c "from gzip import open as gzopen; from Bio.SeqIO.QualityIO import FastqGeneralIterator; print(sum(seq.count('N') for (_, seq, _) in FastqGeneralIterator(gzopen('SRR077487_2.filt.fastq.gz'))))"
306072

real    3m18.103s
user    3m17.676s
sys     0m0.428s

pyfastx (added 27/08/2020)

$ time python3 -c "from pyfastx import Fastq; print(sum(seq.count('N') for (_, seq, _) in Fastq('SRR077487_2.filt.fastq.gz', build_index=False)))"
306072

real    0m51.140s
user    0m50.784s
sys     0m0.352s

(Update 27/08/2020) pyfastx seems quite convenient too, and only slightly slower than pyGATB.

Added fasta benchmark for scikit-bio
Source Link
bli
  • 3.2k
  • 2
  • 16
  • 36

scikit-bio

I read about scikit-bio today (23/06/2017), which has a sequence reader.

$ time python3 -c  "import skbio; print(sum(seq.count('A') for seq in skbio.io.read('genome.fa', format='fasta', verify=False)))"
32371810

real    0m3.643s
user    0m3.440s
sys     0m1.228s

scikit-bio

I read about scikit-bio today (23/06/2017), which has a sequence reader.

$ time python3 -c  "import skbio; print(sum(seq.count('A') for seq in skbio.io.read('genome.fa', format='fasta', verify=False)))"
32371810

real    0m3.643s
user    0m3.440s
sys     0m1.228s
Added benchmarks for fastq.gz
Source Link
bli
  • 3.2k
  • 2
  • 16
  • 36
Loading
Added solution using SimpleFastaParser
Source Link
bli
  • 3.2k
  • 2
  • 16
  • 36
Loading
Applied suggestion to avoid decode
Source Link
bli
  • 3.2k
  • 2
  • 16
  • 36
Loading
Tried to improve readability, emphasised that the pyGATB solution is tested with python3, added Biopython solution
Source Link
bli
  • 3.2k
  • 2
  • 16
  • 36
Loading
Tried to improve readability, emphasised that the pyGATB solution is tested with python3
Source Link
bli
  • 3.2k
  • 2
  • 16
  • 36
Loading
Added a pyGATB based solution
Source Link
bli
  • 3.2k
  • 2
  • 16
  • 36
Loading
added 1 character in body
Source Link
bli
  • 3.2k
  • 2
  • 16
  • 36
Loading
Added python-based versions and link to where I got the gsub hack from
Source Link
bli
  • 3.2k
  • 2
  • 16
  • 36
Loading
Source Link
bli
  • 3.2k
  • 2
  • 16
  • 36
Loading