JAL-1432 updated copyright notices
[jalview.git] / src / jalview / structure / StructureMapping.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
3  * Copyright (C) 2014 The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
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 of the License, or (at your option) any later version.
10  *  
11  * Jalview is distributed in the hope that it will be useful, but 
12  * WITHOUT ANY WARRANTY; without even the implied warranty 
13  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14  * PURPOSE.  See the GNU General Public License for more details.
15  * 
16  * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
17  * The Jalview Authors are detailed in the 'AUTHORS' file.
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 }