Skip to main content

A small command-line tool that summarizes FASTA files (sequence count and mean length).

Project description

Fasta_summary

A small, dependency-free Python command-line tool that summarizes a FASTA file: it counts the number of sequences and prints their mean length.

Installation

From PyPI (once published):

pip install fasta-summary-songwei

From source:

git clone https://github.com/songwei/fasta-summary.git
cd fasta-summary
python -m pip install -e .

Requires Python 3.9 or newer.

Usage

Run the command against a FASTA file:

fasta-summary example.fasta

Typical output (TSV, two lines):

sequences	3
mean_length	8.33

You can also invoke it as a module:

python -m fasta_summary example.fasta

Help:

fasta-summary --help
usage: fasta-summary [-h] input

Summarize a FASTA file: count sequences and compute mean length.

positional arguments:
  input       Path to the input FASTA file

options:
  -h, --help  show this help message and exit

Input / Output

  • Input: a FASTA file. Headers start with >. Sequences may span multiple lines. Blank lines are ignored.
  • Output: two TSV lines written to stdout:
    • sequences<TAB><count>
    • mean_length<TAB><mean> (mean is formatted with 2 decimal places)

Special cases

  • Empty file (or file containing only blank lines): prints sequences\t0 and mean_length\t0.00 and exits with code 0.
  • Missing file: prints a friendly error to stderr and exits with code 1.
  • Sequence data before any header: prints a clear error to stderr and exits with code 2.

Known Limitations

  • Reads the whole file into memory; not optimized for very large FASTA files.
  • Length is counted in raw characters; letters are not validated against any biological alphabet (IUPAC, etc.).
  • Header metadata (anything after the first whitespace) is ignored.
  • Only standard >-prefixed FASTA headers are recognized; alternate formats such as FASTQ or multi-record line-wrapping conventions are not supported.
  • Input is read as UTF-8 text; binary FASTA files are not supported.

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

fasta_summary_songwei-0.1.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fasta_summary_songwei-0.1.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file fasta_summary_songwei-0.1.0.tar.gz.

File metadata

  • Download URL: fasta_summary_songwei-0.1.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.12

File hashes

Hashes for fasta_summary_songwei-0.1.0.tar.gz
Algorithm Hash digest
SHA256 076f3202d23abc2955974eba3583c4bab61ef71275e5e6239cc4e1897752ace0
MD5 7a7512cb20be9965cc74ddec6113bad4
BLAKE2b-256 df560847717323c34a298f598cf6f73b7f9bd37d242eb02d2272af5b191e8aed

See more details on using hashes here.

File details

Details for the file fasta_summary_songwei-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for fasta_summary_songwei-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e14e1a5d45ea532571be76614e24b21679a48a28492e60c2503db7e2d8536170
MD5 8d8e7f41ef69dbb117267912014b84e9
BLAKE2b-256 252ecc585a0d70884faebfdb74706d3b2beb14b8dcf30036f2d0b4cdeea971a5

See more details on using hashes here.

Supported by

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