2 * Jalview - A Sequence Alignment Editor and Viewer
3 * Copyright (C) 2006 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
24 * <p>Description: </p>
26 * Read and write PileUp style MSF Files.
27 * This used to be the MSFFile class, and was written according to the EBI's idea
28 * of a subset of the MSF alignment format. But, that was updated to reflect current
29 * GCG style IO fashion, as found in Emboss (thanks David Martin!)
34 import jalview.datamodel.*;
35 import jalview.util.*;
37 public class PileUpfile extends MSFfile
41 * Creates a new MSFfile object.
49 * Creates a new MSFfile object.
51 * @param inFile DOCUMENT ME!
52 * @param type DOCUMENT ME!
54 * @throws IOException DOCUMENT ME!
56 public PileUpfile(String inFile, String type) throws IOException
63 * @return DOCUMENT ME!
67 return print(getSeqsAsArray());
71 public String print(SequenceI[] s)
73 StringBuffer out = new StringBuffer("PileUp\n\n");
80 int[] checksums = new int[s.length];
83 checksums[i] = checkSum(s[i].getSequence());
84 bigChecksum += checksums[i];
88 out.append(" MSF: " + s[0].getSequence().length() +
89 " Type: P Check: " + bigChecksum%10000 + " ..\n\n\n");
92 while ( (i < s.length) && (s[i] != null))
94 String seq = s[i].getSequence();
95 out.append(" Name: " + printId(s[i]) +
97 s[i].getSequence().length() + " Check: " + checksums[i] +
100 if (seq.length() > max)
105 if (s[i].getName().length() > maxid)
107 maxid = s[i].getName().length();
119 out.append("\n\n//\n\n");
123 int nochunks = (max / len) + 1;
125 if ( (max % len) == 0)
130 for (i = 0; i < nochunks; i++)
134 while ( (j < s.length) && (s[j] != null))
136 String name = printId(s[j]);
138 out.append(new Format("%-" + maxid + "s").form(name + " "));
140 for (int k = 0; k < 5; k++)
142 int start = (i * 50) + (k * 10);
143 int end = start + 10;
145 if ( (end < s[j].getSequence().length()) &&
146 (start < s[j].getSequence().length()))
148 out.append(s[j].getSequence().substring(start, end));
161 if (start < s[j].getSequence().length())
163 out.append(s[j].getSequence().substring(start));
182 return out.toString();