1 /* $RCSfile$ 2 * $Author: hansonr $ 3 * $Date: 2018-02-22 12:04:47 -0600 (Thu, 22 Feb 2018) $ 4 * $Revision: 21841 $ 5 * 6 * Copyright (C) 2002-2005 The Jmol Development Team 7 * 8 * Contact: jmol-developers@lists.sf.net 9 * 10 * This library is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU Lesser General Public 12 * License as published by the Free Software Foundation; either 13 * version 2.1 of the License, or (at your option) any later version. 14 * 15 * This library is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * Lesser General Public License for more details. 19 * 20 * You should have received a copy of the GNU Lesser General Public 21 * License along with this library; if not, write to the Free Software 22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 23 */ 24 package org.jmol.modelset; 25 26 import javajs.util.BS; 27 28 /** 29 * A Model is a collection of Chains of Groups of Atoms. 30 * Chains hold overall information relating to a Monomer, 31 * particularly whether this monomer is RNA or DNA. 32 * 33 */ 34 public final class Chain implements Structure { 35 36 public Model model; 37 /** 38 * chainID is either the integer form of a single character or a pointer into 39 * a map held in Viewer that allows retrieval of a longer string 40 * 41 */ 42 public int chainID; 43 /** 44 * chainNo is for information purposes only; retrieved by {atoms}.chainNo 45 */ 46 public int chainNo; 47 48 /** 49 * Groups form the essence of what a Chain is. 50 * This number will be 0 if there is no chain designation in the PDB or CIF file 51 * or when the file is not of a type that would have chain designations. 52 * 53 */ 54 public Group[] groups; 55 public int groupCount; 56 57 /** 58 * Calculated just prior to coloring by group 59 * so that the range is appropriate for each chain. 60 */ 61 public int selectedGroupCount; 62 Chain(Model model, int chainID, int chainNo)63 Chain(Model model, int chainID, int chainNo) { 64 this.model = model; 65 this.chainID = chainID; 66 this.chainNo = chainNo; 67 groups = new Group[16]; 68 } 69 70 /** 71 * 72 * @return actual string form of the chain identifier 73 */ getIDStr()74 public String getIDStr() { 75 return (chainID == 0 ? "" : chainID < 256 ? "" + (char) chainID : (String) model.ms.vwr.getChainIDStr(chainID)); 76 } 77 78 /** 79 * prior to coloring by group, we need the chain count per chain that is 80 * selected 81 * 82 * @param bsSelected 83 */ calcSelectedGroupsCount(BS bsSelected)84 void calcSelectedGroupsCount(BS bsSelected) { 85 selectedGroupCount = 0; 86 for (int i = 0; i < groupCount; i++) 87 groups[i].selectedIndex = (groups[i].isSelected(bsSelected) ? selectedGroupCount++ 88 : -1); 89 } 90 fixIndices(int atomsDeleted, BS bsDeleted)91 void fixIndices(int atomsDeleted, BS bsDeleted) { 92 for (int i = 0; i < groupCount; i++) 93 groups[i].fixIndices(atomsDeleted, bsDeleted); 94 } 95 96 @Override setAtomBits(BS bs)97 public void setAtomBits(BS bs) { 98 for (int i = 0; i < groupCount; i++) 99 groups[i].setAtomBits(bs); 100 } 101 102 @Override setAtomBitsAndClear(BS bs, BS bsOut)103 public void setAtomBitsAndClear(BS bs, BS bsOut) { 104 for (int i = 0; i < groupCount; i++) 105 groups[i].setAtomBitsAndClear(bs, bsOut); 106 } 107 108 } 109