X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FBLCFile.java;h=8958f7b9d5259d60b28173db9f6010ce65b968e0;hb=7157dfd20efd2e1db47db1ac12e879eb51c67b92;hp=8db0a9ad177152cb4d5fc1e903b8c4259d2e49e4;hpb=2bb0a2c4156ec75795c595df0c6300411557b066;p=jalview.git diff --git a/src/jalview/io/BLCFile.java b/src/jalview/io/BLCFile.java index 8db0a9a..8958f7b 100755 --- a/src/jalview/io/BLCFile.java +++ b/src/jalview/io/BLCFile.java @@ -1,5 +1,6 @@ -/* Jalview - a java multiple alignment editor - * Copyright (C) 1998 Michele Clamp +/* + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -13,55 +14,76 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ package jalview.io; -import jalview.datamodel.*; - import java.io.*; import java.util.*; -import java.net.*; -import java.awt.Font; -public class BLCFile extends AlignFile { +import jalview.datamodel.*; +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class BLCFile + extends AlignFile +{ Vector titles; + /** + * Creates a new BLCFile object. + */ public BLCFile() - {} + { + } - public BLCFile(String inStr) { - super(inStr); + /** + * Creates a new BLCFile object. + * + * @param inFile DOCUMENT ME! + * @param type DOCUMENT ME! + * + * @throws IOException DOCUMENT ME! + */ + public BLCFile(String inFile, String type) + throws IOException + { + super(inFile, type); } - public void initData() { + /** + * DOCUMENT ME! + */ + public void initData() + { super.initData(); titles = new Vector(); } - public BLCFile(String inFile, String type) throws IOException { - super(inFile,type); - } - - + /** + * DOCUMENT ME! + */ public void parse() + throws IOException { - boolean idsFound=false; - Vector ids = new Vector(); - StringBuffer seqstrings []; - Vector starts = new Vector(); - Vector ends = new Vector(); - - String line=null; - try{ - do{ + boolean idsFound = false; + StringBuffer[] seqstrings; + + String line = null; + + do + { line = nextLine(); // seek end of ids if (line.indexOf("*") > -1) { - idsFound=true; + idsFound = true; + break; } @@ -69,80 +91,118 @@ public class BLCFile extends AlignFile { if (abracket > -1) { + line = line.substring(abracket + 1); - if(line.indexOf(" ")>-1) - { - ids.addElement(line.substring(abracket+1, line.indexOf(" ", abracket+1))); - starts.addElement("0"); - ends.addElement("0"); - } - else - { - ids.addElement( line.substring(abracket + 1, line.indexOf("/"))); - line = line.substring(line.indexOf("/") + 1); - starts.addElement(line.substring(0, line.indexOf("-"))); - ends.addElement(line.substring(line.indexOf("-") + 1)); - } + Sequence seq = parseId(line); + seqs.addElement(seq); } - }while(!idsFound); + } + while (!idsFound); int starCol = line.indexOf("*"); - seqstrings = new StringBuffer[ids.size()]; - for(int i=0; ii+starCol) + if (line.length() > (i + starCol)) + { seqstrings[i].append(line.charAt(i + starCol)); + } } } - for(int i=0; i" + s[i].getName() + "/" + s[i].getStart() + "-" + s[i].getEnd() + "\n"); - if (s[i].getSequence().length() > max) { max = s[i].getSequence().length();} + + while ( (i < s.length) && (s[i] != null)) + { + out.append(">" + printId(s[i])); + if (s[i].getDescription() != null) + { + out.append(" " + s[i].getDescription()); + } + + out.append("\n"); + + if (s[i].getSequence().length > max) + { + max = s[i].getSequence().length; + } + i++; } - out.append("* iteration 1\n"); - for (int j = 0; j < max; j++) { - i=0; - while (i < s.length && s[i] != null) { - if(s[i].getSequence().length()>j ) - out.append(s[i].getSequence().substring(j,j+1)); - else - out.append("-"); - i++; + out.append("* iteration 1\n"); + + for (int j = 0; j < max; j++) + { + i = 0; + + while ( (i < s.length) && (s[i] != null)) + { + if (s[i].getSequence().length > j) + { + out.append(s[i].getSequenceAsString(j, j + 1)); + } + else + { + out.append("-"); } - out.append("\n"); + + i++; } + + out.append("\n"); + } + out.append("*\n"); - return out.toString(); + return out.toString(); } }