Skip to main content

FlowAlign

FlowAlign is a package to simplify realignment to a reference for viral sequences, using only Python packages. (Under the hood it is using minimap2, so it's fast.)

Installation

pip install flowalign

Usage (command-line)

flowalign sequences.fasta --reference wuhCor1.fa --output aligned.fa

If you omit the output parameter, output will go to STDOUT.

Usage (Python):

First we download the reference, and some unaligned sequences to align to it:

wget https://hgdownload.soe.ucsc.edu/goldenPath/wuhCor1/bigZips/wuhCor1.fa.gz && gunzip wuhCor1.fa.gz
wget https://data.nextstrain.org/files/ncov/open/global/sequences.fasta.xz &&  xz --decompress sequences.fasta.xz

Then we write a simple Python script, creating an iterator called aligned that will yield reference-aligned versions of these unaligned sequences:

import flowalign
aligned = flowalign.yield_aligned(input="sequences.fasta", reference= "wuhCor1.fa")
for name, aligned_sequence in aligned:
    print(">"+name)
    print(aligned_sequence)

yield_aligned can also take a stream, e.g.:

aligned = flowalign.yield_aligned(input=open("sequences.fasta","rt), reference= "wuhCor1.fa")

Under the hood, mappy is in some sense calling minimap2 with --secondary=no --sam-hit-only --score-N=0 -x asm5.

Note that the multiprocessing implementation is fairly hacky which may cause issues. It is mostly expected that yield_aligned will be only called once at any one time.

Acknowledgements

This package is developed by me, but it owes almost everything to sam_2_fasta by Ben Jackson at the University of Edinburgh -- major functions are taken from that codebase. (Ben has also ported this code to gofasta). Sam2fasta is typically run on a SAM file from minimap2. flowalign incorporates the alignment process using mappy, the Python-bindings for minimap2. The idea is that one doesn't need any dependencies except Python packages (mappy supplies its own minimap2) to get aligned sequences.

Metadata

Release files for flowalign 0.11

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

Source distribution (sdist)

Source distribution for flowalign 0.11
File Size Uploaded Provenance Actions
flowalign-0.11.tar.gz 8.5 kB Without provenance Details for flowalign-0.11.tar.gz

Built distribution (wheel)

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

Total release size: 16.9 kB

Release files / flowalign-0.11.tar.gz

Download URL flowalign-0.11.tar.gz
Size 8.5 kB
Tags Source
SHA-256 checksum
How to use checksums
abe6490818015882a602dd5a9012d87a16701e55fdf5a4178eb47bd6b7ba6692
BLAKE2b-256 checksum
How to use checksums
76a65311702efae8e147a28e06ac3bf74a3c5956354bfd2a33f39404a53bc4bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / flowalign-0.11-py3-none-any.whl

Download URL flowalign-0.11-py3-none-any.whl
Size 8.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
529a5bf71c53b9af632298892d0deed7cfdbd9fd335ff86f906207d19afea926
BLAKE2b-256 checksum
How to use checksums
4576ef75aa8ccd981ed12c2c9fd410387dc3115bac9c00060e3e1d366ef1306a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Security for flowalign 0.11

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.

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