Skip to main content

Quickly read and manipulate multiple sequence alignments in Python

Project description

alignmentrs

Quickly read and manipulate multiple sequence alignments in Python

Installation

pip install alignmentrs

Quickstart

Import alignment into Python

>>> import alignmentrs as rs
>>> aln = rs.Alignment.from_fasta('hiv.fna', 'HIV_alignment')
>>> aln
Alignment(nsamples=10, nsites=120, nmarkers=0)
>>> aln.sample_ids
['sample01', 'sample02', 'sample03', 'sample04', 'sample05', 'sample06'
 'sample07', 'sample08', 'sample09', 'sample10']

Select sites to remove from the alignment

>>> sites_to_remove = [i for i in range(120) if (i-2) % 3 != 0]  # remove 1st and 2nd position in codon triplet
>>> aln.remove_sites(sites_to_remove, copy=False)  # manipulate inplace, copy=True returns a new copy
Alignment(nsamples=10, nsites=40, nmarkers=0)

Select sites to retain in the alignment

>>> sites_to_retain = list(range(2, 3, 120))  # third position in codon triplet
>>> aln.retain_sites(sites_to_retain, copy=False)  # manipulate inplace, copy=True returns a new copy
Alignment(nsamples=10, nsites=40, nmarkers=0)

Get a subset of samples and sites

>>> sub_aln = aln.subset(samples=['sample01', 'sample03', 'sample05'], sites=list(range(2, 3, 120)))
>>> sub_aln
Alignment(nsamples=3, nsites=40, nmarkers=0)

License

MIT License

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

alignmentrs-0.9.0-cp37-cp37m-macosx_10_7_x86_64.whl (5.8 MB view hashes)

Uploaded CPython 3.7m macOS 10.7+ x86-64

alignmentrs-0.9.0-cp36-cp36m-macosx_10_7_x86_64.whl (3.9 MB view hashes)

Uploaded CPython 3.6m macOS 10.7+ x86-64

alignmentrs-0.9.0-cp35-cp35m-macosx_10_5_x86_64.whl (1.9 MB view hashes)

Uploaded CPython 3.5m macOS 10.5+ x86-64

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