Metadata-Version: 2.1
Name: fastaframes
Version: 0.0.3
Summary: A very simple fasta file parser.
Author-email: Patrick Garrett <pgarrett@scripps.edu>
License: MIT License
        
        Copyright (c) 2023 Patrick Garrett
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: repository, https://github.com/pgarrett-scripps/FastaFrames.git
Keywords: Fasta file,Pandas DataFrame,Data conversion,Python module,FASTA format,Reading files,Writing files,Dataclass,Bioinformatics,Scientific computing
Classifier: Programming Language :: Python :: 3
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE

![example workflow](https://github.com/pgarrett-scripps/FastaFrames/actions/workflows/python-package.yml/badge.svg)
![example workflow](https://github.com/pgarrett-scripps/FastaFrames/actions/workflows/pylint.yml/badge.svg)

# FastaFrames
This Python package 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. 

## Features
- Read FASTA files into pandas DataFrames
- Write FASTA files from pandas DataFrames

## Usage

To install fastaframes use pip:

```sh
pip install fastaframes
```

### Reading FASTA files
To read a FASTA file and convert it to a pandas DataFrame:

```python
from fastaframes import to_df

# IO input
with open('example.fasta', 'r') as fasta_io:
    fasta_df = to_df(fasta_data=fasta_io)

# or

# File input
fasta_df = to_df(fasta_data='example.fasta')
    
print(fasta_df.head())
```

### Writing FASTA files
To write a pandas DataFrame to a FASTA file:

```python
from fastaframes import to_fasta

# Write StringIO to file
fasta_io = to_fasta(fasta_data=fasta_df) # outputs StringIO if file=None
with open('output.fasta', 'w') as output_file:
    output_file.write(fasta_io.getvalue())

# or
    
# Write directly to file
to_fasta(fasta_data=fasta_df, file='output.fasta')
```

## Example Fasta DataFrame:

|   | db | unique_identifier | entry_name   | protein_name                                         | organism_name | organism_identifier | gene_name | protein_existence | sequence_version | protein_sequence                                       |
|---|----|------------------|--------------|------------------------------------------------------|---------------|---------------------|-----------|-------------------|------------------|--------------------------------------------------------|
| 0 | sp | A0A087X1C5       | CP2D7_HUMAN  | Putative cytochrome P450 2D7                         | Homo sapiens  | 9606.0              | CYP2D7    | 5.0               | 1.0              | MGLEALVPLAMIVAIFLLLVDLMHRHQRWAARYPPGPLPLPGLGNLLHVDFQNTPYCFDQ |
| 1 | sp | A0A0B4J2F2       | SIK1B_HUMAN  | Putative serine/threonine-protein kinase SIK1B        | Homo sapiens  | 9606.0              | SIK1B     | 5.0               | 1.0              | MVIMSEFSADPAGQGQGQQKPLRVGFYDIERTLGKGNFAVVKLARHRVTKTQVAIKIIDKLVQ |
| 2 | sp | A0A0C5B5G6       | MOTSC_HUMAN  | Mitochondrial-derived peptide MOTS-c                 | Homo sapiens  | 9606.0              | MT-RNR1   | 1.0               | 1.0              | MRWQEMGYIFYPRKLR                                      |
| 3 | sp | A0A0K2S4Q6       | CD3CH_HUMAN  | Protein CD300H                                       | Homo sapiens  | 9606.0              | CD300H    | 1.0               | 1.0              | MTQRAGAAMLPSALLLLCVPGCLTVSGPSTVMGAVGESLSVQCRYEEKYKTFNKYWCRQP |
