2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
32 * Read and write PileUp style MSF Files. This used to be the MSFFile class, and
33 * was written according to the EBI's idea of a subset of the MSF alignment
34 * format. But, that was updated to reflect current GCG style IO fashion, as
35 * found in Emboss (thanks David Martin!)
40 import jalview.datamodel.*;
41 import jalview.util.*;
43 public class PileUpfile extends MSFfile
47 * Creates a new MSFfile object.
54 * Creates a new MSFfile object.
64 public PileUpfile(String inFile, String type) throws IOException
69 public PileUpfile(FileParse source) throws IOException
77 * @return DOCUMENT ME!
81 return print(getSeqsAsArray());
84 public String print(SequenceI[] s)
86 StringBuffer out = new StringBuffer("PileUp");
95 int[] checksums = new int[s.length];
98 checksums[i] = checkSum(s[i].getSequenceAsString());
99 bigChecksum += checksums[i];
103 out.append(" MSF: " + s[0].getSequence().length
104 + " Type: P Check: " + bigChecksum % 10000 + " ..");
110 while ((i < s.length) && (s[i] != null))
112 String seq = s[i].getSequenceAsString();
113 out.append(" Name: " + printId(s[i]) + " oo Len: " + seq.length()
114 + " Check: " + checksums[i] + " Weight: 1.00");
117 if (seq.length() > max)
122 if (s[i].getName().length() > maxid)
124 maxid = s[i].getName().length();
144 int nochunks = (max / len) + 1;
146 if ((max % len) == 0)
151 for (i = 0; i < nochunks; i++)
155 while ((j < s.length) && (s[j] != null))
157 String name = printId(s[j]);
159 out.append(new Format("%-" + maxid + "s").form(name + " "));
161 for (int k = 0; k < 5; k++)
163 int start = (i * 50) + (k * 10);
164 int end = start + 10;
166 if ((end < s[j].getSequence().length)
167 && (start < s[j].getSequence().length))
169 out.append(s[j].getSequence(start, end));
182 if (start < s[j].getSequence().length)
184 out.append(s[j].getSequenceAsString().substring(start));
203 return out.toString();