X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FBLCFile.java;h=8958f7b9d5259d60b28173db9f6010ce65b968e0;hb=7bc226b58110fa26d9dbd3f0c78095d06909ffc3;hp=624e134a0632d2a0f8f8e8c91df1726af590c707;hpb=dd74fc4938723fe5ec48d4e5fdcfbe58ac42a48d;p=jalview.git diff --git a/src/jalview/io/BLCFile.java b/src/jalview/io/BLCFile.java index 624e134..8958f7b 100755 --- a/src/jalview/io/BLCFile.java +++ b/src/jalview/io/BLCFile.java @@ -1,29 +1,27 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2006 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 -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ package jalview.io; -import jalview.datamodel.*; - import java.io.*; - import java.util.*; +import jalview.datamodel.*; /** * DOCUMENT ME! @@ -31,176 +29,180 @@ import java.util.*; * @author $author$ * @version $Revision$ */ -public class BLCFile extends AlignFile +public class BLCFile + extends AlignFile { - Vector titles; - - /** - * Creates a new BLCFile object. - */ - public BLCFile() + Vector titles; + + /** + * Creates a new BLCFile object. + */ + public BLCFile() + { + } + + /** + * 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); + } + + /** + * DOCUMENT ME! + */ + public void initData() + { + super.initData(); + titles = new Vector(); + } + + /** + * DOCUMENT ME! + */ + public void parse() + throws IOException + { + boolean idsFound = false; + StringBuffer[] seqstrings; + + String line = null; + + do { + line = nextLine(); + + // seek end of ids + if (line.indexOf("*") > -1) + { + idsFound = true; + + break; + } + + int abracket = line.indexOf(">"); + + if (abracket > -1) + { + line = line.substring(abracket + 1); + + Sequence seq = parseId(line); + seqs.addElement(seq); + } } + while (!idsFound); + int starCol = line.indexOf("*"); + seqstrings = new StringBuffer[seqs.size()]; - /** - * 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 + for (int i = 0; i < seqs.size(); i++) { - super(inFile, type); + if (seqstrings[i] == null) + { + seqstrings[i] = new StringBuffer(); + } } - /** - * DOCUMENT ME! - */ - public void initData() + while ( (line = nextLine()).indexOf("*") == -1) { - super.initData(); - titles = new Vector(); + for (int i = 0; i < seqs.size(); i++) + { + if (line.length() > (i + starCol)) + { + seqstrings[i].append(line.charAt(i + starCol)); + } + } } - /** - * DOCUMENT ME! - */ - public void parse() throws IOException + for (int i = 0; i < seqs.size(); i++) { - boolean idsFound = false; - StringBuffer[] seqstrings; - - String line = null; - - do - { - line = nextLine(); - - // seek end of ids - if (line.indexOf("*") > -1) - { - idsFound = true; - - break; - } - - int abracket = line.indexOf(">"); - - if (abracket > -1) - { - line = line.substring(abracket+1); - - Sequence seq = parseId(line); - seqs.addElement(seq); - } - } - while (!idsFound); - - int starCol = line.indexOf("*"); - seqstrings = new StringBuffer[seqs.size()]; - - for (int i = 0; i < seqs.size(); i++) - { - if (seqstrings[i] == null) - { - seqstrings[i] = new StringBuffer(); - } - } - - while ((line = nextLine()).indexOf("*") == -1) - { - for (int i = 0; i < seqs.size(); i++) - { - if (line.length() > (i + starCol)) - { - seqstrings[i].append(line.charAt(i + starCol)); - } - } - } - - for (int i = 0; i < seqs.size(); i++) - { - Sequence newSeq = (Sequence) seqs.elementAt(i); - - newSeq.setSequence(seqstrings[i].toString()); - } + Sequence newSeq = (Sequence) seqs.elementAt(i); + newSeq.setSequence(seqstrings[i].toString()); } + } + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String print() + { + return print(getSeqsAsArray()); + } + + /** + * DOCUMENT ME! + * + * @param s DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String print(SequenceI[] s) + { + StringBuffer out = new StringBuffer(); /** - * DOCUMENT ME! + * A general parser for ids. Will look for dbrefs in + * Uniprot format source|id + * And also Jalview /start-end * - * @return DOCUMENT ME! + * @String id Id to be parsed */ - public String print() - { - return print(getSeqsAsArray()); - } + int i = 0; + int max = -1; - /** - * DOCUMENT ME! - * - * @param s DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public String print(SequenceI[] s) + while ( (i < s.length) && (s[i] != null)) { - StringBuffer out = new StringBuffer(); - /** - * A general parser for ids. Will look for dbrefs in - * Uniprot format source|id - * And also Jalview /start-end - * - * @String id Id to be parsed - */ - int i = 0; - int max = -1; + out.append(">" + printId(s[i])); + if (s[i].getDescription() != null) + { + out.append(" " + s[i].getDescription()); + } - 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"); - out.append("\n"); + if (s[i].getSequence().length > max) + { + max = s[i].getSequence().length; + } - if (s[i].getSequence().length > max) - { - max = s[i].getSequence().length; - } + i++; + } - i++; - } + out.append("* iteration 1\n"); - out.append("* iteration 1\n"); + for (int j = 0; j < max; j++) + { + i = 0; - for (int j = 0; j < max; j++) + while ( (i < s.length) && (s[i] != null)) + { + if (s[i].getSequence().length > j) + { + out.append(s[i].getSequenceAsString(j, j + 1)); + } + else { - 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("-"); - } - - i++; - } - - out.append("\n"); + out.append("-"); } - out.append("*\n"); + i++; + } - return out.toString(); + out.append("\n"); } + + out.append("*\n"); + + return out.toString(); + } }