Skip to main content

fastalite

https://travis-ci.org/nhoffman/fastalite.svg?branch=master

The simplest possible fasta and fastq parsers I could come up with. Useful for simple manipulations of sequence files without creating complex dependencies.

The fastalite and fastqlite functions return an iterator of namedtuples, each with attributes id, (the header line before the first whitespace) description (the entire header line), and seq (the sequence as a string). fastqlite output also has an attribute qual containing the quality scores. For example:

from fastalite import fastalite

with open('inseqs.fasta') as infile, open('outseqs.fasta', 'w') as outfile:
    for seq in fastalite(infile):
        outfile.write('>{}\n{}\n'.format(seq.id, seq.seq))

The fastqlite parser also performs some limited error checking and raises ValueError when it encounters a malformed record.

The Opener class may be used in place of argparse.FileType to support transparent reading and writing of compressed files (inferred from a .gz or .bz2 suffix), for example:

import argparse
from fastalite import Opener, fastalite

parser = argparse.ArgumentParser()
parser.add_argument('infile', type=Opener())
args = parser.parse_args(arguments)
seqs = fastalite(args.infile)

You can perform a few actions on input files using the command line interface. For a list of available commands:

python -m fastalite -h

Installation

Compatible with Python versions 2.7 and 3.4+

Install from PyPi using pip:

pip install fastalite

Or install directly from the git repository:

pip install git+https://github.com/nhoffman/fastalite.git

Testing

Run all tests like this:

python setup.py test

Metadata

Release files for fastalite 0.4.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 fastalite 0.4.1
File Size Uploaded Provenance Actions
fastalite-0.4.1.tar.gz 5.8 kB Without provenance Details for fastalite-0.4.1.tar.gz

Release files / fastalite-0.4.1.tar.gz

Download URL fastalite-0.4.1.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e85413ee22bdb3fe0f73f5226771cf71eb33074ccdf8bbefff3a1bc6242de37c
BLAKE2b-256 checksum
How to use checksums
7e62b3c187602af04c31ea7b51f9b2ed365c58abe2959af3ff57d42fdc28dcdf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.7

Security for fastalite 0.4.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.

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