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
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 Vector ids = new Vector();
\r
75 StringBuffer[] seqstrings;
\r
76 Vector starts = new Vector();
\r
77 Vector ends = new Vector();
\r
86 if (line.indexOf("*") > -1)
\r
93 int abracket = line.indexOf(">");
\r
97 if (line.indexOf(" ") > -1) //
\r
99 line = line.substring(abracket + 1,
\r
100 line.indexOf(" ", abracket + 1));
\r
103 line = line.substring(abracket+1);
\r
106 Sequence seq = parseId(line);
\r
107 ids.addElement(seq.getName());
\r
108 starts.addElement(seq.getStart() + "");
\r
109 ends.addElement(seq.getEnd() + "");
\r
114 int starCol = line.indexOf("*");
\r
115 seqstrings = new StringBuffer[ids.size()];
\r
117 for (int i = 0; i < ids.size(); i++)
\r
119 if (seqstrings[i] == null)
\r
121 seqstrings[i] = new StringBuffer();
\r
125 while ((line = nextLine()).indexOf("*") == -1)
\r
127 for (int i = 0; i < ids.size(); i++)
\r
129 if (line.length() > (i + starCol))
\r
131 seqstrings[i].append(line.charAt(i + starCol));
\r
136 for (int i = 0; i < ids.size(); i++)
\r
138 Sequence newSeq = new Sequence(ids.elementAt(i).toString(),
\r
139 seqstrings[i].toString(),
\r
140 Integer.parseInt(starts.elementAt(i).
\r
142 Integer.parseInt(ends.elementAt(i).toString()));
\r
144 if (!isValidProteinSequence(newSeq.getSequence()))
\r
146 throw new IOException(AppletFormatAdapter.INVALID_CHARACTERS
\r
147 +" : "+ newSeq.getName()
\r
148 +" : "+invalidCharacter);
\r
152 seqs.addElement(newSeq);
\r
160 * @return DOCUMENT ME!
\r
162 public String print()
\r
164 return print(getSeqsAsArray());
\r
170 * @param s DOCUMENT ME!
\r
172 * @return DOCUMENT ME!
\r
174 public String print(SequenceI[] s)
\r
176 StringBuffer out = new StringBuffer();
\r
178 * A general parser for ids. Will look for dbrefs in
\r
179 * Uniprot format source|id
\r
180 * And also Jalview /start-end
\r
182 * @String id Id to be parsed
\r
187 while ((i < s.length) && (s[i] != null))
\r
189 out.append(">" + printId(s[i]) +"\n");
\r
191 if (s[i].getSequence().length() > max)
\r
193 max = s[i].getSequence().length();
\r
199 out.append("* iteration 1\n");
\r
201 for (int j = 0; j < max; j++)
\r
205 while ((i < s.length) && (s[i] != null))
\r
207 if (s[i].getSequence().length() > j)
\r
209 out.append(s[i].getSequence().substring(j, j + 1));
\r
224 return out.toString();
\r