jefftk 2 hours ago

The 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 be able to use the repetition effectively.

  • amelius 2 minutes ago

    Sounds like our compression tools can be made more intelligent about this sort of thing.

  • bede an hour ago

    Thank you for clarifying this – yes the non-semantic nature of these particular line breaks is a key detail I omitted.

  • AndrewOMartin an hour ago

    The compression ratio will likely skyrocket if you sorted the list of bases.

    • shellfishgene an hour ago

      You're joking, but a few bioinformatics tools use the Burrows-Wheeler transform to save memory, which is a bit like sorting the bases.

mfld 2 hours ago

    Using larger-than-default window sizes has the drawback of requiring that the same --long=xx argument be passed during decompression reducing compatibility somewhat.
Interesting. Any idea why this can't be stored in the metadata of the compressed file?
  • lifthrasiir 2 hours ago

    It is stored in the metadata [1], but anything larger than 8 MiB is not guaranteed to be supported. So there has to be an out-of-band agreement between compressor and decompressor.

    [1] https://datatracker.ietf.org/doc/html/rfc8878#name-window-de...

    • pbronez an hour ago

      Seems useful for games marketplaces like Steam and Xbox. You control the CDN and client, so you can use tricky but effective compression settings all day long.

  • nolist_policy 2 hours ago

    It uses more memory (up to +2gb) during decompression as well -> potential DoS.

    • Aachen 2 hours ago

      Sending a .zip filled with all zeroes, so it compresses extremely well, is a well-known DoS historically (zip bomb, making the server run out of space in trying to read the archive)

      You always need resource limits when dealing with untrusted data. RAM is one of the obvious ones. They could introduce a memory limit parameter; require passing --long with a value equal to or greater than what the stream requires to successfully decompress; require seeking support for the input stream so they can look back that way (TMTO); fall back to using temp files; or interactively prompt the user if there's a terminal attached. Lots of options, each with pros and cons of course, that would all allow a scenario where the required information for the decoder is stored in the compressed data file

ashvardanian 2 hours ago

Nice 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, but surprisingly underused in bioinformatics — most pipelines stick to plain text even when modern data tooling would make things much easier :(

  • jltsiren an hour ago

    Basic text formats persist, because everyone supports them. Many tools have better file formats for internal purposes, but they are rarely flexible enough and robust enough for wider use. There are occasional proposals for better general purpose formats, but the people proposing them rarely agree which of the competing proposals should be adopted. And even if they manage to agree, they probably don't have the time and the money to make it actually happen.

  • bede 15 minutes ago

    Yes, when doing anything intensive with lots of sequences it generally makes sense to liberate them from FASTA as early as possible and index them somehow. But as an interchange format FASTA seems quite sticky. I find the pervasiveness of fastq.gz particularly unfortunate with Gzip being as slow as it is.

    > 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 :-)

Aachen 2 hours ago

I've also noticed this. Zstandard doesn't see very common patterns

For me it was an increasing number (think of unix timestamps in a data logger that stores one entry per second, so you are just counting up until there's a gap in your data), in the article it's a fixed value every 60 bytes

Of course, our brains are exceedingly good at finding patterns (to the point where we often find phantom ones). I was just expecting some basic checks like "does it make sense to store the difference instead of the absolute value for some of these bytes here". Seeing as the difference is 0 between every 60th byte in the submitted article, that should fix both our issues

Bzip2 performed much better for me but it's also incredibly slow. If it were only the compressor, that might be fine for many applications, but also decompressing is an exercise in patience so I've moved to Zstandard at the standard thing to use

leobuskin 3 hours ago

What about a specialized dict for FASTA? Shouldn't it increase ZSTD compression significantly?

  • bede 2 hours ago

    Yes I'd expect a dict-based approach to do better here. That's probably how it should be done. But --long is compelling for me because using it requires almost no effort, it's still very fast, and yet it can dramatically improve compression ratio.

semiinfinitely 2 hours ago

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.

  • semiinfinitely 2 hours ago

    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...

    • jakobnissen 43 minutes ago

      SAM is not a bad file format. What's bad about SAM?

  • Fraterkes 2 hours ago

    I’ll do you the immense favor of taking the bait. What’s so bad about it?

IshKebab 2 hours ago

Damn surely you stop using ASCII formats before your dataset gets to 2 TB??

  • amelius a few seconds ago

    People rely on compression for that ;)

  • bede 35 minutes ago

    BAM format is widely used but assemblies still tend to be generated and exchanged in FASTA text. BAM is quite a big spec and I think it's fair to say that none of the simpler binary equivalents to FASTA and FASTQ have caught on yet (XKCD competing standards etc.)

    e.g. https://github.com/ArcInstitute/binseq

  • hhh an hour ago

    no, I power thru indefinitely with no recourse

FL33TW00D an hour ago

Looking forward to the relegation of FASTQ and FASTA to the depths of hell where they belong. Incredibly inefficient and poorly designed formats.

rini17 3 days ago

This might in general be a good preprocessing step to check for punctuation repeating in fixed intervals and remove it, and restore after decompression.

  • vintermann 3 hours ago

    That turns in into specialized compression, which DNA already has plenty of. Many forms of specialized compression even allow string-related queries directly on the compressed data.

  • bede 2 days ago

    Yes, it sounds like 7-Zip/LZMA can do this using custom filters, among other more exotic (and slow) statistical compression approaches.

Kim_Bruning 3 hours ago

Now I'm wondering why this works. DNA clearly has some interesting redundancy strategies. (it might also depend on genome?)

  • dwattttt 3 hours ago

    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 "information" being compressed is the same), except that compression isn't perfect.

    Newlines are an example of something that's "information" in the text format that isn't relevant, yet the compression scheme didn't know that.

    • hyghjiyhu 3 hours ago

      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.

      • dwattttt 18 minutes ago

        I was actually under the impression compression algorithms tend to work over a bitstream, but I can't entirely confirm that.

  • vintermann 3 hours ago

    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.

    • bede 2 hours ago

      Exactly. The line breaks break the runs of otherwise identical bits in identical sequences. Unless two identical subsequences are exactly in phase with respect to their line breaks, the hashes used for long range matching are different for otherwise identical subsequences.