2 * Jalview - A Sequence Alignment Editor and Viewer
\r
3 * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\r
5 * This program is free software; you can redistribute it and/or
\r
6 * modify it under the terms of the GNU General Public License
\r
7 * as published by the Free Software Foundation; either version 2
\r
8 * of the License, or (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful,
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 * GNU General Public License for more details.
\r
15 * You should have received a copy of the GNU General Public License
\r
16 * along with this program; if not, write to the Free Software
\r
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
\r
24 * <p>Description: </p>
\r
26 * Read and write PileUp style MSF Files.
\r
27 * This used to be the MSFFile class, and was written according to the EBI's idea
\r
28 * of a subset of the MSF alignment format. But, that was updated to reflect current
\r
29 * GCG style IO fashion, as found in Emboss (thanks David Martin!)
\r
34 import jalview.datamodel.*;
\r
35 import jalview.util.*;
\r
37 public class PileUpfile extends MSFfile
\r
41 * Creates a new MSFfile object.
\r
49 * Creates a new MSFfile object.
\r
51 * @param inFile DOCUMENT ME!
\r
52 * @param type DOCUMENT ME!
\r
54 * @throws IOException DOCUMENT ME!
\r
56 public PileUpfile(String inFile, String type) throws IOException
\r
58 super(inFile, type);
\r
63 * @return DOCUMENT ME!
\r
65 public String print()
\r
67 return print(getSeqsAsArray());
\r
71 public String print(SequenceI[] s)
\r
73 StringBuffer out = new StringBuffer("PileUp\n\n");
\r
79 int bigChecksum = 0;
\r
80 int[] checksums = new int[s.length];
\r
81 while (i < s.length)
\r
83 checksums[i] = checkSum(s[i].getSequence());
\r
84 bigChecksum += checksums[i];
\r
88 out.append(" MSF: " + s[0].getSequence().length() +
\r
89 " Type: P Check: " + bigChecksum%10000 + " ..\n\n\n");
\r
92 while ( (i < s.length) && (s[i] != null))
\r
94 String seq = s[i].getSequence();
\r
95 out.append(" Name: " + printId(s[i]) +
\r
97 s[i].getSequence().length() + " Check: " + checksums[i] +
\r
100 if (seq.length() > max)
\r
102 max = seq.length();
\r
105 if (s[i].getName().length() > maxid)
\r
107 maxid = s[i].getName().length();
\r
119 out.append("\n\n//\n\n");
\r
123 int nochunks = (max / len) + 1;
\r
125 if ( (max % len) == 0)
\r
130 for (i = 0; i < nochunks; i++)
\r
134 while ( (j < s.length) && (s[j] != null))
\r
136 String name = printId(s[j]);
\r
138 out.append(new Format("%-" + maxid + "s").form(name + " "));
\r
140 for (int k = 0; k < 5; k++)
\r
142 int start = (i * 50) + (k * 10);
\r
143 int end = start + 10;
\r
145 if ( (end < s[j].getSequence().length()) &&
\r
146 (start < s[j].getSequence().length()))
\r
148 out.append(s[j].getSequence().substring(start, end));
\r
161 if (start < s[j].getSequence().length())
\r
163 out.append(s[j].getSequence().substring(start));
\r
182 return out.toString();
\r