1 /* Jalview - a java multiple alignment editor
\r
2 * Copyright (C) 1998 Michele Clamp
\r
4 * This program is free software; you can redistribute it and/or
\r
5 * modify it under the terms of the GNU General Public License
\r
6 * as published by the Free Software Foundation; either version 2
\r
7 * of the License, or (at your option) any later version.
\r
9 * This program is distributed in the hope that it will be useful,
\r
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
12 * GNU General Public License for more details.
\r
14 * You should have received a copy of the GNU General Public License
\r
15 * along with this program; if not, write to the Free Software
\r
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
\r
20 import jalview.datamodel.*;
\r
25 import java.awt.Font;
\r
27 public class BLCFile extends AlignFile {
\r
34 public BLCFile(String inStr) {
\r
38 public void initData() {
\r
40 titles = new Vector();
\r
43 public BLCFile(String inFile, String type) throws IOException {
\r
50 boolean idsFound=false;
\r
51 Vector ids = new Vector();
\r
52 StringBuffer seqstrings [];
\r
53 Vector starts = new Vector();
\r
54 Vector ends = new Vector();
\r
62 if (line.indexOf("*") > -1)
\r
68 int abracket = line.indexOf(">");
\r
73 if(line.indexOf(" ")>-1)
\r
75 ids.addElement(line.substring(abracket+1, line.indexOf(" ", abracket+1)));
\r
76 starts.addElement("0");
\r
77 ends.addElement("0");
\r
81 ids.addElement( line.substring(abracket + 1, line.indexOf("/")));
\r
82 line = line.substring(line.indexOf("/") + 1);
\r
83 starts.addElement(line.substring(0, line.indexOf("-")));
\r
84 ends.addElement(line.substring(line.indexOf("-") + 1));
\r
89 int starCol = line.indexOf("*");
\r
90 seqstrings = new StringBuffer[ids.size()];
\r
91 for(int i=0; i<ids.size(); i++)
\r
93 if(seqstrings[i]==null)
\r
94 seqstrings[i] = new StringBuffer();
\r
97 while ((line = nextLine()).indexOf("*")==-1)
\r
99 for(int i=0; i<ids.size(); i++)
\r
101 if(line.length()>i+starCol)
\r
102 seqstrings[i].append(line.charAt(i + starCol));
\r
106 for(int i=0; i<ids.size(); i++)
\r
108 Sequence newSeq = new Sequence(ids.elementAt(i).toString(),
\r
109 seqstrings[i].toString(),
\r
110 Integer.parseInt(starts.elementAt(i).toString()),
\r
111 Integer.parseInt(ends.elementAt(i).toString()));
\r
112 seqs.addElement(newSeq);
\r
115 }catch(Exception ex){ex.printStackTrace();}
\r
118 public String print() {
\r
119 return print(getSeqsAsArray());
\r
121 public static String print(SequenceI[] s) {
\r
122 StringBuffer out = new StringBuffer();
\r
126 while (i < s.length && s[i] != null) {
\r
127 out.append(">" + s[i].getName() + "/" + s[i].getStart() + "-" + s[i].getEnd() + "\n");
\r
128 if (s[i].getSequence().length() > max) { max = s[i].getSequence().length();}
\r
132 out.append("* iteration 1\n");
\r
133 for (int j = 0; j < max; j++) {
\r
135 while (i < s.length && s[i] != null) {
\r
136 if(s[i].getSequence().length()>j )
\r
137 out.append(s[i].getSequence().substring(j,j+1));
\r
145 return out.toString();
\r