Skip to main content

A lightweight library for working with PAF (Pairwise mApping Format) files

Project description

pafpy

A lightweight library for working with PAF (Pairwise mApping Format) files.

GitHub Workflow Status codecov PyPI PyPI - Python Version License Code style: black

Documentation: https://pafpy.xyz

Table of Contents

Install

PyPi

pip install pafpy

Conda

conda install -c bioconda pafpy

Locally

If you would like to install locally, the recommended way is using poetry.

git clone https://github.com/mbhall88/pafpy.git
cd pafpy
make install
# to check the library is installed run
poetry run python -c "from pafpy import PafRecord;print(str(PafRecord()))"
# you should see a (unmapped) PAF record printed to the terminal
# you can also run the tests if you like
make test-code

Usage

For full usage, please refer to the documentation. If there is any functionality you feel is missing or would make pafpy more user-friendly, please raise an issue with a feature request.

In the below basic usage pattern, we collect the BLAST identity of all primary alignments in our PAF file into a list.

from typing import List
from pafpy import PafFile

path = "path/to/sample.paf"

identities: List[float] = []
with PafFile(path) as paf:
    for record in paf:
        if record.is_primary():
            identity = record.blast_identity()
            identities.append(identity)

Another use case might be that we want to get the identifiers of all records aligned to a specific contig, but only keep the alignments where more than 50% of the query (read) is aligned.

from typing import List
from pafpy import PafFile

path = "path/to/sample.paf"

contig = "chr1"
min_covg = 0.5
identifiers: List[str] = []
with PafFile(path) as paf:
    for record in paf:
        if record.tname == contig and record.query_coverage > min_covg:
            identifiers.append(record.qname)

Contributing

If you would like to contribute to pafpy, checkout CONTRIBUTING.md.

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

pafpy-0.1.1.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

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

pafpy-0.1.1-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file pafpy-0.1.1.tar.gz.

File metadata

  • Download URL: pafpy-0.1.1.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.3.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for pafpy-0.1.1.tar.gz
Algorithm Hash digest
SHA256 435684364f6da6e2aca5f40b71a41733069f399574121c7f3c7e18ab6bc923a8
MD5 f25cb420243b754d6f5ee87d83de52b9
BLAKE2b-256 4361903b12dd741622d04a6dbfd806a580f23ffe87317ed5d226b32146a372f9

See more details on using hashes here.

File details

Details for the file pafpy-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pafpy-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.3.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for pafpy-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a414b7bd5db5045f57f30951cec2d4d042ce35a00012d922d5b152ce696963a3
MD5 dd268c1bb9ac5146b3dc47e6aea058f1
BLAKE2b-256 4202117780bc2a484af4615a178a2bbf8722d913777a119e94e6b1d1bb3b42d6

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