-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFASTAWriter.java
More file actions
48 lines (42 loc) · 913 Bytes
/
FASTAWriter.java
File metadata and controls
48 lines (42 loc) · 913 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import java.io.BufferedWriter;
/**
* Writes a list of sequences to a file in FASTA format.
*
* @author Alexander Herbig
*
*/
public class FASTAWriter
{
/**
* Writes a list of sequences to a file in FASTA format.
*
* @param bw the BufferedWriter writing the FASTA file
* @param fastaEntries list of FASTAEntry objects holding the sequences
* which are written to the FASTA file
* @throws Exception
*/
public static void write(BufferedWriter bw, String genomeID, String sequence) throws Exception
{
int charsInLine;
String tmpSeqString;
tmpSeqString=sequence;
bw.write(">"+genomeID);
bw.newLine();
charsInLine=0;
for(int i=0; i<tmpSeqString.length();i++)
{
bw.write(tmpSeqString.charAt(i));
charsInLine++;
if(charsInLine==60)
{
bw.newLine();
charsInLine=0;
}
}
if(charsInLine!=0)
{
bw.newLine();
}
bw.flush();
}
}