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