1 package jalview.structure;
3 import jalview.datamodel.SequenceI;
4 import jalview.io.StructureFile;
5 import jalview.structures.models.MappingOutputModel;
7 import java.util.Collection;
11 import MCview.PDBChain;
13 public abstract class StructureMappingClient
16 protected StructureFile structureFile;
18 public static final int UNASSIGNED = -1;
20 private static final int PDB_RES_POS = 0;
22 private static final int PDB_ATOM_POS = 1;
24 public void populateAtomPositions(String chainId,
25 Map<Integer, int[]> mapping)
26 throws IllegalArgumentException,
27 StructureMappingException
31 PDBChain chain = structureFile.findChain(chainId);
33 if (chain == null || mapping == null)
35 throw new IllegalArgumentException(
36 "Chain id or mapping must not be null.");
38 for (int[] map : mapping.values())
40 if (map[PDB_RES_POS] != UNASSIGNED)
42 map[PDB_ATOM_POS] = getAtomIndex(map[PDB_RES_POS], chain.atoms);
47 throw new StructureMappingException(
48 "Structure mapping exception occured.");
55 * The residue index used for the search
57 * A collection of Atom to search
58 * @return atom position for the given residue index
60 public int getAtomIndex(int residueIndex, Collection<Atom> atoms)
64 throw new IllegalArgumentException(
65 "atoms collection must not be null!");
67 for (Atom atom : atoms)
69 if (atom.resNumber == residueIndex)
71 return atom.atomIndex;
77 public class StructureMappingException extends Exception
80 private static final long serialVersionUID = 1L;
82 public StructureMappingException(String message)
91 * sequence to generate mapping against the structure
93 * PDB file for the mapping
95 * the chain of the entry to use for mapping
96 * @return StructureMapping
99 public abstract StructureMapping getStructureMapping(SequenceI seq,
100 String pdbFile, String chain) throws Exception,
101 StructureMappingException;
107 * @return Sequence<->Structure mapping as int[][]
108 * @throws StructureMappingException
110 public abstract StringBuffer getMappingOutput(MappingOutputModel mp)
111 throws StructureMappingException;