Seqstr

seq·string

A short string for a long genomic sequence

Seqstr compiles genome intervals, raw bases and variants into sequences of any length — so a 32 Mb input to a model can travel as one line of text. It is a format specification with a reference Python implementation and a test suite.

[hg38]chr7:5530575-5530625 -, @chr7 5530575 C T;TTAAccggGGNaa;[hg38]chrX:1000000-1000017 +

Format

Genomic interval

One interval is [genome]chr:start-end strand.

[hg38]chr7:5530575-5530625 -

Compose subsequences

Join subsequences with ;. Each is an interval or a run of raw bases, concatenated in the order written. Raw bases pass through untouched, including lower case and N.

[hg38]chr7:5530575-5530625 -;TTAAccggGGNaa;[hg38]chrX:1000000-1000017 +;TTAA;

Sequence modifiers

Edit an interval with , @chr position reference alternative. Positions are in the original + strand reference coordinates, whatever the interval's strand; several modifiers may follow one interval, separated by ,, and may change its length. Overlapping modifiers are not allowed.

[hg38]chr7:5530575-5530625 -, @chr7 5530575 C T, @chr7 5530576 GC A
[hg38]chr7:5480600-5480620 +, @chr7 5480600 TT T, @chr7 5480619 A ATa deletion and an insertion

Multiple sequences

One sequence per line. A leading <name> names it; unnamed sequences are numbered from 0.

<wildtype>[hg38]chr7:5480600-5580600 -
<mutant>[hg38]chr7:5480600-5580600 -, @chr7 5530626 TATA GCGC
the Puffin-D example: a 100 kb promoter region, and the same with its TATA box replaced

Symbols

[ ]reference assembly (UCSC name);next subsequence
:chromosome | coordinates,next modifier
-start–end, or reverse strand@modifier: chr position ref alt
+forward strand< >sequence name
⏎next sequence

Try it

Resolved on the lab server against local copies of 56 UCSC assemblies, hg38, hg19 and mm10 among them; any other assembly name is fetched from the UCSC API. Long outputs are summarised here — download the FASTA for the full sequence. ⌘/Ctrl+Enter resolves.

Assemblies available locally

Python

pip install git+https://github.com/jzhoulab/Seqstr.git

from seqstr import seqstr
for item in seqstr("<s1>[hg38]chr7:5480600-5480620 -\n<s2>[hg38]chr7:44746680-44746700 +"):
    item.Name, item.Seq, item.errormsg

The API returns an ordered list of SeqOutput(Name, Seq, errormsg). The CLI, seqstr input.txt, writes FASTA; --download hg38 fetches an assembly for local resolution, and without local files it queries the UCSC API. A test suite in the repository verifies any implementation of the specification.

Used by