header updated
[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      * Deletes all residues in every sequence of alignment within given columns.
112      *
113      * @param start Start index of columns to delete.
114      * @param end End index to columns to delete.
115      */
116     public void deleteColumns(SequenceI seqs [], int start, int end);
117
118
119     /**
120      * Finds sequence in alignment using sequence name as query.
121      *
122      * @param name Id of sequence to search for.
123      *
124      * @return Sequence matching query, if found. If not found returns null.
125      */
126     public SequenceI findName(String name);
127
128     public SequenceI [] findSequenceMatch(String name);
129
130     /**
131      * Finds index of a given sequence in the alignment.
132      *
133      * @param s Sequence to look for.
134      *
135      * @return Index of sequence within the alignment.
136      */
137     public int findIndex(SequenceI s);
138
139     /**
140     * All sequences will be cut from beginning to given index.
141     *
142     * @param i Remove all residues in sequences up to this column.
143      */
144     public void trimLeft(int i);
145
146     /**
147      * All sequences will be cut from given index.
148      *
149      * @param i Remove all residues in sequences beyond this column.
150      */
151     public void trimRight(int i);
152
153     /**
154      * Removes all columns containing entirely gap characters.
155      */
156     public void removeGaps();
157     /**
158      * remove gaps in alignment - recording any frame shifts in shiftrecord
159      * @param shiftrecord
160      */
161     public void removeGaps(ShiftList shiftrecord);
162
163     /**
164      * Finds group that given sequence is part of.
165      *
166      * @param s Sequence in alignment.
167      *
168      * @return First group found for sequence. WARNING :
169      * Sequences may be members of several groups. This method is incomplete.
170      */
171     public SequenceGroup findGroup(SequenceI s);
172
173     /**
174      * Finds all groups that a given sequence is part of.
175      *
176      * @param s Sequence in alignment.
177      *
178      * @return All groups containing given sequence.
179      */
180     public SequenceGroup[] findAllGroups(SequenceI s);
181
182     /**
183      * Adds a new SequenceGroup to this alignment.
184      *
185      * @param sg New group to be added.
186      */
187     public void addGroup(SequenceGroup sg);
188
189     /**
190      * Deletes a specific SequenceGroup
191      *
192      * @param g Group will be deleted from alignment.
193      */
194     public void deleteGroup(SequenceGroup g);
195
196     /**
197      * Get all the groups associated with this alignment.
198      *
199      * @return All groups as a Vector.
200      */
201     public Vector getGroups();
202
203     /**
204      * Deletes all groups from this alignment.
205      */
206     public void deleteAllGroups();
207
208
209     /**
210      * Adds a new AlignmentAnnotation to this alignment
211      */
212     public void addAnnotation(AlignmentAnnotation aa);
213
214
215     public void setAnnotationIndex(AlignmentAnnotation aa, int index);
216
217     /**
218      * Deletes a specific AlignmentAnnotation from the alignment.
219      *
220      * @param aa DOCUMENT ME!
221      */
222     public void deleteAnnotation(AlignmentAnnotation aa);
223
224     /**
225      * DOCUMENT ME!
226      *
227      * @return DOCUMENT ME!
228      */
229     public AlignmentAnnotation[] getAlignmentAnnotation();
230
231     /**
232      * DOCUMENT ME!
233      *
234      * @param gc DOCUMENT ME!
235      */
236     public void setGapCharacter(char gc);
237
238     /**
239      * DOCUMENT ME!
240      *
241      * @return DOCUMENT ME!
242      */
243     public char getGapCharacter();
244
245     /**
246      * DOCUMENT ME!
247      *
248      * @return DOCUMENT ME!
249      */
250     public Vector getAAFrequency();
251
252     /**
253      * Returns true if alignment is nucleotide sequence
254      *
255      * @return DOCUMENT ME!
256      */
257     public boolean isNucleotide();
258
259     /**
260      * Set true if the alignment is a nucleotide sequence
261      *
262      * @return
263      */
264     public void setNucleotide(boolean b);
265
266
267     public Alignment getDataset();
268
269     public void setDataset(Alignment dataset);
270     /**
271      * pads sequences with gaps (to ensure the set looks like an alignment)
272      * @return boolean true if alignment was modified
273      */
274     public boolean padGaps();
275
276     public void adjustSequenceAnnotations();
277
278     public HiddenSequences getHiddenSequences();
279     /**
280      * Compact representation of alignment
281      * @return CigarArray
282      */
283     public CigarArray getCompactAlignment();
284 }