Skip to main content

licence PyPI version

Description

seq2onehot is a command-line tool encoding DNA/RNA/protein sequences to a one-hot numpy array.
z

⚠️ All sequences must be the same lengths.

To decode a one-hot numpy array to sequences, use onehot2seq.
https://github.com/akikuno/onehot2seq

Installation

You can install seq2onehot using pip:

pip install seq2onehot

Usage

seq2onehot [options] -t/--type <dna/rna/protein> -i/--input <in.fasta> -o/--output <out.npy>

Options

-a/--ambiguous: include ambiguous characters

The ambigous characters are:

  • XBZJ for amino acid
  • NVHDBMRWSYK for DNA and RNA

The detail of ambiguous characters is described here:
https://meme-suite.org/meme/doc/alphabets.html

Examples

# DNA sequences
seq2onehot -t dna -i example/dna.fasta -o dna.npy

# RNA sequences
seq2onehot -t rna -i example/rna.fasta -o rna.npy

# Protein sequences
seq2onehot -t protein -i example/protein.fasta -o protein.npy

One-hot array

The output file contains 3d one-hot array of RxNxL (Read x Nucreotide/Amino acid x Letter)

  • The order of nucreotide is ACGT (+ NVHDBMRWSYK) for DNA, ACGU (+ NVHDBMRWSYK) for RNA
  • The order of amino acid is ACDEFGHIKLMNPQRSTVWY (+ XBZJ)
# Original sequences:
## ACGTACGTACGTACGT
## CCCCCCCCTTTTTTTT

onehot = np.load("dna.npy")

onehot.shape
# (2, 16, 4) <- 2 reads x 16 nucreotides x 4 letters (ACGT)

onehot
# array([[[1., 0., 0., 0.],
#         [0., 1., 0., 0.],
#         [0., 0., 1., 0.],
#         [0., 0., 0., 1.],
#         [1., 0., 0., 0.],
#         [0., 1., 0., 0.],
#         [0., 0., 1., 0.],
#         [0., 0., 0., 1.],
#         [1., 0., 0., 0.],
#         [0., 1., 0., 0.],
#         [0., 0., 1., 0.],
#         [0., 0., 0., 1.],
#         [1., 0., 0., 0.],
#         [0., 1., 0., 0.],
#         [0., 0., 1., 0.],
#         [0., 0., 0., 1.]],

#        [[0., 1., 0., 0.],
#         [0., 1., 0., 0.],
#         [0., 1., 0., 0.],
#         [0., 1., 0., 0.],
#         [0., 1., 0., 0.],
#         [0., 1., 0., 0.],
#         [0., 1., 0., 0.],
#         [0., 1., 0., 0.],
#         [0., 0., 0., 1.],
#         [0., 0., 0., 1.],
#         [0., 0., 0., 1.],
#         [0., 0., 0., 1.],
#         [0., 0., 0., 1.],
#         [0., 0., 0., 1.],
#         [0., 0., 0., 1.],
#         [0., 0., 0., 1.]]])

Metadata

Release files for seq2onehot 0.0.1

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

Source distribution (sdist)

Source distribution for seq2onehot 0.0.1
File Size Uploaded Provenance
seq2onehot-0.0.1.tar.gz 3.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for seq2onehot 0.0.1
File Interpreter ABI Platform
seq2onehot-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 8.3 kB

Release files / seq2onehot-0.0.1.tar.gz

Download URL seq2onehot-0.0.1.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
897d8c2cce477d85028c43b3c1eb24e89b47742cd39e935ae7d862011ffbefa2
BLAKE2b-256 checksum
How to use checksums
e294b9a39ef02694801ec5159d19bbaf95c3bccc0416399e2313518c4855c843
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/0.0.0 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.10

Release files / seq2onehot-0.0.1-py3-none-any.whl

Download URL seq2onehot-0.0.1-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
841535e7e55c66235639bcc13ad8ff2afb9fd9b58a55d6fa7f19358fe0bc1002
BLAKE2b-256 checksum
How to use checksums
99d4899716534fc53653a75566585ee11e504590fe52fa9af160d867bc962f7c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/0.0.0 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.10

Security for seq2onehot 0.0.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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

0.0.1 This release

2 release files No provenance

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