Skip to main content

biogl

PyPI version Python 3.10+ License: MIT

A collection of useful small bioinformatics functions for working with genomic data formats.

Features

  • GFF3/GTF Parsing: Comprehensive parser with type hints and opt-in GFF3 spec compliance
  • FASTA Utilities: Functions for parsing and manipulating FASTA files
  • Coordinate Operations: Tools for working with genomic coordinates
  • Type Safety: Full type hints for better IDE support and static analysis
  • Well Tested: Comprehensive test suite with real genomic data

Installation

Using pip (recommended)

python3 -m pip install biogl

Development Installation

git clone https://github.com/grahamlarue/biogl.git
cd biogl
pip install -e ".[dev]"

Quick Start

import biogl

# Parse a GFF3/GTF line
from biogl import GxfParse

line = "chr1\tEnsembl\tgene\t1000\t2000\t.\t+\t.\tID=gene1;Name=TEST"
parsed = GxfParse(line, line_number=1)

print(parsed.region)      # chr1
print(parsed.start)       # 1000
print(parsed.stop)        # 2000
print(parsed.strand)      # 1 (normalized)
print(parsed.name)        # gene1
print(parsed.attributes)  # {'ID': 'gene1', 'Name': 'TEST'}

# Enable GFF3 spec compliance features
parsed = GxfParse(
    line,
    line_number=1,
    url_decode=True,        # Decode percent-encoded values
    case_sensitive=True,    # Case-sensitive attribute matching
    strict_coordinates=True # Validate start <= end
)

# Parse FASTA files
from biogl import fasta_parse

for header, sequence in fasta_parse("genome.fa"):
    print(f"{header}: {len(sequence)} bp")

# Work with coordinates
from biogl import coord_overlap

overlap = coord_overlap(100, 200, 150, 250)  # Returns 50

# Reverse complement
from biogl import rev_comp

seq = "ATCG"
rc = rev_comp(seq)  # Returns "CGAT"

Key Modules

  • GxfParse: Parse GFF3/GTF annotation files with full type hints
  • fasta_parse: Efficient FASTA file parsing
  • coord_overlap: Calculate coordinate overlaps
  • rev_comp: Reverse complement DNA sequences
  • translate: Translate DNA to protein
  • flex_open: Open compressed or uncompressed files transparently
  • window: Sliding window generator
  • And more...

Breaking Changes in v3.0.0

Important: Version 3.0.0 introduces breaking changes to GxfParse:

  • Features without explicit IDs now return None instead of 'feature_None' strings
  • Migration: Change if name == 'exon_None' to if name is None

See CHANGELOG.md for full details.

Documentation

For detailed documentation on each module, use Python's built-in help:

from biogl import GxfParse
help(GxfParse)

Requirements

  • Python 3.10+
  • smart_open

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see LICENSE file for details.

Author

Graham Larue (egrahamlarue@gmail.com)

Links

Metadata

Release files for biogl 3.0.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 biogl 3.0.1
File Size Uploaded
biogl-3.0.1.tar.gz 17.3 kB Details

Built distribution (wheel)

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

Total release size: 35.8 kB

Release files / biogl-3.0.1.tar.gz

Download URL biogl-3.0.1.tar.gz
Size 17.3 kB
Tags Source
SHA-256 checksum
How to use checksums
897384eb309b537c9b1eefcc98180c15272b5a40f8514ed92984f44db0912c24
BLAKE2b-256 checksum
How to use checksums
b7c62922a71d9cab67691a120431bbc71942ea18698cb6df176a238077dd3816
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / biogl-3.0.1-py3-none-any.whl

Download URL biogl-3.0.1-py3-none-any.whl
Size 18.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1d48c61c9eda5758625e1d6acd852396e7b44b11c4150fc90e889612d776058b
BLAKE2b-256 checksum
How to use checksums
1be383258ffa0a1606be804aab5c37eb402d2e4fce88841d69420881da7f3389
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

3.0.1 This release

2 release files

3.0.0

2 release files

2.4.0

2 release files

2.3.0

2 release files

2.2.4

2 release files

2.2.3

2 release files

2.2.2

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.3

2 release files

2.1.2

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.0.0

2 release files

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