Skip to main content

No project description provided

Project description

SeqLike

SeqLike - flexible biological sequence objects in Python

PyPI - Supported Python Version PyPI - Package Version Conda - Platform Conda (channel only) Docs - GitHub.io

Introduction

A single object API that makes working with biological sequences in Python more ergonomic. It'll handle anything like a sequence.

Built around the Biopython SeqRecord class, SeqLikes abstract over the semantics of molecular biology (DNA -> RNA -> AA) and data structures (strings, Seqs, SeqRecords, numerical encodings) to allow manipulation of a biological sequence at the level which is most computationally convenient.

Code samples and examples

Build data-type agnostic functions

def f(seq: SeqLikeType, *args):
	seq = SeqLike(seq, seq_type="nt").to_seqrecord()
	# ...

Streamline conversion to/from ML friendly representations

prediction = model(aaSeqLike('MSKGEELFTG').to_onehot())
new_seq = ntSeqLike(generative_model.sample(), alphabet="-ACGTUN")

Interconvert between AA and NT forms of a sequence

Back-translation is conveniently built-in!

s_nt = ntSeqLike("ATGTCTAAAGGTGAA")
s_nt[0:3] # ATG
s_nt.aa()[0:3] # MSK, nt->aa is well defined
s_nt.aa()[0:3].nt() # ATGTCTAAA, works because SeqLike now has both reps
s_nt[:-1].aa() # TypeError, len(s_nt) not a multiple of 3

s_aa = aaSeqLike("MSKGE")
s_aa.nt() # AttributeError, aa->nt is undefined w/o codon map
s_aa = aaSeqLike(s_aa, codon_map=random_codon_map)
s_aa.nt() # now works, backtranslated to e.g. ATGTCTAAAGGTGAA
s_aa[:1].nt() # ATG, codon_map is maintained

Easily plot multiple sequence alignments

seqs = [s for s in SeqIO.parse("file.fasta", "fasta")]
df = pd.DataFrame(
    {
        "names": [s.name for s in seqs],
        "seqs": [aaSeqLike(s) for s in seqs],
    }
)
df["aligned"] = df["seqs"].seq.align()
df["aligned"].seq.plot()

Flexibly build and parse numerical sequence representations

# Assume you have a dataframe with a column of 10 SeqLikes of length 90
df["seqs"].seq.to_onehot().shape # (10, 90, 23), padded if needed

To see more in action, please check out the docs!

Getting Started

Install the library with pip or conda.

With pip

pip install seqlike

With conda

conda install -c conda-forge seqlike

Authors

Support

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Nasos Dousis

💻

andrew giessel

💻

Max Wall

💻 📖

Eric Ma

💻 📖

Mihir Metkar

🤔 💻

Marcus Caron

📖

pagpires

📖

Sugato Ray

🚇 🚧

This project follows the all-contributors specification. Contributions of any kind welcome!

Project details


Download files

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

Source Distribution

seqlike-1.1.7.tar.gz (366.2 kB view details)

Uploaded Source

Built Distribution

seqlike-1.1.7-py3-none-any.whl (368.0 kB view details)

Uploaded Python 3

File details

Details for the file seqlike-1.1.7.tar.gz.

File metadata

  • Download URL: seqlike-1.1.7.tar.gz
  • Upload date:
  • Size: 366.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for seqlike-1.1.7.tar.gz
Algorithm Hash digest
SHA256 7865cf6823a572145034f8f069bf4d68e39bfe0ab3313979f3b76e8b0b7a32cb
MD5 38ed0d70a3bfc4f055b2d033dec9f257
BLAKE2b-256 3780a43b6891e4c3181e61b9e5ea6078d52f1f7f9c45c34a02d11998f9dba762

See more details on using hashes here.

File details

Details for the file seqlike-1.1.7-py3-none-any.whl.

File metadata

  • Download URL: seqlike-1.1.7-py3-none-any.whl
  • Upload date:
  • Size: 368.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for seqlike-1.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 54b95d1ffc9bc7a2c2ae9c155d9588caae115c01828319a131ccf7ff4f904ee6
MD5 c5c4ec1bdcfb9925c5e7e27e8ac46a75
BLAKE2b-256 a4a24487cdb0650a9146cb966657e8ad23945f01f0c53000766e893f816ca476

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page