JAL-4090 JAL-1551 source license
[jalview.git] / src / jalview / ws / datamodel / MappableContactMatrixI.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ 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
10  * of the License, or (at your option) any later version.
11  *  
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.
16  * 
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.
20  */
21 package jalview.ws.datamodel;
22
23 import jalview.datamodel.ContactListI;
24 import jalview.datamodel.ContactMatrixI;
25 import jalview.datamodel.Mapping;
26 import jalview.datamodel.SequenceI;
27 import jalview.util.MapList;
28
29 public interface MappableContactMatrixI extends ContactMatrixI
30 {
31
32   boolean hasReferenceSeq();
33
34   SequenceI getReferenceSeq();
35
36   /**
37    * remaps the matrix to a new reference sequence
38    * 
39    * @param dsq
40    * @param sqmpping
41    *          - mapping from current reference to new reference - 1:1 only
42    * @return new ContactMatrixI instance with updated mapping
43    */
44   MappableContactMatrixI liftOver(SequenceI dsq, Mapping sqmpping);
45
46   /**
47    * like ContactMatrixI.getContactList(int column) but
48    * 
49    * @param localFrame
50    *          - sequence or other object that this contact matrix is associated
51    *          with
52    * @param column
53    *          - position in localFrame
54    * @return ContactListI that returns contacts w.r.t. localFrame
55    */
56
57   ContactListI getMappableContactList(SequenceI localFrame, int column);
58
59   /**
60    * 
61    * Similar to AlignedCodonFrame.getMappingBetween
62    * 
63    * @param sequenceRef
64    *          - a reference sequence mappable to this contactMatrix - may be
65    *          null
66    * @return null or the MapList mapping to the coordinates of the reference
67    *         sequence (or if hasReferenceSeq() is false, and sequenceRef is
68    *         null, any mapping present)
69    * 
70    */
71   MapList getMapFor(SequenceI sequenceRef);
72
73   /**
74    * Locate a position in the mapped sequence for a single column in the matrix.
75    * this to resolve positions corresponding to column clusters
76    * 
77    * @param localFrame
78    *          - sequence derivced from reference sequence
79    * @param column
80    *          - matrix row/column
81    * @return sequence position(s) corresponding to column in contact matrix
82    */
83   int[] getMappedPositionsFor(SequenceI localFrame, int column);
84
85   /**
86    * Locate a position in the mapped sequence for a contiguous range of columns
87    * in the matrix use this to resolve positions corresponding to column
88    * clusters
89    * 
90    * @param localFrame
91    *          - sequence derivced from reference sequence
92    * @param column
93    *          - matrix row/column
94    * @return sequence position(s) corresponding to column in contact matrix
95    */
96   int[] getMappedPositionsFor(SequenceI localFrame, int from, int to);
97
98   ContactMatrixI getMappedMatrix();
99 }