A very simple fasta file parser.
Project description
FastaFrames
This Python module provides a set of functions to work with FASTA files. It allows you to read FASTA files, convert them to pandas dataframes, manipulate data, and write data back to FASTA files. It also supports converting FASTA files to a list of custom FastaEntry dataclass objects.
Features
- Read FASTA files into pandas DataFrames
- Convert FASTA files to a list of FastaEntry objects
- Write FASTA files from pandas DataFrames
- Write FASTA files from a list of FastaEntry objects
Usage
Reading FASTA files
To read a FASTA file and convert it to a pandas DataFrame:
from fastaframes import fasta_to_df
with open('example.fasta', 'r') as file_input:
fasta_df = fasta_to_df(file_input)
print(fasta_df.head())
To read a FASTA file and convert it to a list of FastaEntry objects:
from fastaframes import fasta_to_entries
with open('example.fasta', 'r') as file_input:
entries = fasta_to_entries(file_input)
print(entries[:5])
Writing FASTA files
To write a pandas DataFrame to a FASTA file:
import pandas as pd
from fastaframes import to_fasta
fasta_df = pd.DataFrame() # empty
fasta_content = to_fasta(fasta_df)
with open('output.fasta', 'w') as output_file:
output_file.write(fasta_content.getvalue())
To write a list of FastaEntry objects to a FASTA file:
from fastaframes import to_fasta
entries = [] # empty
fasta_content = to_fasta(entries)
with open('output.fasta', 'w') as output_file:
output_file.write(fasta_content.getvalue())
Customization
The FastaEntry dataclass can be customized to store additional information or modify existing attributes as needed. This can be done by editing the FastaEntry dataclass definition and updating the extract_fasta_info function accordingly.
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
Built Distribution
Hashes for fastaframes-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63048eb70c971028259e6aee8c6ebc1b75b9a42f0350e91c443277cd729c31c0 |
|
MD5 | adae5cb663110144e3f1f29fddf16659 |
|
BLAKE2b-256 | 199532a84969aafdea8b2cfffa82bbd86141d7a04957e04880948d552d1c9831 |