10 comments

  • jefftk 1 hour 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.

    • bede 45 minutes ago
      Thank you for clarifying this – yes the non-semantic nature of these particular line breaks is a key detail I omitted.
    • AndrewOMartin 1 hour ago
      The compression ratio will likely skyrocket if you sorted the list of bases.
      • shellfishgene 39 minutes 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 1 hour 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 1 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 1 hour ago
      It uses more memory (up to +2gb) during decompression as well -> potential DoS.
      • Aachen 1 hour 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 1 hour 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 :(

    • bede 2 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 :-)

    • jltsiren 41 minutes 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.
  • Aachen 1 hour 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

  • semiinfinitely 1 hour 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.
  • leobuskin 2 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.
  • FL33TW00D 1 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 2 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 2 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.
  • IshKebab 1 hour ago
    Damn surely you stop using ASCII formats before your dataset gets to 2 TB??
    • bede 22 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 40 minutes ago
      no, I power thru indefinitely with no recourse
  • 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 2 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 2 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 6 minutes ago
          I was actually under the impression compression algorithms tend to work over a bitstream, but I can't entirely confirm that.
    • vintermann 2 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.