2 * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
3 * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
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.
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.
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
19 package jalview.datamodel;
24 * Data structure to hold and manipulate a multiple sequence alignment
26 public interface AlignmentI
29 * Calculates the number of sequences in an alignment
31 * @return Number of sequences in alignment
33 public int getHeight();
36 * Calculates the maximum width of the alignment, including gaps.
38 * @return Greatest sequence length within alignment.
40 public int getWidth();
43 * Calculates if this set of sequences (visible and invisible) are all the same length
45 * @return true if all sequences in alignment are the same length
47 public boolean isAligned();
49 * Calculates if this set of sequences is all the same length
50 * @param includeHidden optionally exclude hidden sequences from test
51 * @return true if all (or just visible) sequences are the same length
53 public boolean isAligned(boolean includeHidden);
55 * Gets sequences as a Vector
57 * @return All sequences in alignment.
59 public Vector getSequences();
62 * Gets sequences as a SequenceI[]
64 * @return All sequences in alignment.
66 public SequenceI[] getSequencesArray();
69 * Find a specific sequence in this alignment.
72 * Index of required sequence.
74 * @return SequenceI at given index.
76 public SequenceI getSequenceAt(int i);
79 * Add a new sequence to this alignment.
82 * New sequence will be added at end of alignment.
84 public void addSequence(SequenceI seq);
87 * Used to set a particular index of the alignment with the given sequence.
90 * Index of sequence to be updated.
92 * New sequence to be inserted.
94 public void setSequenceAt(int i, SequenceI seq);
97 * Deletes a sequence from the alignment
100 * Sequence to be deleted.
102 public void deleteSequence(SequenceI s);
105 * Deletes a sequence from the alignment.
108 * Index of sequence to be deleted.
110 public void deleteSequence(int i);
113 * Finds sequence in alignment using sequence name as query.
116 * Id of sequence to search for.
118 * @return Sequence matching query, if found. If not found returns null.
120 public SequenceI findName(String name);
122 public SequenceI[] findSequenceMatch(String name);
125 * Finds index of a given sequence in the alignment.
128 * Sequence to look for.
130 * @return Index of sequence within the alignment or -1 if not found
132 public int findIndex(SequenceI s);
135 * Finds group that given sequence is part of.
138 * Sequence in alignment.
140 * @return First group found for sequence. WARNING : Sequences may be members
141 * of several groups. This method is incomplete.
143 public SequenceGroup findGroup(SequenceI s);
146 * Finds all groups that a given sequence is part of.
149 * Sequence in alignment.
151 * @return All groups containing given sequence.
153 public SequenceGroup[] findAllGroups(SequenceI s);
156 * Adds a new SequenceGroup to this alignment.
159 * New group to be added.
161 public void addGroup(SequenceGroup sg);
164 * Deletes a specific SequenceGroup
167 * Group will be deleted from alignment.
169 public void deleteGroup(SequenceGroup g);
172 * Get all the groups associated with this alignment.
174 * @return All groups as a Vector.
176 public Vector getGroups();
179 * Deletes all groups from this alignment.
181 public void deleteAllGroups();
184 * Adds a new AlignmentAnnotation to this alignment
186 * @note Care should be taken to ensure that annotation is at least as wide as
187 * the longest sequence in the alignment for rendering purposes.
189 public void addAnnotation(AlignmentAnnotation aa);
192 * moves annotation to a specified index in alignment annotation display stack
195 * the annotation object to be moved
197 * the destination position
199 public void setAnnotationIndex(AlignmentAnnotation aa, int index);
202 * Deletes a specific AlignmentAnnotation from the alignment, and removes its
203 * reference from any SequenceI object's annotation if and only if aa is
204 * contained within the alignment's annotation vector. Otherwise, it will do
208 * the annotation to delete
209 * @return true if annotation was deleted from this alignment.
211 public boolean deleteAnnotation(AlignmentAnnotation aa);
214 * Get the annotation associated with this alignment
216 * @return array of AlignmentAnnotation objects
218 public AlignmentAnnotation[] getAlignmentAnnotation();
221 * Change the gap character used in this alignment to 'gc'
224 * the new gap character.
226 public void setGapCharacter(char gc);
229 * Get the gap character used in this alignment
231 * @return gap character
233 public char getGapCharacter();
236 * Test for all nucleotide alignment
238 * @return true if alignment is nucleotide sequence
240 public boolean isNucleotide();
243 * Set alignment to be a nucleotide sequence
246 public void setNucleotide(boolean b);
249 * Get the associated dataset for the alignment.
251 * @return Alignment containing dataset sequences or null of this is a
254 public Alignment getDataset();
257 * Set the associated dataset for the alignment, or create one.
260 * The dataset alignment or null to construct one.
262 public void setDataset(Alignment dataset);
265 * pads sequences with gaps (to ensure the set looks like an alignment)
267 * @return boolean true if alignment was modified
269 public boolean padGaps();
271 public HiddenSequences getHiddenSequences();
274 * Compact representation of alignment
278 public CigarArray getCompactAlignment();
281 * Set an arbitrary key value pair for an alignment. Note: both key and value
282 * objects should return a meaningful, human readable response to .toString()
287 public void setProperty(Object key, Object value);
290 * Get a named property from the alignment.
293 * @return value of property
295 public Object getProperty(Object key);
298 * Get the property hashtable.
300 * @return hashtable of alignment properties (or null if none are defined)
302 public Hashtable getProperties();
305 * add a reference to a frame of aligned codons for this alignment
309 public void addCodonFrame(AlignedCodonFrame codons);
312 * remove a particular codon frame reference from this alignment
315 * @return true if codon frame was removed.
317 public boolean removeCodonFrame(AlignedCodonFrame codons);
320 * get all codon frames associated with this alignment
324 public AlignedCodonFrame[] getCodonFrames();
327 * get a particular codon frame
332 public AlignedCodonFrame getCodonFrame(int index);
335 * get codon frames involving sequenceI
337 public AlignedCodonFrame[] getCodonFrame(SequenceI seq);
340 * find sequence with given name in alignment
345 * true implies that case insensitive matching will
346 * <em>also</em> be tried
347 * @return matched sequence or null
349 public SequenceI findName(String token, boolean b);
352 * find next sequence with given name in alignment starting after a given
356 * the sequence after which the search will be started (usually
357 * the result of the last call to findName)
361 * true implies that case insensitive matching will
362 * <em>also</em> be tried
363 * @return matched sequence or null
365 public SequenceI findName(SequenceI startAfter, String token, boolean b);
368 * find first sequence in alignment which is involved in the given search result object
370 * @return -1 or index of sequence in alignment
372 public int findIndex(SearchResults results);
375 * append sequences and annotation from another alignment object to this one.
376 * Note: this is a straight transfer of object references, and may result in
377 * toappend's dependent data being transformed to fit the alignment (changing gap characters, etc...).
378 * If you are uncertain, use the copy Alignment copy constructor to create a new version
379 * which can be appended without side effect.
380 * @param toappend - the alignment to be appended.
382 public void append(AlignmentI toappend);
384 * Justify the sequences to the left or right by deleting and inserting gaps before the initial residue or after the terminal residue
385 * @param right true if alignment padded to right, false to justify to left
386 * @return true if alignment was changed
387 * TODO: return undo object
389 public boolean justify(boolean right);
392 * add given annotation row at given position (0 is start, -1 is end)
396 public void addAnnotation(AlignmentAnnotation consensus, int i);