2 * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
3 * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
30 * Read and write PileUp style MSF Files. This used to be the MSFFile class, and
31 * was written according to the EBI's idea of a subset of the MSF alignment
32 * format. But, that was updated to reflect current GCG style IO fashion, as
33 * found in Emboss (thanks David Martin!)
38 import jalview.datamodel.*;
39 import jalview.util.*;
41 public class PileUpfile extends MSFfile
45 * Creates a new MSFfile object.
52 * Creates a new MSFfile object.
62 public PileUpfile(String inFile, String type) throws IOException
67 public PileUpfile(FileParse source) throws IOException
75 * @return DOCUMENT ME!
79 return print(getSeqsAsArray());
82 public String print(SequenceI[] s)
84 StringBuffer out = new StringBuffer("PileUp\n\n");
91 int[] checksums = new int[s.length];
94 checksums[i] = checkSum(s[i].getSequenceAsString());
95 bigChecksum += checksums[i];
99 out.append(" MSF: " + s[0].getSequence().length
100 + " Type: P Check: " + bigChecksum % 10000
104 while ((i < s.length) && (s[i] != null))
106 String seq = s[i].getSequenceAsString();
107 out.append(" Name: " + printId(s[i]) + " oo Len: " + seq.length()
108 + " Check: " + checksums[i] + " Weight: 1.00\n");
110 if (seq.length() > max)
115 if (s[i].getName().length() > maxid)
117 maxid = s[i].getName().length();
129 out.append("\n\n//\n\n");
133 int nochunks = (max / len) + 1;
135 if ((max % len) == 0)
140 for (i = 0; i < nochunks; i++)
144 while ((j < s.length) && (s[j] != null))
146 String name = printId(s[j]);
148 out.append(new Format("%-" + maxid + "s").form(name + " "));
150 for (int k = 0; k < 5; k++)
152 int start = (i * 50) + (k * 10);
153 int end = start + 10;
155 if ((end < s[j].getSequence().length)
156 && (start < s[j].getSequence().length))
158 out.append(s[j].getSequence(start, end));
171 if (start < s[j].getSequence().length)
173 out.append(s[j].getSequenceAsString().substring(start));
192 return out.toString();