From: <ha...@us...> - 2008-04-22 02:58:09
|
Revision: 9303 http://jmol.svn.sourceforge.net/jmol/?rev=9303&view=rev Author: hansonr Date: 2008-04-21 19:58:04 -0700 (Mon, 21 Apr 2008) Log Message: ----------- version=11.5.31_dev # bug fix: sequence range for missing sequence numbers returns 0 Modified Paths: -------------- trunk/Jmol/src/org/jmol/modelset/Chain.java trunk/Jmol/src/org/jmol/modelset/Model.java Modified: trunk/Jmol/src/org/jmol/modelset/Chain.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/Chain.java 2008-04-22 02:14:14 UTC (rev 9302) +++ trunk/Jmol/src/org/jmol/modelset/Chain.java 2008-04-22 02:58:04 UTC (rev 9303) @@ -94,12 +94,18 @@ } } - public void selectSeqcodeRange(int seqcodeA, int seqcodeB, BitSet bs) { + public int selectSeqcodeRange(int index0, int seqcodeA, int seqcodeB, + BitSet bs) { int seqcode, indexA, indexB, minDiff; - for (indexA = 0; indexA < groupCount && groups[indexA].seqcode != seqcodeA; indexA++) { + boolean isInexact = false; + for (indexA = index0; indexA < groupCount + && groups[indexA].seqcode != seqcodeA; indexA++) { } if (indexA == groupCount) { // didn't find A exactly -- go find the nearest that is GREATER than this value + if (index0 > 0) + return -1; + isInexact = true; minDiff = Integer.MAX_VALUE; for (int i = groupCount; --i >= 0;) if ((seqcode = groups[i].seqcode) > seqcodeA @@ -108,27 +114,34 @@ minDiff = seqcode - seqcodeA; } if (minDiff == Integer.MAX_VALUE) - return; + return -1; } - if (seqcodeB == Integer.MAX_VALUE) + if (seqcodeB == Integer.MAX_VALUE) { indexB = groupCount - 1; - else - for (indexB = indexA; indexB < groupCount && groups[indexB].seqcode != seqcodeB; indexB++) { + isInexact = true; + } else { + for (indexB = indexA; indexB < groupCount + && groups[indexB].seqcode != seqcodeB; indexB++) { } - if (indexB == groupCount) { - // didn't find B exactly -- get the nearest that is LESS than this value - minDiff = Integer.MAX_VALUE; - for (int i = indexA; i < groupCount; i++) - if ((seqcode = groups[i].seqcode) < seqcodeB - && (seqcodeB - seqcode) < minDiff) { - indexB = i; - minDiff = seqcodeB - seqcode; - } - if (minDiff == Integer.MAX_VALUE) - return; + if (indexB == groupCount) { + // didn't find B exactly -- get the nearest that is LESS than this value + if (index0 > 0) + return -1; + isInexact = true; + minDiff = Integer.MAX_VALUE; + for (int i = indexA; i < groupCount; i++) + if ((seqcode = groups[i].seqcode) < seqcodeB + && (seqcodeB - seqcode) < minDiff) { + indexB = i; + minDiff = seqcodeB - seqcode; + } + if (minDiff == Integer.MAX_VALUE) + return -1; + } } for (int i = indexA; i <= indexB; ++i) groups[i].selectAtoms(bs); + return (isInexact ? -1 : indexB + 1); } int getSelectedGroupCount() { Modified: trunk/Jmol/src/org/jmol/modelset/Model.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/Model.java 2008-04-22 02:14:14 UTC (rev 9302) +++ trunk/Jmol/src/org/jmol/modelset/Model.java 2008-04-22 02:58:04 UTC (rev 9303) @@ -208,7 +208,8 @@ void selectSeqcodeRange(int seqcodeA, int seqcodeB, char chainID, BitSet bs) { for (int i = chainCount; --i >= 0; ) if (chainID == '\t' || chainID == chains[i].chainID) - chains[i].selectSeqcodeRange(seqcodeA, seqcodeB, bs); + for (int index = 0; index >= 0; ) + index = chains[i].selectSeqcodeRange(index, seqcodeA, seqcodeB, bs); } int getGroupCount() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |