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