+ *
+ * @param chainId
+ * Target chain to populate mapping of its atom positions.
+ * @param mapping
+ * Two dimension array of residue index versus atom position
+ * @throws IllegalArgumentException
+ * Thrown if chainId or mapping is null
+ */
+ void populateAtomPositions(String chainId,
+ HashMap<Integer, int[]> mapping) throws IllegalArgumentException
+ {
+ PDBChain chain = pdb.findChain(chainId);
+ if (chain == null || mapping == null)
+ {
+ throw new IllegalArgumentException(
+ "Chain id or mapping must not be null.");
+ }
+ for (int[] map : mapping.values())
+ {
+ if (map[PDB_RES_POS] != UNASSIGNED)
+ {
+ map[PDB_ATOM_POS] = getAtomIndex(map[PDB_RES_POS], chain.atoms);
+ }
+ }
+ }
+
+ /**
+ *
+ * @param residueIndex
+ * The residue index used for the search
+ * @param atoms
+ * A collection of Atom to search
+ * @return atom position for the given residue index
+ */
+ int getAtomIndex(int residueIndex, Collection<Atom> atoms)
+ {
+ if (atoms == null)
+ {
+ throw new IllegalArgumentException(
+ "atoms collection must not be null!");
+ }
+ for (Atom atom : atoms)
+ {
+ if (atom.resNumber == residueIndex)
+ {
+ return atom.atomIndex;
+ }
+ }
+ return UNASSIGNED;
+ }
+
+ /**