/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
*
* This file is part of Jalview.
*
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.SequenceI;
+import java.util.HashMap;
+
public class StructureMapping
{
String mappingDetails;
String pdbchain;
- // Mapping index 0 is resNum, index 1 is atomNo
- int[][] mapping;
+ public static final int UNASSIGNED_VALUE = -1;
+
+ private static final int PDB_RES_NUM_INDEX = 0;
+
+ private static final int PDB_ATOM_NUM_INDEX = 1;
+
+ // Mapping key is residue index while value is an array containing PDB resNum,
+ // and atomNo
+ HashMap<Integer, int[]> mapping;
public StructureMapping(SequenceI seq, String pdbfile, String pdbid,
- String chain, int[][] mapping, String mappingDetails)
+ String chain, HashMap<Integer, int[]> mapping,
+ String mappingDetails)
{
sequence = seq;
this.pdbfile = pdbfile;
*/
public int getAtomNum(int seqpos)
{
- if (mapping.length > seqpos)
+ int[] resNumAtomMap = mapping.get(seqpos);
+ if (resNumAtomMap != null)
{
- return mapping[seqpos][1];
+ return resNumAtomMap[PDB_ATOM_NUM_INDEX];
}
else
{
- return 0;
+ return UNASSIGNED_VALUE;
}
}
*/
public int getPDBResNum(int seqpos)
{
- if (mapping.length > seqpos)
+ int[] resNumAtomMap = mapping.get(seqpos);
+ if (resNumAtomMap != null)
{
- return mapping[seqpos][0];
+ return resNumAtomMap[PDB_RES_NUM_INDEX];
}
else
{
- return 0;
+ return UNASSIGNED_VALUE;
}
}
*/
public int getSeqPos(int pdbResNum)
{
- for (int i = 0; i < mapping.length; i++)
+ for (Integer seqPos : mapping.keySet())
{
- if (mapping[i][0] == pdbResNum)
+ if (pdbResNum == getPDBResNum(seqPos))
{
- return i;
+ return seqPos;
}
}
- return -1;
+ return UNASSIGNED_VALUE;
}
/**