X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FBLCFile.java;h=ceeac648b12964b1f95944155d17f63cfe101e18;hb=7f88b4e40175e3f47d35786ba1cb44d1ae79cce8;hp=074e6ceb46feaeacfc5f48837aaa054dec2c8d31;hpb=efc31b4a8d5cee63555586804a2b79c06bdb5a14;p=jalview.git diff --git a/src/jalview/io/BLCFile.java b/src/jalview/io/BLCFile.java index 074e6ce..ceeac64 100755 --- a/src/jalview/io/BLCFile.java +++ b/src/jalview/io/BLCFile.java @@ -1,6 +1,6 @@ /* * Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle +* 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 @@ -42,15 +42,6 @@ public class BLCFile extends AlignFile { } - /** - * Creates a new BLCFile object. - * - * @param inStr DOCUMENT ME! - */ - public BLCFile(String inStr) - { - super(inStr); - } /** * Creates a new BLCFile object. @@ -77,7 +68,7 @@ public class BLCFile extends AlignFile /** * DOCUMENT ME! */ - public void parse() + public void parse() throws IOException { boolean idsFound = false; Vector ids = new Vector(); @@ -87,8 +78,6 @@ public class BLCFile extends AlignFile String line = null; - try - { do { line = nextLine(); @@ -105,60 +94,19 @@ public class BLCFile extends AlignFile if (abracket > -1) { - if (line.indexOf(" ") > -1) // - { - ///Colur it be this format? - //>54402046 0 1 137 137: - // or this?? - // 1 >L1H14 30539 343 - try - { - ids.addElement(line.substring(abracket + 1, - line.indexOf(" ", abracket + 1))); - - // remove p Value - line = line.substring(abracket + 1); - line = line.substring(line.indexOf(" ") + 1); - line = line.trim(); - line = line.substring(line.indexOf(" ") + 1); - line = line.trim(); - - int value = Integer.parseInt(line.substring(0, - line.indexOf(" "))); - starts.addElement(value + ""); - line = line.substring(line.indexOf(" ") + 1); - line = line.trim(); - value = Integer.parseInt(line.substring(0, - line.indexOf(" "))); - ends.addElement(value + ""); - } - catch (Exception ex) - { - System.err.println("Error during blockfile read."); - ex.printStackTrace(); - starts.addElement("0"); - ends.addElement("0"); - } - } - else - { - if (line.indexOf("/") > -1) - { - 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)); - } - else - { - ids.addElement(line.substring(abracket + 1)); - starts.addElement("0"); - ends.addElement("0"); - } - } + if (line.indexOf(" ") > -1) // + { + line = line.substring(abracket + 1, + line.indexOf(" ", abracket + 1)); + } + else + line = line.substring(abracket+1); + + + Sequence seq = parseId(line); + ids.addElement(seq.getName()); + starts.addElement(seq.getStart() + ""); + ends.addElement(seq.getEnd() + ""); } } while (!idsFound); @@ -187,17 +135,23 @@ public class BLCFile extends AlignFile for (int i = 0; i < ids.size(); i++) { - Sequence newSeq = new Sequence(ids.elementAt(i).toString(), - seqstrings[i].toString(), - Integer.parseInt(starts.elementAt(i).toString()), - Integer.parseInt(ends.elementAt(i).toString())); + Sequence newSeq = new Sequence(ids.elementAt(i).toString(), + seqstrings[i].toString(), + Integer.parseInt(starts.elementAt(i). + toString()), + Integer.parseInt(ends.elementAt(i).toString())); + + if (!isValidProteinSequence(newSeq.getSequence())) + { + throw new IOException(AppletFormatAdapter.INVALID_CHARACTERS + +" : "+ newSeq.getName() + +" : "+invalidCharacter); + + } + seqs.addElement(newSeq); } - } - catch (Exception ex) - { - ex.printStackTrace(); - } + } /** @@ -217,17 +171,22 @@ public class BLCFile extends AlignFile * * @return DOCUMENT ME! */ - public static String print(SequenceI[] s) + public String print(SequenceI[] s) { 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; while ((i < s.length) && (s[i] != null)) { - out.append(">" + s[i].getName() + "/" + s[i].getStart() + "-" + - s[i].getEnd() + "\n"); + out.append(">" + printId(s[i]) +"\n"); if (s[i].getSequence().length() > max) {