Skip to main content

A package for maf files io

Project description

MAFIO

A minimalist Python package for reading and writing MAF files.

Installation

Package can be installed using pip.

> pip install mafio

Usage

Read

from mafio import MAFReader

reader = MAFReader("test.maf")

# for reading compressed file
reader = MAFReader("test.maf", compression='gzip')

data = reader.read()

print(reader.headers) # ['col1', 'col2', 'col3']
print(next(data)) # [[1,2,3], [4,5,6], [7,8,9]]

# return only certain columns
data = reader.read(use_cols=['col1','col3'])

print(reader.headers) # ['col1', 'col3']
print(next(data)) # [[1,3], [4,6], [7,9]]

# for big files use chunks
data = reader.read(chunk_size=2)

print(next(data)) #[[1,2,3], [4,5,6]]
print(next(data)) #[[7,8,9]]

Write

from mafio import write

cols = ['col1', 'col2', 'col3']
row1 = [1,2,3]
row2 = [4,5,6]
row3 = [7,8,9]
data = [cols, row1, row2, row3]

# Creates file if not exists
write("test.maf", data)

# Appending the file instead of overwriting
write("test.maf", data, append=True)

# gzip the file
write("test.maf.gz", data)

Tests

Clone the library.

> git clone https://github.com/zeyad-kay/mafio.git

Install test dependencies.

pip install -r test-requirements.txt

Run tests.

> pytest mafio/tests

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

mafio-1.0.2.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

mafio-1.0.2-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file mafio-1.0.2.tar.gz.

File metadata

  • Download URL: mafio-1.0.2.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for mafio-1.0.2.tar.gz
Algorithm Hash digest
SHA256 b356dff7c0fd5006cb75a10459c0b7b7d94b776e971e8802d97a6dd468491a63
MD5 c68690da9fb0bbedea58e53e4a758085
BLAKE2b-256 32a92d5a5b5d1d24bd6493627089ba2a7ef8b4c00cf3f5620aaee8218d3ed3b1

See more details on using hashes here.

File details

Details for the file mafio-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: mafio-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for mafio-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f51f7d2d69b96047763968bd5dbd85672e227d4d5cffb3f4ba2a285e1795111b
MD5 ea09b96fd18a74a881133e8fffa6c71b
BLAKE2b-256 213731cd7aebcbd1fba60734101e08ed29f8e11d4b2e2ec6cdffd54f832099f0

See more details on using hashes here.

Supported by

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