Seq: a high-performance language for bioinformatics

Ariya Shajii, Ibrahim Numanagic, Riyadh Baghdadi, Bonnie Berger, Saman P. AmarasingheProc. ACM Program. Lang 2019 · DOI

TL;DR

Seq is a new programming language designed specifically for bioinformatics that combines Python's ease of use with C-like performance. It achieves significant speedups (up to 160x over Python and 2x over C++) by introducing domain-specific data types and optimizations, making high-performance bioinformatics software more accessible.

What Problem Does This Paper Address?

The explosion of biological data, driven by cheaper and faster DNA sequencing, has created a massive computational bottleneck. While sequencing costs have plummeted, the analysis of this data has become increasingly expensive and time-consuming. Traditional programming languages like Python, while easy to use, are too slow for these massive datasets. Conversely, high-performance languages like C++ are difficult for biologists, who are not typically software engineers, to master and optimize. This gap forces researchers to either buy expensive hardware or struggle with complex, hard-to-maintain codebases. The paper addresses the need for a language that offers both the productivity of Python and the performance required for modern bioinformatics.

Methods

The core innovation is Seq, a domain-specific language (DSL) for bioinformatics. Seq is designed as a statically-typed subset of Python, aiming to retain Python's familiar syntax and ease of use while enabling significant performance gains. Key methodological aspects include:

  • Pythonic Subset: Seq borrows heavily from Python's syntax and semantics, allowing existing Python code to run with minimal or no modification.
  • Static Typing: Unlike Python's dynamic typing, Seq enforces type checking at compile time. This eliminates runtime overhead associated with type information and allows for aggressive compiler optimizations.
  • Domain-Specific Data Types: Seq introduces specialized types for bioinformatics, such as seq for DNA sequences and Kmer[N] for fixed-length k-mers. These types are integrated with optimized operations (e.g., reverse complementation, k-merization).
  • Compiler Optimizations: Seq's compiler leverages LLVM for general-purpose optimizations and applies domain-specific optimizations like operator fusion and pipeline transformations.
  • Parallelism: Seq supports parallel execution through a parallel pipe operator (||>), enabling efficient use of multi-core processors.
  • Coroutines and Generators: Seq uses LLVM coroutines for efficient implementation of generators, crucial for stream processing of large datasets.
  • Prefetching: Seq incorporates explicit prefetching mechanisms to hide memory latency, particularly beneficial for large genomic index lookups.
  • Interoperability: Seq allows seamless integration with C/C++ code through cdef functions.

Datasets

The paper evaluates Seq on several benchmarks:

  • Computer Language Benchmarks Game (CLBG) suite: Specifically, the FASTA, RevComp, and k-nucleotide micro-benchmarks.
  • In-house Sequence Manipulation Suite: Three benchmarks designed to mimic common genomics operations:
  • RC: Reverse complementation of millions of short reads.
  • 16-mer: Counting symmetric 16-mers.
  • CpG: Counting CpG regions.
  • Genomic Index Queries: Benchmarks using genomic indices from widely-used tools SNAP and SGA.

The paper does not introduce new datasets but uses standard benchmarks and real-world genomics operations to evaluate Seq's performance.

Key Insights and Ideas

  • Python's Dynamism is a Performance Bottleneck: The paper clearly demonstrates that Python's dynamic nature, while great for rapid development, incurs significant runtime overhead that is prohibitive for large-scale bioinformatics.
  • Domain-Specific Languages (DSLs) are Crucial for Performance: By tailoring language features and optimizations to the specific needs of bioinformatics (e.g., sequence types, k-mer operations), Seq achieves performance levels far beyond general-purpose languages.
  • Static Typing Doesn't Have to Mean Loss of Productivity: Seq shows that a statically-typed language can still offer a Python-like development experience, especially when it intelligently infers types and provides domain-specific constructs.
  • Democratizing High-Performance Bioinformatics: Seq's primary goal is to make high-performance code accessible to biologists who may not be expert programmers. The significant speedups over C++ with simpler code are a testament to this.
  • The Power of Compiler Optimizations: Seq's compiler plays a vital role, performing optimizations like operator fusion and pipeline transformations that are difficult or impossible for users to achieve manually in other languages.

Key Results

  • Pythonic Seq: Achieves performance comparable to or better than C++ in many cases, and significantly outperforms standard Python (11x to 100x speedup).
  • Idiomatic Seq (with domain-specific features): Attains up to 160x performance improvement over standard Python.
  • Comparison to C++: Seq frequently achieves up to 2x improvement over optimized C++ code, with shorter and cleaner code.
  • Parallelism: With parallel pipelines, Seq demonstrates up to a 650x improvement over Python.
  • Prefetching: For genomic index queries, adding a single line for prefetching resulted in a 50% speedup and up to a 2x speedup over C++.

Limitations and Future Work

  • Limitations:
    • Seq's strongly-typed nature means it cannot create collections with varying types, unlike Python.
  • Seq's tuples are less versatile than Python's, with limitations on iteration and indexing for heterogeneous types.
  • Seq does not support runtime method or class monkey-patching (though it supports compile-time type extensions).
  • Seq does not support subtyping or full-fledged polymorphism.
  • Future Work: The authors suggest exploring a wider range of domain-specific optimizations that exploit the unique structure of biological data. They also mention that some features (like bi-directional type inference) are recent additions and still under development.

Summary updated

BibTeX
@article{shajii2019seq,
  author = {Ariya Shajii and Ibrahim Numanagic and Riyadh Baghdadi and Bonnie Berger and Saman P. Amarasinghe},
  title = {{Seq: a high-performance language for bioinformatics}},
  journal = {Proc. ACM Program. Lang.},
  year = {2019},
  doi = {10.1145/3360551},
}
Figure