X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fio%2FBLCFile.java;h=56d40f9f6109752cbc93aacceea910f89b98c8ee;hb=2535623533691d27fb7a23aef13d0f4f13be0a68;hp=ab41f08a7b8b8320453cc4a0f7a95a6ae84a2e48;hpb=bacb105d85f7d068c8cd643cd337b832aeb80343;p=jalview.git diff --git a/src/jalview/io/BLCFile.java b/src/jalview/io/BLCFile.java index ab41f08..56d40f9 100755 --- a/src/jalview/io/BLCFile.java +++ b/src/jalview/io/BLCFile.java @@ -77,7 +77,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 +87,6 @@ public class BLCFile extends AlignFile String line = null; - try - { do { line = nextLine(); @@ -105,60 +103,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("1"); - ends.addElement("-1"); - } - } + 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 +144,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 +180,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) {