Structure listener
[jalview.git] / src / jalview / structure / StructureMapping.java
1 /*\r
2  * Jalview - A Sequence Alignment Editor and Viewer\r
3  * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
4  *\r
5  * This program is free software; you can redistribute it and/or\r
6  * modify it under the terms of the GNU General Public License\r
7  * as published by the Free Software Foundation; either version 2\r
8  * of the License, or (at your option) any later version.\r
9  *\r
10  * This program is distributed in the hope that it will be useful,\r
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13  * GNU General Public License for more details.\r
14  *\r
15  * You should have received a copy of the GNU General Public License\r
16  * along with this program; if not, write to the Free Software\r
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
18  */\r
19 \r
20 package jalview.structure;\r
21 \r
22 import jalview.datamodel.*;\r
23 \r
24 public class StructureMapping\r
25 {\r
26   String mappingDetails;\r
27   SequenceI sequence;\r
28   String pdbfile;\r
29   String pdbid;\r
30   String pdbchain;\r
31 \r
32   //Mapping index 0 is resNum, index 1 is atomNo\r
33   int[][] mapping;\r
34 \r
35   public StructureMapping(SequenceI seq,\r
36                           String pdbfile,\r
37                           String pdbid,\r
38                           String chain,\r
39                           int[][] mapping,\r
40                           String mappingDetails)\r
41   {\r
42     sequence = seq;\r
43     this.pdbfile = pdbfile;\r
44     this.pdbid = pdbid;\r
45     this.pdbchain = chain;\r
46     this.mapping = mapping;\r
47     this.mappingDetails = mappingDetails;\r
48   }\r
49 \r
50   public SequenceI getSequence()\r
51   {\r
52     return sequence;\r
53   }\r
54 \r
55   public String getChain()\r
56   {\r
57     return pdbchain;\r
58   }\r
59 \r
60   public String getPdbId()\r
61   {\r
62     return pdbid;\r
63   }\r
64 \r
65   public int getAtomNum(int seqpos)\r
66   {\r
67     if (mapping.length > seqpos)\r
68     {\r
69       return mapping[seqpos][1];\r
70     }\r
71     else\r
72     {\r
73       return 0;\r
74     }\r
75   }\r
76 \r
77   public int getPDBResNum(int seqpos)\r
78   {\r
79     if (mapping.length > seqpos)\r
80     {\r
81       return mapping[seqpos][0];\r
82     }\r
83     else\r
84     {\r
85       return 0;\r
86     }\r
87   }\r
88 \r
89   public int getSeqPos(int pdbResNum)\r
90   {\r
91     for (int i = 0; i < mapping.length; i++)\r
92     {\r
93       if (mapping[i][0] == pdbResNum)\r
94       {\r
95         return i;\r
96       }\r
97     }\r
98     return -1;\r
99   }\r
100 }\r