1 /* Copyright (c) 2009 Peter Troshin
\r
3 * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0
\r
5 * This library is free software; you can redistribute it and/or modify it under the terms of the
\r
6 * Apache License version 2 as published by the Apache Software Foundation
\r
8 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
\r
9 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache
\r
10 * License for more details.
\r
12 * A copy of the license is in apache_license.txt. It is also available here:
\r
13 * @see: http://www.apache.org/licenses/LICENSE-2.0.txt
\r
15 * Any republication or derived work distributed in source code form
\r
16 * must include this copyright and license notice.
\r
19 package compbio.data.sequence;
\r
21 import java.io.IOException;
\r
22 import java.util.List;
\r
24 import compbio.util.FileUtil;
\r
26 public class FastaGeneratorManager {
\r
28 public static void main(String[] args) throws IOException {
\r
29 FastaSequenceGenerator fgen = new FastaSequenceGenerator(
\r
30 FastaSequenceGenerator.SeqType.PROTEIN, 50);
\r
32 List<FastaSequence> fslist = fgen.generateFasta(400);
\r
33 writeToFile(fslist, "SmallProtein.fasta");
\r
35 fgen = new FastaSequenceGenerator(
\r
36 FastaSequenceGenerator.SeqType.PROTEIN, 200);
\r
38 fslist = fgen.generateFasta(500);
\r
39 writeToFile(fslist, "200x500Protein.fasta");
\r
41 fgen = new FastaSequenceGenerator(FastaSequenceGenerator.SeqType.DNA,
\r
43 fslist = fgen.generateFasta(3000);
\r
44 writeToFile(fslist, "1000x3000Dna.fasta");
\r
46 fgen = new FastaSequenceGenerator(FastaSequenceGenerator.SeqType.DNA,
\r
48 fslist = fgen.generateFasta(300);
\r
49 writeToFile(fslist, "50000x300Dna.fasta");
\r
50 System.out.println("Done");
\r
53 static void writeToFile(List<FastaSequence> fastalist, String filepath)
\r
54 throws IOException {
\r
55 StringBuilder sb = new StringBuilder();
\r
56 for (FastaSequence fs : fastalist) {
\r
57 sb.append(fs.getOnelineFasta() + "\n");
\r
59 FileUtil.writeToFile(sb.toString(), filepath);
\r