20 comments

  • jefftk11 hours ago
    The FASTA format looks like:<p><pre><code> &gt; title bases with optional newlines &gt; title bases with optional newlines ... </code></pre> The author is talking about removing the non-semantic optional newlines (hard wrapping), not all the newlines in the file.<p>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.
    • LeifCarrotson3 hours ago
      In case &quot;bases with optional newlines&quot; wasn&#x27;t obvious to anyone else, a specific example (from Wikipedia) is:<p><pre><code> ;LCBO - Prolactin precursor - Bovine MDSKGSSQKGSRLLLLLVVSNLLLCQGVVSTPVCPNGPGNCQVSLRDLFDRAVMVSHYIHDLSS EMFNEFDKRYAQGKGFITMALNSCHTSSLPTPEDKEQAQQTHHEVLMSLILGLLRSWNDPLYHL VTEVRGMKGAPDAILSRAIEIEEENKRLLEGMEMIFGQVIPGAKETEPYPVWSGLPSLQTKDED ARYSAFYNLLHCLRRDSSKIDTYLKLLNCRIIYNNNC* </code></pre> where &quot;SS...EM&quot;, HL..VT&quot;, or &quot;ED..AR&quot; may be common subsequences, but the plaintext file arbitrarily wraps at column 65 so it renders on a DEC VT100 terminal from the 70s nicely.<p>Or, for an even simpler example:<p><pre><code> ; plaintext GATTAC AGATTA CAGATT ACCAGA TTACAG ATTACA </code></pre> becomes, on disk, something like<p><pre><code> ; plaintext\r\nGATTAC\r\nAGATTA\r\nCAGATT\r\nACCAGA\r\nTTACAG\r\nATTACA\r\n </code></pre> which is hard to compress, while<p><pre><code> ; plaintext\r\nGATTACAGATTACAGATTACCAGATTACAGATTACA </code></pre> is just<p><pre><code> &quot;; plaintext\r\n&quot; + &quot;GATTACA&quot; * 7 </code></pre> and then, if you want, you can reflow the text when it&#x27;s time to render to the screen.
      • tgtweak1 hour ago
        Feels like it could be an extension to the compression lib (and would retain newlines as such) vs requiring external document tailoring. Also feels like a very specific use case but this optimization might have larger applications outside this narrow field&#x2F;format.
      • Terr_48 minutes ago
        Huh, so in other words: &quot;If you don&#x27;t arbitrarily interrupt continuous sequences of data with cosmetic noise, they compress better.&quot;
    • bede10 hours ago
      Thank you for clarifying this – yes the non-semantic nature of these particular line breaks is a key detail I omitted.
      • tialaramex2 hours ago
        It might be worth (in some other context) introducing a pre-processing step which handles this at both ends. I&#x27;m thinking like PNG - the PNG compression is &quot;just&quot; zlib but for RGBA that wouldn&#x27;t do a great job, however there&#x27;s a (per row) filter step first, so e.g. we can store just the difference from the row above, now big areas of block colour or vertical stripes are mostly zeros and those compress well.<p>Guessing which PNG filters to use can make a <i>huge</i> difference to compression with only a tiny change to write speed. Or (like Adobe 20+ years ago) you can screw it up and get worse compression <i>and</i> slower speeds. These days brutal &quot;try everything&quot; modes exist which can squeeze out those last few bytes by trying even the unlikeliest combinations.<p>I can imagine a filter layer which says this textual data comes in 78 character blocks punctuated with \n so we&#x27;re going to strip those out, then compress and in the opposite direction we decompress then put back the newlines.<p>For FASTA we can just unconditionally choose to remove the extra newlines but that may not be true for most inputs, so the filters would help there.
    • AndrewOMartin10 hours ago
      The compression ratio will likely skyrocket if you sorted the list of bases.
      • shellfishgene10 hours ago
        You&#x27;re joking, but a few bioinformatics tools use the Burrows-Wheeler transform to save memory, which is a bit like sorting the bases.
        • jefftk9 hours ago
          You can also improve compression by reordering the sequences within the FASTA file, as long as you&#x27;re using it as a dictionary and not a list of title-sequence pairs.
    • mylons6 hours ago
      this is also the insight that the bwa developer had, to use the burrows-wheeler transform which is part of bzip2 due to it&#x27;s compression properties being particularly good for genomic sequences.
    • amelius9 hours ago
      This was a question that I thought was interesting enough to test ChatGPT with.<p>Surprisingly, it gave an answer along the lines of the parent comment.<p>However, it seems it didn&#x27;t figure this out by itself but it says:<p>&gt; 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.
  • felixhandte6 hours ago
    This is because Zstd&#x27;s long-distance matcher looks for matching sequences of 64 bytes [0]. Because long matching sequences of the data will likely have the newlines inserted in different offsets in the run, this totally breaks Zstd&#x27;s ability to find the long-distance match.<p>Ultimately, Zstd is a byte-oriented compressor that doesn&#x27;t understand the semantics of the data it compresses. Improvements are certainly possible if you can recognize and separate that framing to recover a contiguous view of the underlying data.<p>[0] <a href="https:&#x2F;&#x2F;github.com&#x2F;facebook&#x2F;zstd&#x2F;blob&#x2F;v1.5.7&#x2F;lib&#x2F;compress&#x2F;zstd_ldm.c#L20" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;facebook&#x2F;zstd&#x2F;blob&#x2F;v1.5.7&#x2F;lib&#x2F;compress&#x2F;zs...</a><p>(I am one of the maintainers of Zstd.)
    • nerpderp826 hours ago
      That is fascinating. I wonder if you could layer a Levenshtein State Machine on the strings so you can apply n-edits to the text to get longer matches.<p>I absolutely adore ZSTD, it has worked so well for me compressing json metadata for a knowledge engine.
      • felixhandte5 hours ago
        Zstd has a similar-ish capability called &quot;repetition codes&quot; [0].<p>The first stage of Zstd does LZ77 matching, which transforms the input into &quot;sequences&quot;, a series of instructions each of which describes some literals and one match. The literals component of the instruction says &quot;the next L bytes of the message are these L bytes&quot;. The match component says &quot;the next M bytes of the input are the M bytes N bytes ago&quot;.<p>If you want to construct a match between two strings that differ by one character, rather than saying &quot;the next N bytes are the N bytes M bytes ago except for this one byte here which is X instead&quot;, Zstd just breaks it up into two sequences, the first part of the match, and then a single literal byte describing the changed byte, and then the rest of the match, which is described as being at offset 0. The encoding rules for Zstd define offset 0 to mean &quot;the previously used match offset&quot;. This isn&#x27;t as powerful as a Levenshtein edit, but it&#x27;s a reasonable approximation.<p>The big advantage of this approach is that it doesn&#x27;t require much additional machinery on the encoder or decoder, and thus remains very fast. Whereas implementing a whole edit description state machine would (I think) slow down decompression and especially compression enormously.<p>[0] <a href="https:&#x2F;&#x2F;datatracker.ietf.org&#x2F;doc&#x2F;html&#x2F;rfc8878#name-repeat-offsets" rel="nofollow">https:&#x2F;&#x2F;datatracker.ietf.org&#x2F;doc&#x2F;html&#x2F;rfc8878#name-repeat-of...</a>
  • mfld11 hours ago
    <p><pre><code> Using larger-than-default window sizes has the drawback of requiring that the same --long=xx argument be passed during decompression reducing compatibility somewhat. </code></pre> Interesting. Any idea why this can&#x27;t be stored in the metadata of the compressed file?
    • lifthrasiir11 hours ago
      It <i>is</i> 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.<p>[1] <a href="https:&#x2F;&#x2F;datatracker.ietf.org&#x2F;doc&#x2F;html&#x2F;rfc8878#name-window-descriptor" rel="nofollow">https:&#x2F;&#x2F;datatracker.ietf.org&#x2F;doc&#x2F;html&#x2F;rfc8878#name-window-de...</a>
      • mfld7 hours ago
        Thanks! So the --long essentially signals the decoder &quot;I am willing to accept the potentially large memory requirements implied by the given window size&quot;
      • pbronez10 hours 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.
        • chronogram6 hours ago
          For internal use like that you can also use the library feature. The downside of using long=31 is increased memory usage, which might not be desirable for customer facing applications like Steam.
    • nolist_policy11 hours ago
      It uses more memory (up to +2gb) during decompression as well -&gt; potential DoS.
      • Aachen11 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)<p>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&#x27;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
        • dzaima9 hours ago
          The decompressed output needn&#x27;t be in-memory (or even on-disk; it could be directly streamed to analysis) all at the same time, at which point resource limits aren&#x27;t a problem at all. And I believe --long already is a &quot;grater than or equal to&quot; value, and should also be effectively a memory limit (or pretty close to one at least).<p>Seeking back in the input might theoretically work, but I feel like that could easily get very bad (aka exponential runtime); never mind needing actual seeking.
  • ashvardanian11 hours ago
    Nice observation!<p>Took me a while to realize that Grace Blackwell refers to a person and not an Nvidia chip :)<p>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&#x2F;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 :(
    • jltsiren10 hours 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&#x27;t have the time and the money to make it actually happen.
      • vintermann8 hours ago
        Also for historical reasons I think, since Perl used to be the big bioinformatics language, and it is surprisingly hard to compete with in string handling.
        • lazide8 hours ago
          Perl+strings really is one of those ‘unreasonably effective’ combinations.<p>It feels like Benzene in some ways. Use it correctly and gdamn. Just don’t huff it - i mean - use it for your enterprise backend - and it’s worth it.
    • bede9 hours 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 <i>interchange</i> format FASTA seems quite sticky. I find the pervasiveness of fastq.gz particularly unfortunate with Gzip being as slow as it is.<p>&gt; Took me a while to realize that Grace Blackwell refers to a person and not an Nvidia chip :)<p>I even confused myself about this while writing :-)
      • chrchang5233 hours ago
        Note that BGZF solves gzip’s speed problem (libdeflate + parallel compression&#x2F;decompression) without breaking compatibility, and usually the hit to compression ratio is tolerable.
  • Aachen11 hours ago
    I&#x27;ve also noticed this. Zstandard doesn&#x27;t see very common patterns<p>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&#x27;s a gap in your data), in the article it&#x27;s a fixed value every 60 bytes<p>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 &quot;does it make sense to store the difference instead of the absolute value for some of these bytes here&quot;. Seeing as the difference is 0 between every 60th byte in the submitted article, that should fix both our issues<p>Bzip2 performed much better for me but it&#x27;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&#x27;ve moved to Zstandard at the standard thing to use
    • pajko11 hours ago
      Bzip2 performs exactly better because it rearranges the input to achieve better pattern matches: <a href="https:&#x2F;&#x2F;en.m.wikipedia.org&#x2F;wiki&#x2F;Burrows%E2%80%93Wheeler_transform" rel="nofollow">https:&#x2F;&#x2F;en.m.wikipedia.org&#x2F;wiki&#x2F;Burrows%E2%80%93Wheeler_tran...</a>
  • keketi8 hours ago
    When you know you&#x27;re going to be compressing files of particular structure, it&#x27;s often very beneficial to tweak compression algorithm parameters. In one case when dealing with CSV data, I was able to find a LZMA2 compression level, dictionary size and compression mode that yielded a massive speedup, uses 1&#x2F;100th the memory and surprisingly even yields better compression ratios, probably from the smaller dictionary size. That&#x27;s in comparison to the library&#x27;s default settings.
  • leobuskin12 hours ago
    What about a specialized dict for FASTA? Shouldn&#x27;t it increase ZSTD compression significantly?
    • bede11 hours ago
      Yes I&#x27;d expect a dict-based approach to do better here. That&#x27;s probably how it should be done. But --long is compelling for me because using it requires almost no effort, it&#x27;s still very fast, and yet it can dramatically improve compression ratio.
      • tecleandor9 hours ago
        From what I&#x27;ve read (although I haven&#x27;t tested and I can&#x27;t find my source from when I read it), dictionaries aren&#x27;t very useful when dataset is big, and just by using &#x27;--long&#x27; you can cover that improvement.<p>Have any of you tested it?
        • leobuskin8 hours ago
          I don’t think the size of content matters, it’s all about patterns (and their repetitiveness) within, and FASTA is a great target, if I understand the format correctly
          • privatelypublic7 hours ago
            I tried building a zstd dictionary for something(compressing many instances of the same Mono(.net) binary serialized class, mostly identical), and in this case it provided no real advantage. Honestly, I didn&#x27;t dig into it too much, but will give --long a try shortly.<p>PS: what the author implicitly suggests cannot be replaced with zstd tweaks. It&#x27;ll be interesting to look at the file in imhex- especially if I can find an existing Pattern File.
  • pkilgore4 hours ago
    To me the most interesting thing here isn&#x27;t that you can compress something better by removing randomly-distributed semantically-meaningless information. It&#x27;s why zstd --long does so much better than gzip when you do and the default does worse than gzip.<p>What lessons can we take from this?
    • cogman102 hours ago
      Why it does worse than gzip isn&#x27;t something that I know. Why --long is so efficient is likely a result of evolution of all things :). A lot of things have common ancestors which means shared genetic patterns across species. --long allows zstd to see a 2gb window of data which means it&#x27;s likely finding all those genetic similarities across species.<p>Endogenous retroviruses [1] are interesting bits of genetics that helps link together related species. A virus will inject a bit of it&#x27;s genetics into the host which can effectively permanently scar the host&#x27;s DNA and all their offspring&#x27;s DNA.<p>[1] <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Endogenous_retrovirus" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Endogenous_retrovirus</a>
  • semiinfinitely11 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.
    • boothby7 hours ago
      Spend a few years handling data in arcane, one-off, and proprietary file formats conceived by &quot;brilliant&quot; programmers with strong CS backgrounds and you might reconsider the conclusion you&#x27;ve come to here.
    • semiinfinitely11 hours ago
      other file formats that rival fasta in stupidity include fastq pdb bed sam cram vcf. further reading [1]<p>&gt; &quot;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&quot;<p>1. <a href="https:&#x2F;&#x2F;madhadron.com&#x2F;science&#x2F;farewell_to_bioinformatics.html" rel="nofollow">https:&#x2F;&#x2F;madhadron.com&#x2F;science&#x2F;farewell_to_bioinformatics.htm...</a>
      • jakobnissen10 hours ago
        SAM is not a bad file format. What&#x27;s bad about SAM?
        • optionalsquid8 hours ago
          I don&#x27;t dislike the format, and it is much, much better than what it replaced, but SAM, and its binary sister-format BAM, does have some flaws:<p>- The original index format could not handle large chromosomes, so now there are two index formats: .bai and .csi<p>- For BAM, the CIGAR (alignment description) operation count is limited to 16 bits, which means that very long alignments cannot be represented. One workaround I&#x27;ve seen (but thankfully not used) is saving the CIGAR as a string in a tag<p>- SAM cannot unambiguously represent sequences with only a single base (e.g. after trimming), since a &#x27;*&#x27; in the quality column can be interpreted either as a single Phred score (9) or as a special value meaning &quot;no qualities&quot;. BAM can represent such sequences unambiguously, but most tools output SAM
          • jakobnissen4 hours ago
            True. I&#x27;d consider these minor flaws. W.r.t. the CIGAR, the spec says you do need to store it as a tag.
    • totalperspectiv8 hours ago
      &gt; a testament to the massive gap in perceived vs actual programming ability of the average bioinformatician.<p>This is not really a fair statement. Literally all of software bears the weight of some early poor choice that then keeps moving forward via weight of momentum. FASTA and FASTQ formats are exceptionally dumb though.
    • Fraterkes11 hours ago
      I’ll do you the immense favor of taking the bait. What’s so bad about it?
      • jszymborski9 hours ago
        It&#x27;s a fine format for what it is.<p>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.<p>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.<p>People forget FASTA was from 1985, and it sticks around because (1) it&#x27;s easy to parse and write (2) we have mountains of sequences in that format going back 4 decades.<p>[O] <a href="https:&#x2F;&#x2F;gist.github.com&#x2F;jszym&#x2F;9860a2671dabb45424f2673a49e4b582" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;jszym&#x2F;9860a2671dabb45424f2673a49e4b5...</a><p>[1] <a href="https:&#x2F;&#x2F;seqan.readthedocs.io&#x2F;en&#x2F;main&#x2F;Tutorial&#x2F;InputOutput&#x2F;IndexedFastaIO.html" rel="nofollow">https:&#x2F;&#x2F;seqan.readthedocs.io&#x2F;en&#x2F;main&#x2F;Tutorial&#x2F;InputOutput&#x2F;In...</a>
    • StillBored5 hours ago
      I think the prevalence of the format vs something more widely used should be part of that metric.<p>On those grounds, the lack of pre-tokenization in html&#x2F;css&#x2F;js ranks at this point as a planet killing level of poor choices.
    • fwip7 hours ago
      It might be the stupidest, but stupid in the sense of &quot;the simplest thing that could possibly work.&quot;<p>When FASTA was invented, Sanger sequencing reads would be around a thousand bases in length. Even back then, disk space wasn&#x27;t so precious that you couldn&#x27;t spend several kilobytes on the results of your experiment. Plus, being able to view your results with `more` is a useful feature when you&#x27;re working with data of that size.<p>And, despite its simplicity, it has worked for forty years.
      • michaelhoffman6 hours ago
        When FASTA was invented in 1985, generally sequencing reads would be about half that.<p>The simplicity of FASTA seems like a dream compared to the GenBank flat file format used before then. And around the year 2000, less computationally-inclined scientists were storing sequence in Microsoft Word binary .doc files.<p>A lot of file formats (including bioinformatics formats!) have come and gone in that time period. I don&#x27;t think many would design it this way today, but it has a lot of nice features like the ones you point out that led to its longevity.
      • attractivechaos6 hours ago
        FASTA was invented in late 1980s. At that time, unix tools often limited line length. Even in early 2000s, some unix tools (on AIX as I remember) still had this limit.
  • totalperspectiv8 hours ago
    Removing the wrapping newline from the FASTA&#x2F;FASTQ convention also dramatically improves parsing perf when you don&#x27;t have to do as much lookahead to find record ends.
    • Gethsemane8 hours ago
      Unfortunately, when you write a program that doesn&#x27;t wrap output FASTAs, you have a bunch of people telling you off because SOME programs (cough bioperl cough) have hard limits on line length :)
      • o11c3 hours ago
        You can use content-defined chunking to wrap at a predictable place so that compression still works.
    • bede7 hours ago
      Thanks for reminding me to benchmark this!
      • totalperspectiv7 hours ago
        I&#x27;ve only tested this when writing my own parser where I could skip the record end checks, so idk if this improves perf on a existing parser. Excited to see what you find!
  • IshKebab11 hours ago
    Damn surely you stop using ASCII formats before your dataset gets to 2 TB??
    • rurban8 hours ago
      Ha. it gets worse. Search engines or blacklist processors often use gigantic url lists, which are stored as plain ASCII, which is then fed into a perfect hash generator, which accesses those url&#x27;s unordered. I.e. they need to create a second ordering index to access the urllist. The perfect hashing guys are mathematicians and so they don&#x27;t care because their definition of a mphf (minimal perfect hash function) is just a random ordering of unique indices, but they don&#x27;t care to store the ordering also. So we have ASCII and no index.
    • bede10 hours 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&#x27;s fair to say that none of the simpler binary equivalents to FASTA and FASTQ have caught on yet (XKCD competing standards etc.)<p>e.g. <a href="https:&#x2F;&#x2F;github.com&#x2F;ArcInstitute&#x2F;binseq" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ArcInstitute&#x2F;binseq</a>
    • hhh10 hours ago
      no, I power thru indefinitely with no recourse
    • amelius9 hours ago
      People rely on compression for that ;)
  • dekhn7 hours ago
    I&#x27;ve explored alternatives to FASTA and FASTQ but in most cases I found that simply not storing sequence data is the best option of all, but if I have to do it, columnar formats with compression are usually the best alternative when considering all of (my) the constraints.
  • FL33TW00D10 hours ago
    Looking forward to the relegation of FASTQ and FASTA to the depths of hell where they belong. Incredibly inefficient and poorly designed formats.
    • jefftk9 hours ago
      How so? As long as you remove the hard wrapping and use compression aren&#x27;t they in the same range as other options?<p>(I currently store a lot of data as FASTQ, and smaller file sizes could save us a bunch of money. But FASTQ + zstd is very good.)
      • FL33TW00D5 hours ago
        <a href="https:&#x2F;&#x2F;www.biorxiv.org&#x2F;content&#x2F;10.1101&#x2F;2025.04.08.647863v1.full.pdf" rel="nofollow">https:&#x2F;&#x2F;www.biorxiv.org&#x2F;content&#x2F;10.1101&#x2F;2025.04.08.647863v1....</a>
        • optionalsquid24 minutes ago
          The fact that these formats are unable to represent degenerate bases (Ns in particular, but also the remaining IUPAC bases), in my experience renders them unusable for many, if not most, use-cases, including for the storage of FASTQ data
      • fwip7 hours ago
        There&#x27;s a few options out there that have noticeably better compression, with the downside of being less widely-compatible with tools. zstd also has the benefit of being very fast (depending on your settings, of course).<p>CRAM compresses unmapped fastq pretty well, and can do even better with reference-based compression. If your institution is okay with it, you can see additional savings by quantizing quality scores (modern Illumina sequencers already do this for you). If you&#x27;re aligning your data anyways, probably retaining just the compressed CRAM file with unmapped reads included is your best bet.<p>There are also other fasta&#x2F;fastq specific tools like fqzcomp or MZPAQ. Last I checked, both of these could about halve the size of our fastq.gz files.
  • meel-hd5 hours ago
    <a href="https:&#x2F;&#x2F;github.com&#x2F;meel-hd&#x2F;DNA" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;meel-hd&#x2F;DNA</a>
  • rini173 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.
    • vintermann12 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.
    • bede2 days ago
      Yes, it sounds like 7-Zip&#x2F;LZMA can do this using custom filters, among other more exotic (and slow) statistical compression approaches.
  • nickdothutton8 hours ago
    How can we represent data or algos such that such optimisations before more obvious?
  • lutusp8 hours ago
    &gt; I speculated that this poor performance might be caused by the newline bytes (0x0A) punctuating every 60 characters of sequence, breaking the hashes used for long range pattern matching.<p>If the linefeeds were treated as semantic characters and not allowed to break the hash size, you would get similar results without pre-filtering and post-filtering. It occurs to me that this strategy is so obvious that there must be some reason it won&#x27;t work.
  • diimdeep8 hours ago
    What&#x27;s current way to accessibly process my 23andme raw data ? It&#x27;s been synthesized decade ago and SNPedia and Promethease seems abandoned, so what&#x27;s alternative if there is, and if there is none how we arrived to this?
    • iijj1 hour ago
      I was no longer on the scene when it happened, but I’ve been told it became very difficult to get ongoing funding from the National Science Foundation for bioinformatics software around 10 years ago. You could get an initial grant to develop something, but ongoing support was difficult. So websites and ‘databases’ (curated datasets) that made it easy to run the tools faded away.
  • im3w1l9 hours ago
    As someone with an idle interest in data compression, ss it possible to download the original dataset somewhere to play around with? Or rather a like 20gb subset of it.
    • fwip1 hour ago
      The article links to the dataset here: <a href="https:&#x2F;&#x2F;ftp.ebi.ac.uk&#x2F;pub&#x2F;databases&#x2F;ENA2018-bacteria-661k&#x2F;" rel="nofollow">https:&#x2F;&#x2F;ftp.ebi.ac.uk&#x2F;pub&#x2F;databases&#x2F;ENA2018-bacteria-661k&#x2F;</a>
      • im3w1l36 minutes ago
        Ahh, I didn&#x27;t notice that there were two adjacent links. I must have clicked the first one and gotten the article rather than the ftp.
  • Kim_Bruning12 hours ago
    Now I&#x27;m wondering <i>why</i> this works. DNA clearly has some interesting redundancy strategies. (it might also depend on genome?)
    • dwattttt12 hours ago
      The FASTA format stores nucleotides in text form... compression is used to make this tractable at genome sizes, but it&#x27;s by no means perfect.<p>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.<p>Compression on top of that &quot;should&quot; result in the same compressed size as the original text (after all, the &quot;information&quot; being compressed is the same), except that compression isn&#x27;t perfect.<p>Newlines are an example of something that&#x27;s &quot;information&quot; in the text format that isn&#x27;t relevant, yet the compression scheme didn&#x27;t know that.
      • hyghjiyhu12 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.
        • dwattttt9 hours ago
          I was actually under the impression compression algorithms tend to work over a bitstream, but I can&#x27;t entirely confirm that.
          • Sesse__7 hours ago
            Some are bit-by-bit (e.g. the PPM family of compressors[1]), but the normal input granularity for most compressors is a byte. (There are even specialized ones that work on e.g. 32 bits at a time.)<p>[1] Many of the context models in a typical PPM compressor will be byte-by-byte, so even that isn&#x27;t fully clear-cut.
          • vintermann8 hours ago
            They output a bitstream, yeah but I don&#x27;t know of anything general purpose which effectively consumes anything smaller than bytes (unless you count various specialized handlers in general-purpose compression algorithms, e.g. to deal with long lists of floats)
    • vintermann12 hours ago
      This is a dataset of bacterial DNA. Any two related bacteria will have long strings of the same letters. But it won&#x27;t be neatly aligned, so the line breaks will mess up pattern matching.
      • bede11 hours ago
        Exactly. The line breaks <i>break</i> 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.
      • amelius9 hours ago
        And the compressor does not think: &quot;how can I make these two sequences align better without wasting a lot of space?&quot;
        • ebolyen5 hours ago
          No, because alignment, in the general case, is O(n^2). It is ironically one of the more tractable and well solved problems in bioinformatics.
        • tiagod5 hours ago
          The compressor doesn&#x27;t think about anything. Also, Zstd doesn&#x27;t have the goal of reaching the highest possible compression ratio. It&#x27;s more geared toward lowest overhead, high bandwidth compress&#x2F;decompress.