94dbf1b776f93e3590a2dbe9537ddd7acfa7923d
[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     /**
46      * Calculates if this set of sequences is all the same length
47      *
48      * @return true if all sequences in alignment are the same length
49      */
50     public boolean isAligned();
51
52     /**
53      * Gets sequences as a Vector
54      *
55      * @return All sequences in alignment.
56      */
57     public Vector getSequences();
58
59     /**
60      * Gets sequences as a SequenceI[]
61      *
62      * @return All sequences in alignment.
63      */
64     public SequenceI [] getSequencesArray();
65
66     /**
67      * Find a specific sequence in this alignment.
68      *
69      * @param i Index of required sequence.
70      *
71      * @return SequenceI at given index.
72      */
73     public SequenceI getSequenceAt(int i);
74
75     /**
76      * Add a new sequence to this alignment.
77      *
78      * @param seq New sequence will be added at end of alignment.
79      */
80     public void addSequence(SequenceI seq);
81
82     /**
83      * Used to set a particular index of the alignment with the given sequence.
84      *
85      * @param i Index of sequence to be updated.
86      * @param seq New sequence to be inserted.
87      */
88     public void setSequenceAt(int i, SequenceI seq);
89
90     /**
91      * Deletes a sequence from the alignment
92      *
93      * @param s Sequence to be deleted.
94      */
95     public void deleteSequence(SequenceI s);
96
97     /**
98      * Deletes a sequence from the alignment.
99      *
100      * @param i Index of sequence to be deleted.
101      */
102     public void deleteSequence(int i);
103
104
105     /**
106      * Finds sequence in alignment using sequence name as query.
107      *
108      * @param name Id of sequence to search for.
109      *
110      * @return Sequence matching query, if found. If not found returns null.
111      */
112     public SequenceI findName(String name);
113
114     public SequenceI [] findSequenceMatch(String name);
115
116     /**
117      * Finds index of a given sequence in the alignment.
118      *
119      * @param s Sequence to look for.
120      *
121      * @return Index of sequence within the alignment.
122      */
123     public int findIndex(SequenceI s);
124
125
126     /**
127      * Finds group that given sequence is part of.
128      *
129      * @param s Sequence in alignment.
130      *
131      * @return First group found for sequence. WARNING :
132      * Sequences may be members of several groups. This method is incomplete.
133      */
134     public SequenceGroup findGroup(SequenceI s);
135
136     /**
137      * Finds all groups that a given sequence is part of.
138      *
139      * @param s Sequence in alignment.
140      *
141      * @return All groups containing given sequence.
142      */
143     public SequenceGroup[] findAllGroups(SequenceI s);
144
145     /**
146      * Adds a new SequenceGroup to this alignment.
147      *
148      * @param sg New group to be added.
149      */
150     public void addGroup(SequenceGroup sg);
151
152     /**
153      * Deletes a specific SequenceGroup
154      *
155      * @param g Group will be deleted from alignment.
156      */
157     public void deleteGroup(SequenceGroup g);
158
159     /**
160      * Get all the groups associated with this alignment.
161      *
162      * @return All groups as a Vector.
163      */
164     public Vector getGroups();
165
166     /**
167      * Deletes all groups from this alignment.
168      */
169     public void deleteAllGroups();
170
171
172     /**
173      * Adds a new AlignmentAnnotation to this alignment
174      */
175     public void addAnnotation(AlignmentAnnotation aa);
176
177
178     public void setAnnotationIndex(AlignmentAnnotation aa, int index);
179
180     /**
181      * Deletes a specific AlignmentAnnotation from the alignment.
182      *
183      * @param aa DOCUMENT ME!
184      */
185     public void deleteAnnotation(AlignmentAnnotation aa);
186
187     /**
188      * DOCUMENT ME!
189      *
190      * @return DOCUMENT ME!
191      */
192     public AlignmentAnnotation[] getAlignmentAnnotation();
193
194     /**
195      * DOCUMENT ME!
196      *
197      * @param gc DOCUMENT ME!
198      */
199     public void setGapCharacter(char gc);
200
201     /**
202      * DOCUMENT ME!
203      *
204      * @return DOCUMENT ME!
205      */
206     public char getGapCharacter();
207
208
209     /**
210      * Returns true if alignment is nucleotide sequence
211      *
212      * @return DOCUMENT ME!
213      */
214     public boolean isNucleotide();
215
216     /**
217      * Set true if the alignment is a nucleotide sequence
218      *
219      * @return
220      */
221     public void setNucleotide(boolean b);
222
223
224     public Alignment getDataset();
225
226     public void setDataset(Alignment dataset);
227     /**
228      * pads sequences with gaps (to ensure the set looks like an alignment)
229      * @return boolean true if alignment was modified
230      */
231     public boolean padGaps();
232
233     public void adjustSequenceAnnotations();
234
235     public HiddenSequences getHiddenSequences();
236     /**
237      * Compact representation of alignment
238      * @return CigarArray
239      */
240     public CigarArray getCompactAlignment();
241 }