Skip to content

Commit 3fa9a96

Browse files
committed
Update README.md
1 parent 0005cd3 commit 3fa9a96

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ $ pip install fastaparser
1515
```
1616

1717
## Usage
18+
19+
### Read FASTA files
1820
Generate python objects from FASTA files:
21+
1922
```Python
2023
>>> import fastaparser
2124
>>> with open("fasta_file.fasta") as fasta_file:
@@ -54,6 +57,27 @@ Header: >sp|P15822|ZEP1_HUMAN Zinc finger protein 40 OS=Homo sapiens OX=9606 GN.
5457
Sequence: MPRTKQIHPRNLRDKIEEAQKELNGAEVSKKEILQAGVKGTSESLKGVKRKKIVAENHLKKIPKSPLRN...
5558
```
5659

60+
### Write FASTA files
61+
Create FASTA files from FastaSequence objects:
62+
```Python
63+
>>> import fastaparser
64+
>>> with open("fasta_file.fasta", 'w') as fasta_file:
65+
writer = fastaparser.Writer(fasta_file)
66+
fasta_sequence = fastaparser.FastaSequence(
67+
sequence='ACTGCTGCTAGCTAGC',
68+
id='id123',
69+
description='test sequence'
70+
)
71+
writer.writefasta(fasta_sequence)
72+
```
73+
or single header and sequence strings:
74+
```Python
75+
>>> import fastaparser
76+
>>> with open("fasta_file.fasta", 'w') as fasta_file:
77+
writer = fastaparser.Writer(fasta_file)
78+
writer.writefasta(('id123 test sequence', 'ACTGCTGCTAGCTAGC'))
79+
```
80+
5781
## Documentation
5882
Documentation for FastaParser is available here: [fastaparser.rtfd.io](https://fastaparser.readthedocs.io/en/latest/)
5983

0 commit comments

Comments
 (0)