Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

rev-comp

Reverse complement, transcription and multi-frame translation from the command line. Pure Python with no third-party dependencies, reading FASTA or a bare sequence and writing FASTA.

Install

Install the prerelease from PyPI:

python -m pip install --pre norvara-rev-comp

The Python package and command keep the shorter project name:

import revcomp
rev-comp --version

Quickstart

rev-comp translate --cds --input examples/phix174_geneJ.fasta
>NC_001422.1:848-964_f1 Escherichia phage phiX174 gene J, complete cds frame=+1 table=1
MSKGKKRSGARPGRPQPLRGTKGKRKGARLWYVGGQQF
rev-comp complement -i examples/phix174.fasta -o revcomp_phix174.fasta
rev-comp translate --frame all -t 11 -i examples/phix174_geneJ.fasta
rev-comp complement ATGGCCATTGTAATG        # or pipe a sequence on stdin

examples/phix174.fasta, shipped with the repository and the source distribution, is the complete phiX174 genome (RefSeq NC_001422.1); examples/phix174_geneJ.fasta is its annotated gene J, nucleotides 848..964.

Options

-i, --input PATH         FASTA or raw sequence to read (default: stdin)
-o, --output PATH        file to write (default: stdout)
-w, --line-width N       residues per output line; 0 for one line (default: 60)
    --name NAME          record name for a bare input sequence
    --permissive         replace characters outside the IUPAC alphabet with N
-q, --quiet              suppress warnings on standard error

complement - reverse complement, or complement or reverse alone
-m, --mode {revcomp,complement,reverse}
    --rna                write U in place of T

transcribe - DNA to RNA from either strand, or RNA back to DNA
-s, --strand {coding,template}
    --back               convert RNA to DNA instead

translate - one frame, six frames, or a checked coding sequence
-f, --frame FRAMES       1, 2, 3, -1, -2, -3, a comma-separated list, or
                         'forward', 'reverse', 'all' (default: 1)
-t, --table CODE         genetic code by number, name or alias (default: 1)
    --cds                require a complete coding sequence
    --to-stop            end each frame at its first stop codon
    --stop-symbol CHAR   symbol written for a stop (default: *)
    --unknown CHAR       symbol written for an undecidable codon (default: X)

rev-comp tables lists the 27 bundled genetic codes; rev-comp tables --table N prints one in full.

Reading the output

  • Names and descriptions are carried through with the operation appended, so >primer_F forward primer becomes >primer_F forward primer reverse-complement. Translated records are named for their frame, name_f1 to name_r3, so six-frame output has unique identifiers.
  • Frames 1, 2, 3 are offsets into the sequence as given; -1, -2, -3 are offsets into its reverse complement, so frame -1 begins at the 3' end.
  • transcribe assumes the coding strand and substitutes U for T. For a template strand pass --strand template, which reverse complements first: the transcript is antiparallel to the template, so plain substitution would give the right bases in the wrong order.
  • --cds requires a whole number of codons from an initiation codon of the chosen table to a terminal stop, translates the initiator as methionine, omits the stop, and reports a sequence that is not a valid CDS rather than translating it anyway.
  • Ambiguity codes are complemented to their IUPAC counterparts (R↔Y, K↔M, B↔V, D↔H) and translated when decidable (GGN is glycine) and to X otherwise. Case is preserved, gaps (-, ., ~) pass through, and T and U are interchangeable, though a sequence holding both is warned about.
  • Characters outside the IUPAC alphabet are reported by position and record and nothing is written; --permissive substitutes N and warns instead. Exit codes: 0 success, 1 I/O or conflicting arguments, 2 usage error, 3 input read but not valid sequence.

Genetic codes

All 27 translation tables are bundled, transcribed verbatim from the ncbieaa and sncbieaa strings of gc.prt, whose sha256 is recorded in codons.py. Each table carries its own stop codons and its own initiation codons, so --cds means something different under each one:

--table takes a number, an NCBI name, or an alias such as standard, bacterial or vertebrate-mito. Tables 1 and 11 assign the same amino acids and differ only in which codons may initiate, so --cds accepts a GTG or TTG start under table 11 and rejects it under table 1.

Limitations

  • Input is held in memory, which suits oligos, genes, plasmids and viral genomes rather than vertebrate chromosomes. Validation completes before anything is written, so an invalid record leaves no partial output.
  • Sequences are treated as linear and no coordinate subsetting is offered, so slice before piping in. Alignment gaps are accepted but not removed, and translate to X where they fall.
  • Translation is frame arithmetic, not gene finding: no splice sites, ribosome binding sites or coding potential are considered.

Development

pip install -e ".[dev]"
pytest -q
python -m pyflakes src/revcomp tests

License

Licensed under the PolyForm Noncommercial License 1.0.0. See LICENSE for the complete terms.

Metadata

Release files for norvara-rev-comp 1.0.0rc1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for norvara-rev-comp 1.0.0rc1
File Size Uploaded Provenance
norvara_rev_comp-1.0.0rc1.tar.gz 29.2 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for norvara-rev-comp 1.0.0rc1
File Interpreter ABI Platform
norvara_rev_comp-1.0.0rc1-py3-none-any.whl Python 3 none any Details

Total release size: 51.7 kB

Release files / norvara_rev_comp-1.0.0rc1.tar.gz

Download URL norvara_rev_comp-1.0.0rc1.tar.gz
Size 29.2 kB
Tags Source
SHA-256 checksum
How to use checksums
737319b91c0b15ac18cb1fc2ea47871fceff945b0df5e074ef123fae08a2902f
BLAKE2b-256 checksum
How to use checksums
b7fcdea4f09381aa2859c5dc4151a564a657d096a4b9e4f6c34dc2b0bbce00de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / norvara_rev_comp-1.0.0rc1-py3-none-any.whl

Download URL norvara_rev_comp-1.0.0rc1-py3-none-any.whl
Size 22.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bc960c4851ad28b8c1d22009971d25d7fa3465e444be21243f4342e703c870c3
BLAKE2b-256 checksum
How to use checksums
22b19fcaa4e8baca0e05ce81b725d7a553e79760e910b51ee462e985228cf941
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Security for norvara-rev-comp 1.0.0rc1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for norvara_rev_comp-1.0.0rc1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release
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