+ /**
+ * Pad omitted residue positions in PDB sequence with gaps
+ *
+ * @param resNumMap
+ */
+ void padWithGaps(TreeMap<Integer, String> resNumMap,
+ ArrayList<Integer> omitNonObserved)
+ {
+ if (resNumMap == null || resNumMap.isEmpty())
+ {
+ return;
+ }
+ Integer[] keys = resNumMap.keySet().toArray(new Integer[0]);
+ Arrays.sort(keys);
+ int firstIndex = keys[0];
+ int lastIndex = keys[keys.length - 1];
+ System.out.println("Min value " + firstIndex);
+ System.out.println("Max value " + lastIndex);
+ for (int x = firstIndex; x <= lastIndex; x++)
+ {
+ if (!resNumMap.containsKey(x) && !omitNonObserved.contains(x))
+ {
+ resNumMap.put(x, "-");
+ }
+ }
+ }
+
+
+ /**
+ *
+ * @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;
+ }
+