ed1ec4e72346e992f3ba3a89f4e43221dccf819b
[jalview.git] / src / jalview / datamodel / AlignmentI.java
1 /*\r
2 * Jalview - A Sequence Alignment Editor and Viewer\r
3 * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
4 *\r
5 * This program is free software; you can redistribute it and/or\r
6 * modify it under the terms of the GNU General Public License\r
7 * as published by the Free Software Foundation; either version 2\r
8 * of the License, or (at your option) any later version.\r
9 *\r
10 * This program is distributed in the hope that it will be useful,\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13 * GNU General Public License for more details.\r
14 *\r
15 * You should have received a copy of the GNU General Public License\r
16 * along with this program; if not, write to the Free Software\r
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
18 */\r
19 package jalview.datamodel;\r
20 \r
21 import java.util.*;\r
22 \r
23 \r
24 /** Data structure to hold and manipulate a multiple sequence alignment\r
25  */\r
26 public interface AlignmentI\r
27 {\r
28     /**\r
29      *  Calculates the number of sequences in an alignment\r
30      *\r
31      * @return Number of sequences in alignment\r
32      */\r
33     public int getHeight();\r
34 \r
35     /**\r
36      * Calculates the maximum width of the alignment, including gaps.\r
37      *\r
38      * @return Greatest sequence length within alignment.\r
39      */\r
40     public int getWidth();\r
41 \r
42     /**\r
43      * Calculates the longest sequence Id of the alignment\r
44      *\r
45      * @return Number of characters in longest sequence Id.\r
46      */\r
47     public int getMaxIdLength();\r
48 \r
49     /**\r
50      * Calculates if this set of sequences is all the same length\r
51      *\r
52      * @return true if all sequences in alignment are the same length\r
53      */\r
54     public boolean isAligned();\r
55 \r
56     /**\r
57      * Gets sequences as a Vector\r
58      *\r
59      * @return All sequences in alignment.\r
60      */\r
61     public Vector getSequences();\r
62 \r
63     /**\r
64      * Find a specific sequence in this alignment.\r
65      *\r
66      * @param i Index of required sequence.\r
67      *\r
68      * @return SequenceI at given index.\r
69      */\r
70     public SequenceI getSequenceAt(int i);\r
71 \r
72     /**\r
73      * Add a new sequence to this alignment.\r
74      *\r
75      * @param seq New sequence will be added at end of alignment.\r
76      */\r
77     public void addSequence(SequenceI seq);\r
78 \r
79     /**\r
80      * Used to set a particular index of the alignment with the given sequence.\r
81      *\r
82      * @param i Index of sequence to be updated.\r
83      * @param seq New sequence to be inserted.\r
84      */\r
85     public void setSequenceAt(int i, SequenceI seq);\r
86 \r
87     /**\r
88      * Deletes a sequence from the alignment.\r
89      *\r
90      * @param s Sequence to be deleted.\r
91      */\r
92     public void deleteSequence(SequenceI s);\r
93 \r
94     /**\r
95      * Deletes a sequence from the alignment.\r
96      *\r
97      * @param i Index of sequence to be deleted.\r
98      */\r
99     public void deleteSequence(int i);\r
100 \r
101     /**\r
102      * Deletes all residues in every sequence of alignment within given columns.\r
103      *\r
104      * @param start Start index of columns to delete.\r
105      * @param end End index to columns to delete.\r
106      */\r
107     public void deleteColumns(int start, int end);\r
108 \r
109     /**\r
110      * Deletes all residues in every sequence of alignment within given columns.\r
111      *\r
112      * @param seq1 Index of first sequence to delete columns from.\r
113      * @param seq2 Index of last sequence to delete columns from.\r
114      * @param start Start index of columns to delete.\r
115      * @param end End index of columns to delete.\r
116      */\r
117     public void deleteColumns(int seq1, int seq2, int start, int end);\r
118 \r
119     /**\r
120      * Finds sequence in alignment using sequence name as query.\r
121      *\r
122      * @param name Id of sequence to search for.\r
123      *\r
124      * @return Sequence matching query, if found. If not found returns null.\r
125      */\r
126     public SequenceI findName(String name);\r
127 \r
128     public SequenceI findShortName(String name);\r
129 \r
130 \r
131     /**\r
132      * Finds index of a given sequence in the alignment.\r
133      *\r
134      * @param s Sequence to look for.\r
135      *\r
136      * @return Index of sequence within the alignment.\r
137      */\r
138     public int findIndex(SequenceI s);\r
139 \r
140     /**\r
141     * All sequences will be cut from beginning to given index.\r
142     *\r
143     * @param i Remove all residues in sequences up to this column.\r
144      */\r
145     public void trimLeft(int i);\r
146 \r
147     /**\r
148      * All sequences will be cut from given index.\r
149      *\r
150      * @param i Remove all residues in sequences beyond this column.\r
151      */\r
152     public void trimRight(int i);\r
153 \r
154     /**\r
155      * Removes all columns containing entirely gap characters.\r
156      */\r
157     public void removeGaps();\r
158 \r
159     /**\r
160      * Removes redundant sequences from alignment.\r
161      *\r
162      * @param threshold Remove all sequences above the given threshold.\r
163      * @param sel Set of sequences which will have redundant sequences removed from.\r
164      *\r
165      * @return All sequences below redundancy threshold.\r
166      */\r
167     public Vector removeRedundancy(float threshold, Vector sel);\r
168 \r
169     /**\r
170      * Finds group that sequence at index i in alignment is part of.\r
171      *\r
172      * @param i Index in alignment.\r
173      *\r
174      * @return First group found for sequence at position i. WARNING :\r
175      * Sequences may be members of several groups. This method is incomplete.\r
176      */\r
177     public SequenceGroup findGroup(int i);\r
178 \r
179     /**\r
180      * Finds group that given sequence is part of.\r
181      *\r
182      * @param s Sequence in alignment.\r
183      *\r
184      * @return First group found for sequence. WARNING :\r
185      * Sequences may be members of several groups. This method is incomplete.\r
186      */\r
187     public SequenceGroup findGroup(SequenceI s);\r
188 \r
189     /**\r
190      * Finds all groups that a given sequence is part of.\r
191      *\r
192      * @param s Sequence in alignment.\r
193      *\r
194      * @return All groups containing given sequence.\r
195      */\r
196     public SequenceGroup[] findAllGroups(SequenceI s);\r
197 \r
198     /**\r
199      * Adds a new SequenceGroup to this alignment.\r
200      *\r
201      * @param sg New group to be added.\r
202      */\r
203     public void addGroup(SequenceGroup sg);\r
204 \r
205     /**\r
206      * Deletes a specific SequenceGroup\r
207      *\r
208      * @param g Group will be deleted from alignment.\r
209      */\r
210     public void deleteGroup(SequenceGroup g);\r
211 \r
212     /**\r
213      * Get all the groups associated with this alignment.\r
214      *\r
215      * @return All groups as a Vector.\r
216      */\r
217     public Vector getGroups();\r
218 \r
219     /**\r
220      * Deletes all groups from this alignment.\r
221      */\r
222     public void deleteAllGroups();\r
223 \r
224     /**\r
225      * Adds a super group. A SuperGroup is a group of groups.\r
226      *\r
227      * @param sg Adds a new SuperGroup to alignment\r
228      */\r
229     public void addSuperGroup(SuperGroup sg);\r
230 \r
231     /**\r
232      * Removes SuperGroup from alignment.\r
233      *\r
234      * @param sg This SuperGroup will be deleted from alignment.\r
235      */\r
236     public void removeSuperGroup(SuperGroup sg);\r
237 \r
238     /**\r
239      * Finds any SuperGroup that a given SequenceGroup may be part of.\r
240      *\r
241      * @param sg SequenceGroup to search for.\r
242      *\r
243      * @return SuperGroup that contains the given SequenceGroup.\r
244      */\r
245     public SuperGroup getSuperGroup(SequenceGroup sg);\r
246 \r
247     /**\r
248      * Adds a new AlignmentAnnotation to this alignment\r
249      */\r
250     public void addAnnotation(AlignmentAnnotation aa);\r
251 \r
252     /**\r
253      * Deletes a specific AlignmentAnnotation from the alignment.\r
254      *\r
255      * @param aa DOCUMENT ME!\r
256      */\r
257     public void deleteAnnotation(AlignmentAnnotation aa);\r
258 \r
259     /**\r
260      * DOCUMENT ME!\r
261      *\r
262      * @return DOCUMENT ME!\r
263      */\r
264     public AlignmentAnnotation[] getAlignmentAnnotation();\r
265 \r
266     /**\r
267      * DOCUMENT ME!\r
268      *\r
269      * @param gc DOCUMENT ME!\r
270      */\r
271     public void setGapCharacter(char gc);\r
272 \r
273     /**\r
274      * DOCUMENT ME!\r
275      *\r
276      * @return DOCUMENT ME!\r
277      */\r
278     public char getGapCharacter();\r
279 \r
280     /**\r
281      * DOCUMENT ME!\r
282      *\r
283      * @return DOCUMENT ME!\r
284      */\r
285     public Vector getAAFrequency();\r
286 \r
287     /**\r
288      * Returns true if alignment is nucleotide sequence\r
289      *\r
290      * @return DOCUMENT ME!\r
291      */\r
292     public boolean isNucleotide();\r
293 \r
294     /**\r
295      * Set true if the alignment is a nucleotide sequence\r
296      *\r
297      * @return\r
298      */\r
299     public void setNucleotide(boolean b);\r
300 \r
301 \r
302     public Alignment getDataset();\r
303 \r
304     public void setDataset(Alignment dataset);\r
305 \r
306     public Provenance getProvenance();\r
307 \r
308     public void setProvenance(Provenance prov);\r
309 \r
310 \r
311 \r
312 }\r