11# FastaParser
2+
3+ [ ![ pypi] ( https://img.shields.io/pypi/v/fastaparser " pypi package ")] ( https://pypi.org/project/fastaparser )
4+ [ ![ python versions] ( https://img.shields.io/pypi/pyversions/fastaparser " supported python versions ")] ( https://pypi.org/project/fastaparser )
5+ [ ![ downloads] ( https://img.shields.io/pypi/dm/fastaparser " pypi downloads ")] ( https://pypi.org/project/fastaparser )
6+ [ ![ build status] ( https://github.com/Kronopt/FastaParser/workflows/CI/badge.svg " build status ")] ( https://github.com/Kronopt/FastaParser/actions?query=workflow%3ACI )
7+ [ ![ coverage] ( https://codecov.io/gh/Kronopt/FastaParser/branch/master/graph/badge.svg " code coverage ")] ( https://codecov.io/gh/Kronopt/FastaParser )
8+ [ ![ known vulnerabilities] ( https://snyk.io/test/github/Kronopt/FastaParser/badge.svg?targetFile=requirements-dev.txt " known vulnerabilities ")] ( https://snyk.io/test/github/Kronopt/FastaParser?targetFile=requirements-dev.txt )
9+ [ ![ license] ( https://img.shields.io/pypi/l/fastaparser " license ")] ( https://github.com/Kronopt/fastaparser/blob/master/LICENSE )
10+
211A python FASTA parser
312
13+ ## Installation
14+ ``` sh
15+ $ pip install fastaparser
16+ ```
17+
18+ ## Usage
19+ Generate python objets from FASTA files:
420``` Python
521>> > import fastaparser
622>> > with open (" fasta_file.fasta" ) as fasta_file:
7- ... parser = fastaparser.Reader(fasta_file)
8- ... for seq in parser:
9- ... print (seq.id, seq.description)
23+ parser = fastaparser.Reader(fasta_file)
24+ for seq in parser:
25+ # seq is a FastaSequence object
26+ print (' ID:' , seq.id)
27+ print (' Description:' , seq.description)
28+ print (' Sequence:' , seq.sequence_as_string())
29+ print ()
1030
11- HSBGPG Human gene for bone gla protein (BGP )
12- HSGLTH1 Human theta 1 - globin gene
31+ ID : sp| P04439| HLAA_HUMAN
32+ Description: HLA class I histocompatibility antigen, A alpha chain OS = Homo sapi...
33+ Sequence: MAVMAPRTLLLLLSGALALTQTWAGSHSMRYFFTSVSRPGRGEPRFIAVGYVDDTQFVRFDSDAASQRM ...
34+
35+ ID : sp| P15822| ZEP1_HUMAN
36+ Description: Zinc finger protein 40 OS = Homo sapiens OX = 9606 GN = HIVEP1 PE = 1 SV = 3 ...
37+ Sequence: MPRTKQIHPRNLRDKIEEAQKELNGAEVSKKEILQAGVKGTSESLKGVKRKKIVAENHLKKIPKSPLRN ...
1338```
1439
15- # ### Work in Progress
16- * PyPi package
40+ or just parse FASTA headers and sequences, which is much faster but less feature rich:
41+ ``` Python
42+ >> > import fastaparser
43+ >> > with open (" fasta_file.fasta" ) as fasta_file:
44+ parser = fastaparser.Reader(fasta_file, parse_method = ' quick' )
45+ for seq in parser:
46+ # seq is a namedtuple('Fasta', ['header', 'sequence'])
47+ print (' Header:' , seq.header)
48+ print (' Sequence:' , seq.sequence)
49+ print ()
50+
51+ Header: > sp| P04439| HLAA_HUMAN HLA class I histocompatibility antigen, A alpha c...
52+ Sequence: MAVMAPRTLLLLLSGALALTQTWAGSHSMRYFFTSVSRPGRGEPRFIAVGYVDDTQFVRFDSDAASQRM ...
53+
54+ Header: > sp| P15822| ZEP1_HUMAN Zinc finger protein 40 OS = Homo sapiens OX = 9606 GN ...
55+ Sequence: MPRTKQIHPRNLRDKIEEAQKELNGAEVSKKEILQAGVKGTSESLKGVKRKKIVAENHLKKIPKSPLRN ...
56+ ```
57+
58+ ## Documentation
59+ Documentation for FastaParser is available here: [ fastaparser.rtfd.io] ( https://fastaparser.readthedocs.io/en/latest/ )
60+
61+ ## To do
1762* Documentation (readthedocs)
1863 * Home
1964 * Installation
@@ -24,7 +69,6 @@ HSGLTH1 Human theta 1-globin gene
2469 * Authors
2570 * History
2671* Conda package (?)
27- * README
2872
2973#### Maybe
3074* Identify FASTA ID's
0 commit comments