X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FModellerDescription.java;h=3af2f93b68c33dfc19112015905ff0618de917e9;hb=cb105dfc09cebd040a202758a3756fdf6c5fa3b6;hp=5652a2533052b5923125e66975545e60aade3fd5;hpb=2de8acfae59aced665e4c37ad0f7dcc2ed68818e;p=jalview.git diff --git a/src/jalview/io/ModellerDescription.java b/src/jalview/io/ModellerDescription.java index 5652a25..3af2f93 100755 --- a/src/jalview/io/ModellerDescription.java +++ b/src/jalview/io/ModellerDescription.java @@ -1,20 +1,19 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1) - * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6) + * Copyright (C) 2010 J Procter, AM Waterhouse, 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 file is part of Jalview. * - * 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. + * Jalview 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 3 of the License, or (at your option) any later version. * - * 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 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 Jalview. If not, see . */ package jalview.io; @@ -120,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) @@ -138,6 +138,7 @@ public class ModellerDescription if (i < seqTypes.length) { + st.nextToken(); // skip ':' // valid seqType for modeller type = i; i = 1; // continue parsing fields @@ -145,6 +146,8 @@ public class ModellerDescription { if ((field = st.nextToken(":")) != null) { + if (!field.equals(":")) + { // validate residue field value if (Types[i] == 1) { @@ -163,6 +166,12 @@ public class ModellerDescription ; } fields.put(Fields[i++], field); + if (st.hasMoreTokens()) { + st.nextToken(); // skip token sep. + } + } else { + i++; + } } } if (i == TAIL) @@ -170,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); } @@ -216,7 +226,7 @@ public class ModellerDescription * make a possibly updated modeller field line for the sequence object * * @param seq - * SequenceI + * SequenceI */ ModellerDescription(SequenceI seq) { @@ -230,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()); } @@ -246,7 +257,7 @@ public class ModellerDescription setStartCode(seq.getStart()); setEndCode(seq.getEnd()); fields.put(Fields[LOCALID], seq.getName()); // this may be overwritten - // below... + // below... // type - decide based on evidence of PDB database references - this also // sets the local reference field int t = 0; // sequence @@ -338,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(); } @@ -367,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(); } @@ -378,14 +389,15 @@ public class ModellerDescription * returns true if sequence object was modifed with a valid modellerField set * * @param newSeq - * SequenceI + * SequenceI * @return boolean */ boolean updateSequenceI(SequenceI newSeq) { if (isModellerFieldset()) { - if (getStartCode().val != null) + resCode rc=getStartCode(); + if (rc!=null && rc.val != null) { newSeq.setStart(getStartNum()); } @@ -393,7 +405,8 @@ public class ModellerDescription { newSeq.setStart(1); } - if (getEndCode().val != null) + rc=getEndCode(); + if (rc!=null && rc.val != null) { newSeq.setEnd(getEndNum()); }