# TextFormats parser generator

**URL:** https://discourse.julialang.org/t/textformats-parser-generator/95505
**Category:** Biology, Health, and Medicine
**Created:** [March 3, 2023, 3:29pm UTC](https://discourse.julialang.org/t/textformats-parser-generator/95505 "2023-03-03T15:29:00Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![tp2750](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tp2750/32/207806_2.png) [@tp2750](https://discourse.julialang.org/u/tp2750)
#### Post date: [March 3, 2023, 3:29pm UTC](https://discourse.julialang.org/t/textformats-parser-generator/95505/1 "2023-03-03T15:29:00Z")

</div>

Came across this library: [GitHub - ggonnella/textformats](https://github.com/ggonnella/textformats) and paper: [TextFormats: Simplifying the definition and parsing of text formats in bioinformatics](https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0268910)

They define a way to describe a text-based file format (like FASTA, SAM) in YAML / JSON and generate readers, writers and validators based on that specification.

This is done in nim with bindings to C, C++, and python. Do we have anything similar in Julia?

---

<div class="post-metadata">

### Author: ![kevbonham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevbonham/32/216165_2.png) [@kevbonham](https://discourse.julialang.org/u/kevbonham)
#### Post date: [March 3, 2023, 11:15pm UTC](https://discourse.julialang.org/t/textformats-parser-generator/95505/2 "2023-03-03T23:15:42Z")

</div>

Not that I’m aware of - most of the parsers in BioJulia use [Automa.jl](https://github.com/BioJulia/Automa.jl), which generates state machines from regular expressions.

---

<div class="post-metadata">

### Author: ![jar1](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jar1](https://discourse.julialang.org/u/jar1)
#### Post date: [March 3, 2023, 11:20pm UTC](https://discourse.julialang.org/t/textformats-parser-generator/95505/3 "2023-03-03T23:20:21Z")

</div>

cc @jakobnissen

---

<div class="post-metadata">

### Author: ![jakobnissen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jakobnissen/32/13477_2.png) [@jakobnissen](https://discourse.julialang.org/u/jakobnissen)
#### Post date: [March 5, 2023, 8:13am UTC](https://discourse.julialang.org/t/textformats-parser-generator/95505/4 "2023-03-05T08:13:30Z")

</div>

I don’t know of any Julia package that does this. But I’m also skeptical it will bring any value:

- If the advantage is to automatically generate parsers from higher-level descriptions, then we have ParserCombinator.jl (which I haven’t tried) for nested formats and Automa.jl for flat formats.
- If the advantage is that we could simply use format descriptions intended for other programming languages without needing to modify them, then I doubt that the bespoke format mentioned in that article, as opposed to, say Bakcus-Naur form, would be more widespread.

---

<div class="post-metadata">

### Author: ![tp2750](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tp2750/32/207806_2.png) [@tp2750](https://discourse.julialang.org/u/tp2750)
#### Post date: [March 5, 2023, 8:31am UTC](https://discourse.julialang.org/t/textformats-parser-generator/95505/5 "2023-03-05T08:31:40Z")

</div>

Thank you for your comments @jakobnissen

I think there is value in a library of specifications of bio-data-formats in a form that can be used directly to generate parsers. The format they propose does not look terrible (to me), but the library is quite limited at this point. If it can grow to something like Kaitai it would be cool: [https://formats.kaitai.io/](https://formats.kaitai.io/).

---

<div class="post-metadata">

### Author: ![jar1](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jar1](https://discourse.julialang.org/u/jar1)
#### Post date: [March 5, 2023, 9:31am UTC](https://discourse.julialang.org/t/textformats-parser-generator/95505/6 "2023-03-05T09:31:47Z")

</div>

See also

> [@\[ANN\] PikaParser.jl -- small and fast parser library](https://discourse.julialang.org/t/ann-pikaparser-jl-small-and-fast-parser-library/93700):
>
> It has been around half a year since we released the first version of [PikaParser.jl](https://github.com/LCSB-BioCore/PikaParser.jl), and we’re at 0.5.1 today successfully using it for several local projects[\*](https://github.com/LCSB-BioCore/COBREXA.jl/blob/ac27ca5bcd66b177078320c220620de15fa6e5b9/src/base/utils/gene_associations.jl#L63-L165). So I thought it’s about time to announce it more formally. What is it about? Parsing of structured input from users and other programs is traditionally one of the most complicated, error-prone, fragile and otherwise annoying components of any software, and we witnessed too many bugs and security problems that stem from completely insuf…
