From 2f85cd057a290c47d90e648545ed194a777f09da Mon Sep 17 00:00:00 2001 From: jprocter Date: Fri, 29 Oct 2010 13:59:47 +0000 Subject: [PATCH] patch for secondary issue in JAL-664 re parsing empty fields in description line --- src/jalview/io/ModellerDescription.java | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/jalview/io/ModellerDescription.java b/src/jalview/io/ModellerDescription.java index b590a6d..3af2f93 100755 --- a/src/jalview/io/ModellerDescription.java +++ b/src/jalview/io/ModellerDescription.java @@ -119,7 +119,8 @@ public class ModellerDescription private java.util.Hashtable parseDescription(String desc) { java.util.Hashtable fields = new java.util.Hashtable(); - java.util.StringTokenizer st = new java.util.StringTokenizer(desc, ":"); + java.util.StringTokenizer st = new java.util.StringTokenizer(desc, ":",true); + String field; int type = -1; if (st.countTokens() > 0) @@ -137,6 +138,7 @@ public class ModellerDescription if (i < seqTypes.length) { + st.nextToken(); // skip ':' // valid seqType for modeller type = i; i = 1; // continue parsing fields @@ -144,6 +146,8 @@ public class ModellerDescription { if ((field = st.nextToken(":")) != null) { + if (!field.equals(":")) + { // validate residue field value if (Types[i] == 1) { @@ -162,6 +166,12 @@ public class ModellerDescription ; } fields.put(Fields[i++], field); + if (st.hasMoreTokens()) { + st.nextToken(); // skip token sep. + } + } else { + i++; + } } } if (i == TAIL) @@ -169,7 +179,8 @@ public class ModellerDescription // slurp remaining fields while (st.hasMoreTokens()) { - field += ":" + st.nextToken(":"); + String tl = st.nextToken(":"); + field += tl.equals(":") ? tl : (":" + tl); } fields.put(Fields[TAIL], field); } @@ -229,12 +240,13 @@ public class ModellerDescription { // Set start and end before we update the type (in the case of a // synthesized field set) - if (getStartNum() != seq.getStart() && getStartCode().val != null) + if (getStartCode()==null || (getStartNum() != seq.getStart() && getStartCode().val != null)) { + // unset or user updated sequence start position setStartCode(seq.getStart()); } - if (getEndNum() != seq.getEnd() && getStartCode().val != null) + if (getEndCode()==null || (getEndNum() != seq.getEnd() && getStartCode()!=null && getStartCode().val != null)) { setEndCode(seq.getEnd()); } @@ -337,7 +349,7 @@ public class ModellerDescription { int start = 0; resCode val = getStartCode(); - if (val.val != null) + if (val!=null && val.val != null) { return val.val.intValue(); } @@ -366,7 +378,7 @@ public class ModellerDescription { int end = 0; resCode val = getEndCode(); - if (val.val != null) + if (val!=null && val.val != null) { return val.val.intValue(); } @@ -384,7 +396,8 @@ public class ModellerDescription { if (isModellerFieldset()) { - if (getStartCode().val != null) + resCode rc=getStartCode(); + if (rc!=null && rc.val != null) { newSeq.setStart(getStartNum()); } @@ -392,7 +405,8 @@ public class ModellerDescription { newSeq.setStart(1); } - if (getEndCode().val != null) + rc=getEndCode(); + if (rc!=null && rc.val != null) { newSeq.setEnd(getEndNum()); } -- 1.7.10.2