fastaparser


Namefastaparser JSON
Version 1.1.1 PyPI version JSON
download
home_pagehttps://github.com/Kronopt/FastaParser
SummaryA Python FASTA file Parser and Writer.
upload_time2022-09-03 23:58:52
maintainer
docs_urlNone
authorPedro HC David, https://github.com/Kronopt
requires_python
licenseGPLv3
keywords fasta parser fasta-parser fasta-writer
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # FastaParser

[![python versions](https://img.shields.io/pypi/pyversions/fastaparser "supported python versions")](https://pypi.org/project/fastaparser)
[![build status](https://github.com/Kronopt/FastaParser/workflows/CI/badge.svg "build status")](https://github.com/Kronopt/FastaParser/actions?query=workflow%3ACI)
[![code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![coverage](https://codecov.io/gh/Kronopt/FastaParser/branch/master/graph/badge.svg "code coverage")](https://codecov.io/gh/Kronopt/FastaParser)
[![docs status](https://readthedocs.org/projects/fastaparser/badge/?version=latest "documentation build status")](https://fastaparser.readthedocs.io/en/latest/)
[![license](https://img.shields.io/pypi/l/fastaparser "license")](https://github.com/Kronopt/fastaparser/blob/master/LICENSE)

[![pypi](https://img.shields.io/pypi/v/fastaparser "pypi package")](https://pypi.org/project/fastaparser)
[![pypi downloads](https://img.shields.io/pypi/dm/fastaparser "pypi downloads")](https://pypi.org/project/fastaparser)

A Python FASTA file Parser and Writer.

The FASTA file format is a standard text-based format for representing nucleotide and aminoacid sequences
(usual file extensions include: .fasta, .fna, .ffn, .faa and .frn).
FastaParser is able to parse such files and extract the biological sequences within into Python objects.
It can also handle and manipulate such sequences as well as write sequences to new or existing FASTA files.

## Installation

With `pip`:
```sh
$ pip install fastaparser
```

## Usage

### Read FASTA files
Generate python objects from FASTA files:

```Python
>>> import fastaparser
>>> with open("fasta_file.fasta") as fasta_file:
        parser = fastaparser.Reader(fasta_file)
        for seq in parser:
            # seq is a FastaSequence object
            print('ID:', seq.id)
            print('Description:', seq.description)
            print('Sequence:', seq.sequence_as_string())
            print()
```
output:
```
ID: sp|P04439|HLAA_HUMAN
Description: HLA class I histocompatibility antigen, A alpha chain OS=Homo sapi...
Sequence: MAVMAPRTLLLLLSGALALTQTWAGSHSMRYFFTSVSRPGRGEPRFIAVGYVDDTQFVRFDSDAASQRM...

ID: sp|P15822|ZEP1_HUMAN
Description: Zinc finger protein 40 OS=Homo sapiens OX=9606 GN=HIVEP1 PE=1 SV=3...
Sequence: MPRTKQIHPRNLRDKIEEAQKELNGAEVSKKEILQAGVKGTSESLKGVKRKKIVAENHLKKIPKSPLRN...
```

or just parse FASTA headers and sequences, which is much faster but less feature rich:
```Python
>>> import fastaparser
>>> with open("fasta_file.fasta") as fasta_file:
        parser = fastaparser.Reader(fasta_file, parse_method='quick')
        for seq in parser:
            # seq is a namedtuple('Fasta', ['header', 'sequence'])
            print('Header:', seq.header)
            print('Sequence:', seq.sequence)
            print()
```
output:
```
Header: >sp|P04439|HLAA_HUMAN HLA class I histocompatibility antigen, A alpha c...
Sequence: MAVMAPRTLLLLLSGALALTQTWAGSHSMRYFFTSVSRPGRGEPRFIAVGYVDDTQFVRFDSDAASQRM...

Header: >sp|P15822|ZEP1_HUMAN Zinc finger protein 40 OS=Homo sapiens OX=9606 GN...
Sequence: MPRTKQIHPRNLRDKIEEAQKELNGAEVSKKEILQAGVKGTSESLKGVKRKKIVAENHLKKIPKSPLRN...
```

### Write FASTA files
Create FASTA files from FastaSequence objects:
```Python
>>> import fastaparser
>>> with open("fasta_file.fasta", 'w') as fasta_file:
        writer = fastaparser.Writer(fasta_file)
        fasta_sequence = fastaparser.FastaSequence(
            sequence='ACTGCTGCTAGCTAGC',
            id='id123',
            description='test sequence'
        )
        writer.writefasta(fasta_sequence)
```
or single header and sequence strings:
```Python
>>> import fastaparser
>>> with open("fasta_file.fasta", 'w') as fasta_file:
        writer = fastaparser.Writer(fasta_file)
        writer.writefasta(('id123 test sequence', 'ACTGCTGCTAGCTAGC'))
```

## Documentation
Documentation for FastaParser is available here: [https://fastaparser.readthedocs.io/en/latest](https://fastaparser.readthedocs.io/en/latest/)

## History

### 1.1.1 (04-09-2022)
* Added support for Python 3.9 and 3.10

### 1.1 (13-02-2020)
* Added property setters for:
    * FastaSequence.id
    * FastaSequence.description
* Added property deleters for:
    * FastaSequence.id
    * FastaSequence.description
    * FastaSequence.sequence_type
    * LetterCode.letter_type

### 1.0 (27-01-2020)
* First release on PyPI and Anaconda Cloud
* Reader, Writer, FastaSequence and LetterCode classes

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Kronopt/FastaParser",
    "name": "fastaparser",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "fasta parser fasta-parser fasta-writer",
    "author": "Pedro HC David, https://github.com/Kronopt",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/5b/bb/5a567fe0c0ae5ef34a1d547666ff712ef5d16ac6d3f5fae1dad315dda652/fastaparser-1.1.1.tar.gz",
    "platform": null,
    "description": "# FastaParser\n\n[![python versions](https://img.shields.io/pypi/pyversions/fastaparser \"supported python versions\")](https://pypi.org/project/fastaparser)\n[![build status](https://github.com/Kronopt/FastaParser/workflows/CI/badge.svg \"build status\")](https://github.com/Kronopt/FastaParser/actions?query=workflow%3ACI)\n[![code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![coverage](https://codecov.io/gh/Kronopt/FastaParser/branch/master/graph/badge.svg \"code coverage\")](https://codecov.io/gh/Kronopt/FastaParser)\n[![docs status](https://readthedocs.org/projects/fastaparser/badge/?version=latest \"documentation build status\")](https://fastaparser.readthedocs.io/en/latest/)\n[![license](https://img.shields.io/pypi/l/fastaparser \"license\")](https://github.com/Kronopt/fastaparser/blob/master/LICENSE)\n\n[![pypi](https://img.shields.io/pypi/v/fastaparser \"pypi package\")](https://pypi.org/project/fastaparser)\n[![pypi downloads](https://img.shields.io/pypi/dm/fastaparser \"pypi downloads\")](https://pypi.org/project/fastaparser)\n\nA Python FASTA file Parser and Writer.\n\nThe FASTA file format is a standard text-based format for representing nucleotide and aminoacid sequences\n(usual file extensions include: .fasta, .fna, .ffn, .faa and .frn).\nFastaParser is able to parse such files and extract the biological sequences within into Python objects.\nIt can also handle and manipulate such sequences as well as write sequences to new or existing FASTA files.\n\n## Installation\n\nWith `pip`:\n```sh\n$ pip install fastaparser\n```\n\n## Usage\n\n### Read FASTA files\nGenerate python objects from FASTA files:\n\n```Python\n>>> import fastaparser\n>>> with open(\"fasta_file.fasta\") as fasta_file:\n        parser = fastaparser.Reader(fasta_file)\n        for seq in parser:\n            # seq is a FastaSequence object\n            print('ID:', seq.id)\n            print('Description:', seq.description)\n            print('Sequence:', seq.sequence_as_string())\n            print()\n```\noutput:\n```\nID: sp|P04439|HLAA_HUMAN\nDescription: HLA class I histocompatibility antigen, A alpha chain OS=Homo sapi...\nSequence: MAVMAPRTLLLLLSGALALTQTWAGSHSMRYFFTSVSRPGRGEPRFIAVGYVDDTQFVRFDSDAASQRM...\n\nID: sp|P15822|ZEP1_HUMAN\nDescription: Zinc finger protein 40 OS=Homo sapiens OX=9606 GN=HIVEP1 PE=1 SV=3...\nSequence: MPRTKQIHPRNLRDKIEEAQKELNGAEVSKKEILQAGVKGTSESLKGVKRKKIVAENHLKKIPKSPLRN...\n```\n\nor just parse FASTA headers and sequences, which is much faster but less feature rich:\n```Python\n>>> import fastaparser\n>>> with open(\"fasta_file.fasta\") as fasta_file:\n        parser = fastaparser.Reader(fasta_file, parse_method='quick')\n        for seq in parser:\n            # seq is a namedtuple('Fasta', ['header', 'sequence'])\n            print('Header:', seq.header)\n            print('Sequence:', seq.sequence)\n            print()\n```\noutput:\n```\nHeader: >sp|P04439|HLAA_HUMAN HLA class I histocompatibility antigen, A alpha c...\nSequence: MAVMAPRTLLLLLSGALALTQTWAGSHSMRYFFTSVSRPGRGEPRFIAVGYVDDTQFVRFDSDAASQRM...\n\nHeader: >sp|P15822|ZEP1_HUMAN Zinc finger protein 40 OS=Homo sapiens OX=9606 GN...\nSequence: MPRTKQIHPRNLRDKIEEAQKELNGAEVSKKEILQAGVKGTSESLKGVKRKKIVAENHLKKIPKSPLRN...\n```\n\n### Write FASTA files\nCreate FASTA files from FastaSequence objects:\n```Python\n>>> import fastaparser\n>>> with open(\"fasta_file.fasta\", 'w') as fasta_file:\n        writer = fastaparser.Writer(fasta_file)\n        fasta_sequence = fastaparser.FastaSequence(\n            sequence='ACTGCTGCTAGCTAGC',\n            id='id123',\n            description='test sequence'\n        )\n        writer.writefasta(fasta_sequence)\n```\nor single header and sequence strings:\n```Python\n>>> import fastaparser\n>>> with open(\"fasta_file.fasta\", 'w') as fasta_file:\n        writer = fastaparser.Writer(fasta_file)\n        writer.writefasta(('id123 test sequence', 'ACTGCTGCTAGCTAGC'))\n```\n\n## Documentation\nDocumentation for FastaParser is available here: [https://fastaparser.readthedocs.io/en/latest](https://fastaparser.readthedocs.io/en/latest/)\n\n## History\n\n### 1.1.1 (04-09-2022)\n* Added support for Python 3.9 and 3.10\n\n### 1.1 (13-02-2020)\n* Added property setters for:\n    * FastaSequence.id\n    * FastaSequence.description\n* Added property deleters for:\n    * FastaSequence.id\n    * FastaSequence.description\n    * FastaSequence.sequence_type\n    * LetterCode.letter_type\n\n### 1.0 (27-01-2020)\n* First release on PyPI and Anaconda Cloud\n* Reader, Writer, FastaSequence and LetterCode classes\n",
    "bugtrack_url": null,
    "license": "GPLv3",
    "summary": "A Python FASTA file Parser and Writer.",
    "version": "1.1.1",
    "project_urls": {
        "Documentation": "https://fastaparser.readthedocs.io/en/latest/",
        "Homepage": "https://github.com/Kronopt/FastaParser"
    },
    "split_keywords": [
        "fasta",
        "parser",
        "fasta-parser",
        "fasta-writer"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "09f2b29911ca428036cbb78095dd5a1506f85b1868bd37bd49102046e0ab571b",
                "md5": "3ca1f7e8ffd6659f320d62f8a0e16550",
                "sha256": "c929f712bd4ea3e6f3569761c6c4fbe798e9a1c4b04d322deb05c8922e731cd4"
            },
            "downloads": -1,
            "filename": "fastaparser-1.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3ca1f7e8ffd6659f320d62f8a0e16550",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 29697,
            "upload_time": "2022-09-03T23:58:50",
            "upload_time_iso_8601": "2022-09-03T23:58:50.695106Z",
            "url": "https://files.pythonhosted.org/packages/09/f2/b29911ca428036cbb78095dd5a1506f85b1868bd37bd49102046e0ab571b/fastaparser-1.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5bbb5a567fe0c0ae5ef34a1d547666ff712ef5d16ac6d3f5fae1dad315dda652",
                "md5": "b5f0241695e6e06b7f428cc9413ea9cd",
                "sha256": "55adcc43285cac07a39844de2bbc5a0b9a40eb35fa99a44b62abe19917cd778e"
            },
            "downloads": -1,
            "filename": "fastaparser-1.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "b5f0241695e6e06b7f428cc9413ea9cd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 27863,
            "upload_time": "2022-09-03T23:58:52",
            "upload_time_iso_8601": "2022-09-03T23:58:52.536064Z",
            "url": "https://files.pythonhosted.org/packages/5b/bb/5a567fe0c0ae5ef34a1d547666ff712ef5d16ac6d3f5fae1dad315dda652/fastaparser-1.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-09-03 23:58:52",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Kronopt",
    "github_project": "FastaParser",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "fastaparser"
}
        
Elapsed time: 0.21747s