2 * Jalview - A Sequence Alignment Editor and Viewer
\r
3 * Copyright (C) 2006 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
21 import jalview.datamodel.*;
\r
32 * @version $Revision$
\r
34 public class BLCFile extends AlignFile
\r
39 * Creates a new BLCFile object.
\r
47 * Creates a new BLCFile object.
\r
49 * @param inFile DOCUMENT ME!
\r
50 * @param type DOCUMENT ME!
\r
52 * @throws IOException DOCUMENT ME!
\r
54 public BLCFile(String inFile, String type) throws IOException
\r
56 super(inFile, type);
\r
62 public void initData()
\r
65 titles = new Vector();
\r
71 public void parse() throws IOException
\r
73 boolean idsFound = false;
\r
74 StringBuffer[] seqstrings;
\r
83 if (line.indexOf("*") > -1)
\r
90 int abracket = line.indexOf(">");
\r
94 line = line.substring(abracket+1);
\r
96 Sequence seq = parseId(line);
\r
97 seqs.addElement(seq);
\r
102 int starCol = line.indexOf("*");
\r
103 seqstrings = new StringBuffer[seqs.size()];
\r
105 for (int i = 0; i < seqs.size(); i++)
\r
107 if (seqstrings[i] == null)
\r
109 seqstrings[i] = new StringBuffer();
\r
113 while ((line = nextLine()).indexOf("*") == -1)
\r
115 for (int i = 0; i < seqs.size(); i++)
\r
117 if (line.length() > (i + starCol))
\r
119 seqstrings[i].append(line.charAt(i + starCol));
\r
124 for (int i = 0; i < seqs.size(); i++)
\r
126 Sequence newSeq = (Sequence) seqs.elementAt(i);
\r
128 if (!isValidProteinSequence(newSeq.getSequence()))
\r
130 throw new IOException(AppletFormatAdapter.INVALID_CHARACTERS
\r
131 +" : "+ newSeq.getName()
\r
132 +" : "+invalidCharacter);
\r
135 newSeq.setSequence(seqstrings[i].toString());
\r
143 * @return DOCUMENT ME!
\r
145 public String print()
\r
147 return print(getSeqsAsArray());
\r
153 * @param s DOCUMENT ME!
\r
155 * @return DOCUMENT ME!
\r
157 public String print(SequenceI[] s)
\r
159 StringBuffer out = new StringBuffer();
\r
161 * A general parser for ids. Will look for dbrefs in
\r
162 * Uniprot format source|id
\r
163 * And also Jalview /start-end
\r
165 * @String id Id to be parsed
\r
170 while ((i < s.length) && (s[i] != null))
\r
172 out.append(">" + printId(s[i]));
\r
173 if(s[i].getDescription()!=null)
\r
174 out.append(" "+s[i].getDescription());
\r
178 if (s[i].getSequence().length > max)
\r
180 max = s[i].getSequence().length;
\r
186 out.append("* iteration 1\n");
\r
188 for (int j = 0; j < max; j++)
\r
192 while ((i < s.length) && (s[i] != null))
\r
194 if (s[i].getSequence().length > j)
\r
196 out.append(s[i].getSequenceAsString(j, j + 1));
\r
211 return out.toString();
\r