From: <ha...@us...> - 2011-05-10 20:19:58
|
Revision: 15451 http://jmol.svn.sourceforge.net/jmol/?rev=15451&view=rev Author: hansonr Date: 2011-05-10 20:19:51 +0000 (Tue, 10 May 2011) Log Message: ----------- version=12.1.46_dev # bug fix: select within(chain, atomno=xxx) will not select all desired atoms # if the chain is spread out over multiple regions of the file (1gzx) Modified Paths: -------------- trunk/Jmol/src/org/jmol/modelset/AtomCollection.java trunk/Jmol/src/org/jmol/modelset/Chain.java Modified: trunk/Jmol/src/org/jmol/modelset/AtomCollection.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/AtomCollection.java 2011-05-10 20:18:59 UTC (rev 15450) +++ trunk/Jmol/src/org/jmol/modelset/AtomCollection.java 2011-05-10 20:19:51 UTC (rev 15451) @@ -2248,21 +2248,11 @@ } break; case Token.chain: - for (i = i0; i >= 0; i = bsInfo.nextSetBit(i+1)) { - if (bs.get(i)) - continue; + bsInfo = BitSetUtil.copy((BitSet) specInfo); + for (i = bsInfo.nextSetBit(0); i >= 0; i = bsInfo.nextSetBit(i + 1)) { Chain chain = atoms[i].getChain(); - bs.set(i); - for (int j = i; --j >= 0;) - if (atoms[j].getChain() == chain) - bs.set(j); - else - break; - for (; ++i < atomCount;) - if (atoms[i].getChain() == chain) - bs.set(i); - else - break; + chain.setAtomBitSet(bs); + bsInfo.andNot(bs); } break; case Token.polymer: @@ -2470,17 +2460,20 @@ return (!isEmpty || returnEmpty ? bs : null); } - protected BitSet getChainBits(char chain) { + protected BitSet getChainBits(char chainId) { boolean caseSensitive = viewer.getChainCaseSensitive(); if (!caseSensitive) - chain = Character.toUpperCase(chain); + chainId = Character.toUpperCase(chainId); BitSet bs = new BitSet(); - for (int i = atomCount; --i >= 0;) { - char ch = atoms[i].getChainID(); - if (!caseSensitive) - ch = Character.toUpperCase(ch); - if (chain == ch) - bs.set(i); + BitSet bsDone = new BitSet(atomCount); + for (int i = bsDone.nextClearBit(0); i < atomCount; i = bsDone.nextClearBit(i)) { + Chain chain = atoms[i].getChain(); + if (chainId == (caseSensitive ? chain.chainID : Character.toUpperCase(chain.chainID))) { + chain.setAtomBitSet(bs); + bsDone.or(bs); + } else { + chain.setAtomBitSet(bsDone); + } } return bs; } Modified: trunk/Jmol/src/org/jmol/modelset/Chain.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/Chain.java 2011-05-10 20:18:59 UTC (rev 15450) +++ trunk/Jmol/src/org/jmol/modelset/Chain.java 2011-05-10 20:19:51 UTC (rev 15451) @@ -37,53 +37,49 @@ private boolean isDna, isRna; private BitSet bsSelectedGroups; - public Chain(ModelSet modelSet, Model model, char chainID) { - this.modelSet = modelSet; - this.model = model; - this.chainID = chainID; - } - - public void setModelSet(ModelSet modelSet) { - this.modelSet = modelSet; - } - public char getChainID() { return chainID; } - public ModelSet getModelSet() { - return modelSet; - } - public boolean isDna() { return isDna; } public boolean isRna() { return isRna; } public void setIsDna(boolean TF) {isDna = TF;} public void setIsRna(boolean TF) {isRna = TF;} - public Group getGroup(int groupIndex) { - return groups[groupIndex]; + public Atom getAtom(int index) { + return modelSet.atoms[index]; } - public int getGroupCount() { - return groupCount; + Chain(ModelSet modelSet, Model model, char chainID) { + this.modelSet = modelSet; + this.model = model; + this.chainID = chainID; } - public int getAtomCount() { - return groups[groupCount - 1].lastAtomIndex + 1 - groups[0].firstAtomIndex; + void setModelSet(ModelSet modelSet) { + this.modelSet = modelSet; } - public Atom getAtom(int index) { - return modelSet.atoms[index]; + ModelSet getModelSet() { + return modelSet; } + Group getGroup(int groupIndex) { + return groups[groupIndex]; + } + + int getGroupCount() { + return groupCount; + } + /** * prior to coloring by group, we need the chain count per chain * that is selected * * @param bsSelected */ - public void calcSelectedGroupsCount(BitSet bsSelected) { + void calcSelectedGroupsCount(BitSet bsSelected) { selectedGroupCount = 0; if (bsSelectedGroups == null) bsSelectedGroups = new BitSet(); @@ -98,7 +94,7 @@ } } - public int selectSeqcodeRange(int index0, int seqcodeA, int seqcodeB, + int selectSeqcodeRange(int index0, int seqcodeA, int seqcodeB, BitSet bs) { int seqcode, indexA, indexB, minDiff; boolean isInexact = false; @@ -152,11 +148,16 @@ return selectedGroupCount; } - public void fixIndices(int atomsDeleted) { + void fixIndices(int atomsDeleted) { for (int i = 0; i < groupCount; i++) { groups[i].firstAtomIndex -= atomsDeleted; groups[i].leadAtomIndex -= atomsDeleted; groups[i].lastAtomIndex -= atomsDeleted; } } + + void setAtomBitSet(BitSet bs) { + for (int i = 0; i < groupCount; i++) + bs.set(groups[i].firstAtomIndex, groups[i].lastAtomIndex + 1); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |