Skip to content

Commit 4ad8eb6

Browse files
committed
Added an example for FastaStreamer
1 parent 219af9a commit 4ad8eb6

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

core/readwrite.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,27 @@ BioJava can also be used to parse large FASTA files. The example below can parse
7979
}
8080
```
8181

82+
BioJava can also process large FASTA files using the Java streams API.
83+
84+
```java
85+
FastaStreamer
86+
.from(path)
87+
.stream()
88+
.forEach(sequence -> System.out.printf("%s -> %ss\n", sequence.getOriginalHeader(), sequence.getSequenceAsString()));
89+
```
90+
91+
If you need to specify a header parser other that `GenericFastaHeaderParser` or a sequence creater other than a
92+
`ProteinSequenceCreator`, these can be specified before streaming the contents as follows:
93+
94+
```java
95+
FastaStreamer
96+
.from(path)
97+
.withHeaderParser(new PlainFastaHeaderParser<>())
98+
.withSequenceCreator(new CasePreservingProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet()))
99+
.stream()
100+
.forEach(sequence -> System.out.printf("%s -> %ss\n", sequence.getOriginalHeader(), sequence.getSequenceAsString()));
101+
```
102+
82103

83104

84105
<!--automatically generated footer-->

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy