FASTA is a candidate for the stupidest file format ever invented and a testament to the massive gap in perceived vs actual programming ability of the average bioinformatician.
other file formats that rival fasta in stupidity include fastq pdb bed sam cram vcf. further reading [1] > "intentionally or not, bioinformatics found a way to survive: obfuscation. By making the tools unusable, by inventing file format after file format, by seeking out the most brittle techniques" 1. https://madhadron.com/science/farewell_to_bioinformatics.htm...
Removing newlines in FASTA file increases ZSTD compression ratio by 10x
31–40 of 118 posts
Re: Removing newlines in FASTA file increases ZSTD compression ratio by 10x
#32Damn surely you stop using ASCII formats before your dataset gets to 2 TB??
Re: Removing newlines in FASTA file increases ZSTD compression ratio by 10x
#33FASTA is a candidate for the stupidest file format ever invented and a testament to the massive gap in perceived vs actual programming ability of the average bioinformatician.
I’ll do you the immense favor of taking the bait. What’s so bad about it?
A parser to stream FASTA can be written in like 30 lines [0], much easier than say CSV where the edge cases can get hairy.
If you need something like fast random reads, use the FAIDX format [1], or even better just store it in an LMDB or SQLite embedded db.
People forget FASTA was from 1985, and it sticks around because (1) it's easy to parse and write (2) we have mountains of sequences in that format going back 4 decades.
[O] https://gist.github.com/jszym/9860a2671dabb45424f2673a49e4b5...
[1] https://seqan.readthedocs.io/en/main/Tutorial/InputOutput/In...
Re: Removing newlines in FASTA file increases ZSTD compression ratio by 10x
#34Earlier quoted context omitted.
The FASTA format stores nucleotides in text form... compression is used to make this tractable at genome sizes, but it's by no means perfect. Depending on what you need to represent, you can get a 4x reduction in data size without compression at all, by just representing a GATC with 2 bits, rather than 8. Compression on top of that "should" result in the same compressed size as the original text (after all, the "info…
I think one important factor you missed to account for is frameshifting. Compression algorithms work on bytes - 8 bits. Imagine that you have the exact same sequence but they occur at different offsets mod 4. Then your encoding will give completely different results, and the compression algorithm will be unable to make use of the repetition.
Re: Removing newlines in FASTA file increases ZSTD compression ratio by 10x
#35Nice observation! Took me a while to realize that Grace Blackwell refers to a person and not an Nvidia chip :) I’ve worked with large genomic datasets on my own dime, and the default formats show their limits quickly. With FASTA, the first step for me is usually conversion: unzip headers from sequences, store them in Arrow-like tapes for CPU/GPU processing, and persist as Parquet when needed. It’s straightforward, bu…
> Took me a while to realize that Grace Blackwell refers to a person and not an Nvidia chip :)
I even confused myself about this while writing :-)
Re: Removing newlines in FASTA file increases ZSTD compression ratio by 10x
#36The FASTA format looks like: > title bases with optional newlines > title bases with optional newlines ... The author is talking about removing the non-semantic optional newlines (hard wrapping), not all the newlines in the file. It makes a lot of sense that this would work: bacteria have many subsequences in common, but if you insert non-semantic newlines at effectively random offsets then compression tools will not…
Re: Removing newlines in FASTA file increases ZSTD compression ratio by 10x
#37Damn surely you stop using ASCII formats before your dataset gets to 2 TB??
Re: Removing newlines in FASTA file increases ZSTD compression ratio by 10x
#38Now I'm wondering why this works. DNA clearly has some interesting redundancy strategies. (it might also depend on genome?)
This is a dataset of bacterial DNA. Any two related bacteria will have long strings of the same letters. But it won't be neatly aligned, so the line breaks will mess up pattern matching.
Re: Removing newlines in FASTA file increases ZSTD compression ratio by 10x
#39The FASTA format looks like: > title bases with optional newlines > title bases with optional newlines ... The author is talking about removing the non-semantic optional newlines (hard wrapping), not all the newlines in the file. It makes a lot of sense that this would work: bacteria have many subsequences in common, but if you insert non-semantic newlines at effectively random offsets then compression tools will not…
Surprisingly, it gave an answer along the lines of the parent comment.
However, it seems it didn't figure this out by itself but it says:
> It’s widely known in bioinformatics that “one-line Fasta” files compress much better with LZ-based algorithms, and this is discussed in forums, papers, and practical guides on storing genomic data.
Re: Removing newlines in FASTA file increases ZSTD compression ratio by 10x
#40Earlier quoted context omitted.
The compression ratio will likely skyrocket if you sorted the list of bases.
You're joking, but a few bioinformatics tools use the Burrows-Wheeler transform to save memory, which is a bit like sorting the bases.