{"id":17372893,"url":"https://github.com/kronopt/fastaparser","last_synced_at":"2025-04-15T05:51:36.215Z","repository":{"id":57428458,"uuid":"161213781","full_name":"Kronopt/FastaParser","owner":"Kronopt","description":"A Python FASTA file Parser and Writer.","archived":false,"fork":false,"pushed_at":"2022-09-03T23:57:08.000Z","size":229,"stargazers_count":17,"open_issues_count":4,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T06:19:52.715Z","etag":null,"topics":["fasta","fasta-parser","fasta-reader","fasta-writer","parser","python","python-3"],"latest_commit_sha":null,"homepage":"https://fastaparser.readthedocs.io/en/latest/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Kronopt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/contributing.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"ko_fi":"kronopt"}},"created_at":"2018-12-10T17:45:19.000Z","updated_at":"2023-11-15T23:38:18.000Z","dependencies_parsed_at":"2022-09-02T15:31:37.095Z","dependency_job_id":null,"html_url":"https://github.com/Kronopt/FastaParser","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kronopt%2FFastaParser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kronopt%2FFastaParser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kronopt%2FFastaParser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kronopt%2FFastaParser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kronopt","download_url":"https://codeload.github.com/Kronopt/FastaParser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249016316,"owners_count":21198832,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fasta","fasta-parser","fasta-reader","fasta-writer","parser","python","python-3"],"created_at":"2024-10-16T02:04:36.398Z","updated_at":"2025-04-15T05:51:36.191Z","avatar_url":"https://github.com/Kronopt.png","language":"Python","funding_links":["https://ko-fi.com/kronopt"],"categories":[],"sub_categories":[],"readme":"# 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\u003e\u003e\u003e import fastaparser\n\u003e\u003e\u003e 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\u003e\u003e\u003e import fastaparser\n\u003e\u003e\u003e 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: \u003esp|P04439|HLAA_HUMAN HLA class I histocompatibility antigen, A alpha c...\nSequence: MAVMAPRTLLLLLSGALALTQTWAGSHSMRYFFTSVSRPGRGEPRFIAVGYVDDTQFVRFDSDAASQRM...\n\nHeader: \u003esp|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\u003e\u003e\u003e import fastaparser\n\u003e\u003e\u003e 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\u003e\u003e\u003e import fastaparser\n\u003e\u003e\u003e 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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkronopt%2Ffastaparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkronopt%2Ffastaparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkronopt%2Ffastaparser/lists"}