alignmentProperties added
[jalview.git] / src / jalview / datamodel / AlignmentI.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer
3  * Copyright (C) 2007 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.datamodel;
20
21 import java.util.*;
22
23 /** Data structure to hold and manipulate a multiple sequence alignment
24  */
25 public interface AlignmentI
26 {
27   /**
28    *  Calculates the number of sequences in an alignment
29    *
30    * @return Number of sequences in alignment
31    */
32   public int getHeight();
33
34   /**
35    * Calculates the maximum width of the alignment, including gaps.
36    *
37    * @return Greatest sequence length within alignment.
38    */
39   public int getWidth();
40
41   /**
42    * Calculates if this set of sequences is all the same length
43    *
44    * @return true if all sequences in alignment are the same length
45    */
46   public boolean isAligned();
47
48   /**
49    * Gets sequences as a Vector
50    *
51    * @return All sequences in alignment.
52    */
53   public Vector getSequences();
54
55   /**
56    * Gets sequences as a SequenceI[]
57    *
58    * @return All sequences in alignment.
59    */
60   public SequenceI[] getSequencesArray();
61
62   /**
63    * Find a specific sequence in this alignment.
64    *
65    * @param i Index of required sequence.
66    *
67    * @return SequenceI at given index.
68    */
69   public SequenceI getSequenceAt(int i);
70
71   /**
72    * Add a new sequence to this alignment.
73    *
74    * @param seq New sequence will be added at end of alignment.
75    */
76   public void addSequence(SequenceI seq);
77
78   /**
79    * Used to set a particular index of the alignment with the given sequence.
80    *
81    * @param i Index of sequence to be updated.
82    * @param seq New sequence to be inserted.
83    */
84   public void setSequenceAt(int i, SequenceI seq);
85
86   /**
87    * Deletes a sequence from the alignment
88    *
89    * @param s Sequence to be deleted.
90    */
91   public void deleteSequence(SequenceI s);
92
93   /**
94    * Deletes a sequence from the alignment.
95    *
96    * @param i Index of sequence to be deleted.
97    */
98   public void deleteSequence(int i);
99
100   /**
101    * Finds sequence in alignment using sequence name as query.
102    *
103    * @param name Id of sequence to search for.
104    *
105    * @return Sequence matching query, if found. If not found returns null.
106    */
107   public SequenceI findName(String name);
108
109   public SequenceI[] findSequenceMatch(String name);
110
111   /**
112    * Finds index of a given sequence in the alignment.
113    *
114    * @param s Sequence to look for.
115    *
116    * @return Index of sequence within the alignment.
117    */
118   public int findIndex(SequenceI s);
119
120   /**
121    * Finds group that given sequence is part of.
122    *
123    * @param s Sequence in alignment.
124    *
125    * @return First group found for sequence. WARNING :
126    * Sequences may be members of several groups. This method is incomplete.
127    */
128   public SequenceGroup findGroup(SequenceI s);
129
130   /**
131    * Finds all groups that a given sequence is part of.
132    *
133    * @param s Sequence in alignment.
134    *
135    * @return All groups containing given sequence.
136    */
137   public SequenceGroup[] findAllGroups(SequenceI s);
138
139   /**
140    * Adds a new SequenceGroup to this alignment.
141    *
142    * @param sg New group to be added.
143    */
144   public void addGroup(SequenceGroup sg);
145
146   /**
147    * Deletes a specific SequenceGroup
148    *
149    * @param g Group will be deleted from alignment.
150    */
151   public void deleteGroup(SequenceGroup g);
152
153   /**
154    * Get all the groups associated with this alignment.
155    *
156    * @return All groups as a Vector.
157    */
158   public Vector getGroups();
159
160
161   /**
162    * Deletes all groups from this alignment.
163    */
164   public void deleteAllGroups();
165
166   /**
167    * Adds a new AlignmentAnnotation to this alignment
168    * @note Care should be taken to ensure that annotation is at
169    * least as wide as the longest sequence in the alignment
170    * for rendering purposes.
171    */
172   public void addAnnotation(AlignmentAnnotation aa);
173   /**
174    * moves annotation to a specified index in alignment annotation display stack
175    * @param aa the annotation object to be moved
176    * @param index the destination position
177    */
178   public void setAnnotationIndex(AlignmentAnnotation aa, int index);
179
180   /**
181    * Deletes a specific AlignmentAnnotation from the alignment.
182    *
183    * @param aa the annotation to delete
184    */
185   public void deleteAnnotation(AlignmentAnnotation aa);
186
187   /**
188    * Get the annotation associated with this alignment
189    *
190    * @return array of AlignmentAnnotation objects
191    */
192   public AlignmentAnnotation[] getAlignmentAnnotation();
193
194   /**
195    * Change the gap character used in this alignment to 'gc'
196    *
197    * @param gc the new gap character.
198    */
199   public void setGapCharacter(char gc);
200
201   /**
202    * Get the gap character used in this alignment
203    *
204    * @return gap character
205    */
206   public char getGapCharacter();
207
208   /**
209    * Test for all nucleotide alignment
210    *
211    * @return true if alignment is nucleotide sequence
212    */
213   public boolean isNucleotide();
214
215   /**
216    * Set alignment to be a nucleotide sequence
217    *
218    */
219   public void setNucleotide(boolean b);
220
221   /**
222    * Get the associated dataset for the alignment.
223    * @return Alignment containing dataset sequences or null of this is a dataset.
224    */
225   public Alignment getDataset();
226
227   /**
228    * Set the associated dataset for the alignment, or create one.
229    * @param dataset The dataset alignment or null to construct one.
230    */
231   public void setDataset(Alignment dataset);
232
233   /**
234    * pads sequences with gaps (to ensure the set looks like an alignment)
235    * @return boolean true if alignment was modified
236    */
237   public boolean padGaps();
238
239   public HiddenSequences getHiddenSequences();
240
241   /**
242    * Compact representation of alignment
243    * @return CigarArray
244    */
245   public CigarArray getCompactAlignment();
246
247   public void setProperty(Object key, Object value);
248
249   public Object getProperty(Object key);
250 }