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
21 import jalview.datamodel.*;
\r
32 * @version $Revision$
\r
34 public class BLCFile extends AlignFile
\r
39 * Creates a new BLCFile object.
\r
46 * Creates a new BLCFile object.
\r
48 * @param inStr DOCUMENT ME!
\r
50 public BLCFile(String inStr)
\r
56 * Creates a new BLCFile object.
\r
58 * @param inFile DOCUMENT ME!
\r
59 * @param type DOCUMENT ME!
\r
61 * @throws IOException DOCUMENT ME!
\r
63 public BLCFile(String inFile, String type) throws IOException
\r
65 super(inFile, type);
\r
71 public void initData()
\r
74 titles = new Vector();
\r
80 public void parse() throws IOException
\r
82 boolean idsFound = false;
\r
83 Vector ids = new Vector();
\r
84 StringBuffer[] seqstrings;
\r
85 Vector starts = new Vector();
\r
86 Vector ends = new Vector();
\r
95 if (line.indexOf("*") > -1)
\r
102 int abracket = line.indexOf(">");
\r
106 if (line.indexOf(" ") > -1) //
\r
108 line = line.substring(abracket + 1,
\r
109 line.indexOf(" ", abracket + 1));
\r
112 line = line.substring(abracket+1);
\r
115 Sequence seq = parseId(line);
\r
116 ids.addElement(seq.getName());
\r
117 starts.addElement(seq.getStart() + "");
\r
118 ends.addElement(seq.getEnd() + "");
\r
123 int starCol = line.indexOf("*");
\r
124 seqstrings = new StringBuffer[ids.size()];
\r
126 for (int i = 0; i < ids.size(); i++)
\r
128 if (seqstrings[i] == null)
\r
130 seqstrings[i] = new StringBuffer();
\r
134 while ((line = nextLine()).indexOf("*") == -1)
\r
136 for (int i = 0; i < ids.size(); i++)
\r
138 if (line.length() > (i + starCol))
\r
140 seqstrings[i].append(line.charAt(i + starCol));
\r
145 for (int i = 0; i < ids.size(); i++)
\r
147 Sequence newSeq = new Sequence(ids.elementAt(i).toString(),
\r
148 seqstrings[i].toString(),
\r
149 Integer.parseInt(starts.elementAt(i).
\r
151 Integer.parseInt(ends.elementAt(i).toString()));
\r
153 if (!isValidProteinSequence(newSeq.getSequence()))
\r
155 throw new IOException(AppletFormatAdapter.INVALID_CHARACTERS
\r
156 +" : "+ newSeq.getName()
\r
157 +" : "+invalidCharacter);
\r
161 seqs.addElement(newSeq);
\r
169 * @return DOCUMENT ME!
\r
171 public String print()
\r
173 return print(getSeqsAsArray());
\r
179 * @param s DOCUMENT ME!
\r
181 * @return DOCUMENT ME!
\r
183 public String print(SequenceI[] s)
\r
185 StringBuffer out = new StringBuffer();
\r
187 * A general parser for ids. Will look for dbrefs in
\r
188 * Uniprot format source|id
\r
189 * And also Jalview /start-end
\r
191 * @String id Id to be parsed
\r
196 while ((i < s.length) && (s[i] != null))
\r
198 out.append(">" + printId(s[i]) +"\n");
\r
200 if (s[i].getSequence().length() > max)
\r
202 max = s[i].getSequence().length();
\r
208 out.append("* iteration 1\n");
\r
210 for (int j = 0; j < max; j++)
\r
214 while ((i < s.length) && (s[i] != null))
\r
216 if (s[i].getSequence().length() > j)
\r
218 out.append(s[i].getSequence().substring(j, j + 1));
\r
233 return out.toString();
\r