2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3 * Copyright (C) 2014 The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.structure;
23 import jalview.datamodel.AlignmentAnnotation;
24 import jalview.datamodel.SequenceI;
26 public class StructureMapping
28 String mappingDetails;
38 // Mapping index 0 is resNum, index 1 is atomNo
41 public StructureMapping(SequenceI seq, String pdbfile, String pdbid,
42 String chain, int[][] mapping, String mappingDetails)
45 this.pdbfile = pdbfile;
47 this.pdbchain = chain;
48 this.mapping = mapping;
49 this.mappingDetails = mappingDetails;
52 public SequenceI getSequence()
57 public String getChain()
62 public String getPdbId()
70 * @return 0 or corresponding atom number for the sequence position
72 public int getAtomNum(int seqpos)
74 if (mapping.length > seqpos)
76 return mapping[seqpos][1];
87 * @return 0 or the corresponding residue number for the sequence position
89 public int getPDBResNum(int seqpos)
91 if (mapping.length > seqpos)
93 return mapping[seqpos][0];
104 * @return -1 or the corresponding sequence position for a pdb residue number
106 public int getSeqPos(int pdbResNum)
108 for (int i = 0; i < mapping.length; i++)
110 if (mapping[i][0] == pdbResNum)
119 * transfer a copy of an alignment annotation row in the PDB chain coordinate
120 * system onto the mapped sequence
123 * @return the copy that was remapped to the mapped sequence
124 * @note this method will create a copy and add it to the dataset sequence for
125 * the mapped sequence as well as the mapped sequence (if it is not a
128 public AlignmentAnnotation transfer(AlignmentAnnotation ana)
130 AlignmentAnnotation ala_copy = new AlignmentAnnotation(ana);
131 SequenceI ds = sequence;
132 while (ds.getDatasetSequence() != null)
134 ds = ds.getDatasetSequence();
136 // need to relocate annotation from pdb coordinates to local sequence
137 // -1,-1 doesn't look at pdbresnum but fails to remap sequence positions...
139 ala_copy.remap(ds, mapping, -1, -1, 0);
140 ds.addAlignmentAnnotation(ala_copy);
143 // mapping wasn't to an original dataset sequence, so we make a copy on
144 // the mapped sequence too
145 ala_copy = new AlignmentAnnotation(ala_copy);
146 sequence.addAlignmentAnnotation(ala_copy);