Skip to main content

Coralsnake

Pypi Releases Downloads

coralsnake logo

Coralsnake is a transcriptome mapping toolkit. In addition to the two-color mapping workflow (prepare, map, liftover, annot, group), it now bundles the full metagene profiling analysis and a sequence-logo plotter as first-class subcommands.

Installation

pip install coralsnake

Optional support for the visualization commands (metagene profile plot and sequence logo) requires the lightweight plot extra, which only pulls in matplotlib when you need it:

pip install "coralsnake[plot]"

Commands

Route Command Description
t -> g liftover / tbam2gbam Remap transcriptome-aligned reads to genome coordinates.
g -> t gbam2tbam Remap genome-aligned reads back to transcript coordinates.

Read mapping (both directions)

prepare builds a transcript reference; map aligns reads to it. The two BAM-conversion commands round-trip between transcript and genome span:

  • coralsnake tbam2gbam (alias: liftover) – transcript BAM → genome BAM (splices reads at exon boundaries, inserts introns).
  • coralsnake gbam2tbam – genome BAM → transcript BAM (clips to exons, joins spliced reads contiguously on the transcript).

Command reference

Command Description
prepare Extract primary transcript from a GTF/GFF file.
map Map reads to a reference genome using BWA-MEM (two-color aware).
liftover / tbam2gbam Remap transcriptome-aligned reads to genome coords.
gbam2tbam Remap genome-aligned reads back to transcript coordinates.
annotate Unified site/variant annotation (region + gene/transcript/effect).
annot Site labeling (legacy; use annotate --annotation).
effect Variant effect (legacy; use annotate with GTF+FASTA).
group Group genes and build a consensus sequence.
metagene Metagene profiling: distribution of sites across 5'UTR/CDS/3'UTR.
logo Plot a DNA/RNA sequence logo (requires coralsnake[plot]).
variant Variant utilities (motif, coordinate).

annotate is the single annotation tool (merged annot + effect). One command, one schema. Two input modes share one engine:

  • --reference-gtf [--reference-transcript FASTA] – region + gene/transcript/ position + (with ref/alt + FASTA) the full variant effect.
  • --annotation <prepare-table> – fast precomputed-table site labeling.

Metagene subcommand

coralsnake metagene is a full migration of the metagene package, built on the high-performance polars + ruranges stack. It computes the distribution of genomic sites relative to gene regions (5'UTR, CDS, 3'UTR) and can emit binned statistics and a publication-ready profile plot.

# Using a built-in reference (GRCh38) or a custom GTF:
coralsnake metagene -i sites.tsv.gz -r GRCh38 -H -m 1,2,3 -w 5 \
                    -o output.tsv -s scores.tsv -p plot.png

coralsnake metagene -i sites.bed -g custom.gtf.gz -m 1,2,3 -w 5 \
                    -o output.tsv -s scores.tsv -p plot.png

List or download the built-in references:

coralsnake metagene --list
coralsnake metagene --download GRCh38

Python API

The metagene functions are also importable directly from the flat modules:

from coralsnake.io import load_sites, load_reference
from coralsnake.gtf import load_gtf
from coralsnake.annotation import map_to_transcripts, normalize_positions
from coralsnake.map_to_local import map_to_local
from coralsnake.plotting import plot_profile

sites = load_sites("sites.tsv.gz", with_header=True, meta_col_index=[0, 1, 2])
ref = load_reference("GRCh38")   # or load_gtf("custom.gtf.gz")
annotated = map_to_transcripts(sites, ref)
gene_bins, gene_stats, gene_splits = normalize_positions(
    annotated, split_strategy="median", bin_number=100
)
plot_profile(gene_bins, gene_splits, "metagene_plot.png")

# Map global coordinates to local transcript coordinates (strand-aware):
local = map_to_local(sites, ref, ref_id_col="transcript_id")

Performance

The metagene core is built on the vectorized polars + ruranges stack, and uses Rust-backed ruranges primitives instead of slow per-group Python applies:

  • map_to_transcripts picks the best transcript per gene with a vectorized sort + group_by().first() (was group_by().map_groups() python apply) — ~20× faster on realistic inputs.
  • map_to_local uses ruranges.numpy.group_cumsum for strand-aware cumulative transcript offsets (was a hand-rolled map_groups apply) — ~7× faster.
  • Mlogo (sequence logo) builds its score matrix with vectorized numpy (bincount + codepoint lookup) — ~1.5× faster and fixes a 0·log2(0) NaN edge case.

Logo subcommand

coralsnake logo plots a DNA/RNA sequence logo from a set of motif sequences. The scoring engine is pure numpy; the renderer needs matplotlib (plot extra).

coralsnake logo -m ACGT -m ACGG -m CCGT -o logo.png
# or with per-motif weights from a file (seq\tcount)
coralsnake logo -i motifs.tsv -o logo.svg
from coralsnake import Mlogo

m = Mlogo(motifs=["ACGT", "ACGG", "CCGT"], to2bit=True)
m.plot(ax)  # requires matplotlib (plot extra)

Variant analysis

The motif, coordinate and effect commands are a migration of the standalone variant package — fused into the top-level CLI with the old pyfaidx / urllib3 / pyensembl+varcode dependencies removed and coralsnake's pysam + ruranges stack used instead. Naming and output format are unchanged.

# Motif fetch (strand-aware, padded with N)
coralsnake motif -i sites.tsv -o motifs.tsv -f genome.fa -n 2,3 -w

# Chromosome-name mapping (UCSC ↔ Ensembl)
coralsnake coordinate -i sites.tsv -o mapped.tsv -M U2E

# Variant effect annotation (pure Python classifier on coralsnake GTF)
coralsnake effect -i variants.tsv -o effects.tsv \
                  --reference-gtf annotation.gtf \
                  --reference-transcript transcripts.fa -s -a
from coralsnake.effect import Annot, Site, reverse_base
from coralsnake.motif import get_motif
from coralsnake.coordinate import run_coordinate
from coralsnake.effect import run_effect

Documentation

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

coralsnake-0.0.216.tar.gz (104.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

coralsnake-0.0.216-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (98.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

coralsnake-0.0.216-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (98.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

File details

Details for the file coralsnake-0.0.216.tar.gz.

File metadata

  • Download URL: coralsnake-0.0.216.tar.gz
  • Upload date:
  • Size: 104.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for coralsnake-0.0.216.tar.gz
Algorithm Hash digest
SHA256 833886bc44b2ba44b69695a0248c7002c851e6961e287a89b0de1c5d73c31523
MD5 7ad8bce894fe5d922cbc8d24b3ccd395
BLAKE2b-256 70eb861ae554f64eddd6f206c64f5047b28f05de5a970f62cdb61d6a7abf6d6f

See more details on using hashes here.

File details

Details for the file coralsnake-0.0.216-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for coralsnake-0.0.216-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9a1ab65620fef8e27621f2614fc2c284019e399f408d6f83d34412b0ca87e570
MD5 01afc4347662416a2d2badd268e28155
BLAKE2b-256 5edc81d750be1ca1b0e942c42739be153e49dc5e536d1e9919cb9c07fb820b1a

See more details on using hashes here.

File details

Details for the file coralsnake-0.0.216-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for coralsnake-0.0.216-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cdd4e92b0c96650652fa360d675f4bb0c8102434c634dc82425effbdb2850ba5
MD5 0e577be5dc271e7994b8d75cd2e532d3
BLAKE2b-256 f655dbb1dc16a1b2d38ff6d4a18bc452e103a22a818c5ec920887f4f85ac45de

See more details on using hashes here.

Release history Release notifications | RSS feed

0.2.2

3 files

0.2.1

3 files

0.2.0

3 files

0.1.1

3 files

0.0.222

3 files

0.0.221

3 files

0.0.220

3 files

0.0.219

3 files

0.0.218

3 files

0.0.217

3 files

This release

0.0.216 This release

3 files

0.0.215

3 files

0.0.214

3 files

0.0.213

3 files

0.0.210

3 files

0.0.209

3 files

0.0.208

3 files

0.0.207

3 files

0.0.206

3 files

0.0.205

3 files

0.0.203

3 files

0.0.202

3 files

0.0.201

3 files

0.0.200

3 files

0.0.198

3 files

0.0.197

3 files

0.0.196

3 files

0.0.195

3 files

0.0.193

3 files

0.0.191

3 files

0.0.190

3 files

0.0.189

3 files

0.0.188

3 files

0.0.187

3 files

0.0.186

3 files

0.0.185

3 files

0.0.184

3 files

0.0.183

3 files

0.0.182

7 files

0.0.181

7 files

0.0.180

7 files

0.0.179

7 files

0.0.178

7 files

0.0.177

7 files

0.0.176

7 files

0.0.175

7 files

0.0.174

7 files

0.0.173

7 files

0.0.172

7 files

0.0.171

7 files

0.0.170

7 files

0.0.169

7 files

0.0.168

7 files

0.0.167

7 files

0.0.166

7 files

0.0.165

7 files

0.0.164

7 files

0.0.163

7 files

0.0.162

7 files

0.0.161

7 files

0.0.160

7 files

0.0.159

7 files

0.0.158

7 files

0.0.157

7 files

0.0.156

7 files

0.0.155

7 files

0.0.154

7 files

0.0.153

7 files

0.0.152

7 files

0.0.151

7 files

0.0.150

7 files

0.0.149

7 files

0.0.147

7 files

0.0.146

7 files

0.0.145

7 files

0.0.141

7 files

0.0.140

7 files

0.0.137

7 files

0.0.136

7 files

0.0.135

7 files

0.0.134

7 files

0.0.133

7 files

0.0.132

7 files

0.0.131

7 files

0.0.129

7 files

0.0.128

7 files

0.0.127

7 files

0.0.126

7 files

0.0.125

7 files

0.0.124

7 files

0.0.123

7 files

0.0.122

7 files

0.0.121

7 files

0.0.120

7 files

0.0.119

7 files

0.0.118

7 files

0.0.117

7 files

0.0.116

13 files

0.0.115

13 files

0.0.114

13 files

0.0.113

13 files

0.0.112

13 files

0.0.111

13 files

0.0.110

13 files

0.0.109

13 files

0.0.107

13 files

0.0.106

13 files

0.0.105

13 files

0.0.104

13 files

0.0.103

13 files

0.0.102

13 files

0.0.101

13 files

0.0.100

17 files

0.0.98

2 files

0.0.97

2 files

0.0.96

2 files

0.0.95

2 files

0.0.94

2 files

0.0.93

2 files

0.0.92

2 files

0.0.91

2 files

0.0.90

2 files

0.0.89

2 files

0.0.88

2 files

0.0.87

2 files

0.0.86

2 files

0.0.85

2 files

0.0.84

2 files

0.0.83

2 files

0.0.82

2 files

0.0.80

2 files

0.0.79

2 files

0.0.78

2 files

0.0.77

2 files

0.0.76

2 files

0.0.75

2 files

0.0.74

2 files

0.0.73

2 files

0.0.72

2 files

0.0.71

2 files

0.0.70

2 files

0.0.69

2 files

0.0.68

2 files

0.0.67

2 files

0.0.66

2 files

0.0.65

2 files

0.0.64

2 files

0.0.63

2 files

0.0.62

2 files

0.0.61

2 files

0.0.60

2 files

0.0.59

2 files

0.0.58

2 files

0.0.57

2 files

0.0.56

2 files

0.0.55

2 files

0.0.54

2 files

0.0.53

2 files

0.0.52

2 files

0.0.51

2 files

0.0.50

2 files

0.0.49

2 files

0.0.48

2 files

0.0.47

2 files

0.0.46

2 files

0.0.45

2 files

0.0.44

2 files

0.0.43

2 files

0.0.42

2 files

0.0.41

2 files

0.0.40

3 files

0.0.39

3 files

0.0.38

2 files

0.0.37

2 files

0.0.36

2 files

0.0.35

2 files

0.0.34

2 files

0.0.33

2 files

0.0.32

2 files

0.0.31

2 files

0.0.30

2 files

0.0.29

2 files

0.0.28

2 files

0.0.27

2 files

0.0.26

2 files

0.0.25

2 files

0.0.24

2 files

0.0.22

2 files

0.0.21

2 files

0.0.20

2 files

0.0.19

2 files

0.0.18

2 files

0.0.17

2 files

0.0.16

2 files

0.0.15

2 files

0.0.14

2 files

0.0.13

2 files

0.0.12

2 files

0.0.11

2 files

0.0.10

2 files

0.0.9

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

3 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page