2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
3 * Copyright (C) 2008 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 is all the same length
45 * @return true if all sequences in alignment are the same length
47 public boolean isAligned();
50 * Gets sequences as a Vector
52 * @return All sequences in alignment.
54 public Vector getSequences();
57 * Gets sequences as a SequenceI[]
59 * @return All sequences in alignment.
61 public SequenceI[] getSequencesArray();
64 * Find a specific sequence in this alignment.
67 * Index of required sequence.
69 * @return SequenceI at given index.
71 public SequenceI getSequenceAt(int i);
74 * Add a new sequence to this alignment.
77 * New sequence will be added at end of alignment.
79 public void addSequence(SequenceI seq);
82 * Used to set a particular index of the alignment with the given sequence.
85 * Index of sequence to be updated.
87 * New sequence to be inserted.
89 public void setSequenceAt(int i, SequenceI seq);
92 * Deletes a sequence from the alignment
95 * Sequence to be deleted.
97 public void deleteSequence(SequenceI s);
100 * Deletes a sequence from the alignment.
103 * Index of sequence to be deleted.
105 public void deleteSequence(int i);
108 * Finds sequence in alignment using sequence name as query.
111 * Id of sequence to search for.
113 * @return Sequence matching query, if found. If not found returns null.
115 public SequenceI findName(String name);
117 public SequenceI[] findSequenceMatch(String name);
120 * Finds index of a given sequence in the alignment.
123 * Sequence to look for.
125 * @return Index of sequence within the alignment or -1 if not found
127 public int findIndex(SequenceI s);
130 * Finds group that given sequence is part of.
133 * Sequence in alignment.
135 * @return First group found for sequence. WARNING : Sequences may be members
136 * of several groups. This method is incomplete.
138 public SequenceGroup findGroup(SequenceI s);
141 * Finds all groups that a given sequence is part of.
144 * Sequence in alignment.
146 * @return All groups containing given sequence.
148 public SequenceGroup[] findAllGroups(SequenceI s);
151 * Adds a new SequenceGroup to this alignment.
154 * New group to be added.
156 public void addGroup(SequenceGroup sg);
159 * Deletes a specific SequenceGroup
162 * Group will be deleted from alignment.
164 public void deleteGroup(SequenceGroup g);
167 * Get all the groups associated with this alignment.
169 * @return All groups as a Vector.
171 public Vector getGroups();
174 * Deletes all groups from this alignment.
176 public void deleteAllGroups();
179 * Adds a new AlignmentAnnotation to this alignment
181 * @note Care should be taken to ensure that annotation is at least as wide as
182 * the longest sequence in the alignment for rendering purposes.
184 public void addAnnotation(AlignmentAnnotation aa);
187 * moves annotation to a specified index in alignment annotation display stack
190 * the annotation object to be moved
192 * the destination position
194 public void setAnnotationIndex(AlignmentAnnotation aa, int index);
197 * Deletes a specific AlignmentAnnotation from the alignment, and removes its
198 * reference from any SequenceI object's annotation if and only if aa is
199 * contained within the alignment's annotation vector. Otherwise, it will do
203 * the annotation to delete
204 * @return true if annotation was deleted from this alignment.
206 public boolean deleteAnnotation(AlignmentAnnotation aa);
209 * Get the annotation associated with this alignment
211 * @return array of AlignmentAnnotation objects
213 public AlignmentAnnotation[] getAlignmentAnnotation();
216 * Change the gap character used in this alignment to 'gc'
219 * the new gap character.
221 public void setGapCharacter(char gc);
224 * Get the gap character used in this alignment
226 * @return gap character
228 public char getGapCharacter();
231 * Test for all nucleotide alignment
233 * @return true if alignment is nucleotide sequence
235 public boolean isNucleotide();
238 * Set alignment to be a nucleotide sequence
241 public void setNucleotide(boolean b);
244 * Get the associated dataset for the alignment.
246 * @return Alignment containing dataset sequences or null of this is a
249 public Alignment getDataset();
252 * Set the associated dataset for the alignment, or create one.
255 * The dataset alignment or null to construct one.
257 public void setDataset(Alignment dataset);
260 * pads sequences with gaps (to ensure the set looks like an alignment)
262 * @return boolean true if alignment was modified
264 public boolean padGaps();
266 public HiddenSequences getHiddenSequences();
269 * Compact representation of alignment
273 public CigarArray getCompactAlignment();
276 * Set an arbitrary key value pair for an alignment. Note: both key and value
277 * objects should return a meaningful, human readable response to .toString()
282 public void setProperty(Object key, Object value);
285 * Get a named property from the alignment.
288 * @return value of property
290 public Object getProperty(Object key);
293 * Get the property hashtable.
295 * @return hashtable of alignment properties (or null if none are defined)
297 public Hashtable getProperties();
300 * add a reference to a frame of aligned codons for this alignment
304 public void addCodonFrame(AlignedCodonFrame codons);
307 * remove a particular codon frame reference from this alignment
310 * @return true if codon frame was removed.
312 public boolean removeCodonFrame(AlignedCodonFrame codons);
315 * get all codon frames associated with this alignment
319 public AlignedCodonFrame[] getCodonFrames();
322 * get a particular codon frame
327 public AlignedCodonFrame getCodonFrame(int index);
330 * get codon frames involving sequenceI
332 public AlignedCodonFrame[] getCodonFrame(SequenceI seq);
335 * find sequence with given name in alignment
340 * true implies that case insensitive matching will
341 * <em>also</em> be tried
342 * @return matched sequence or null
344 public SequenceI findName(String token, boolean b);
347 * find next sequence with given name in alignment starting after a given
351 * the sequence after which the search will be started (usually
352 * the result of the last call to findName)
356 * true implies that case insensitive matching will
357 * <em>also</em> be tried
358 * @return matched sequence or null
360 public SequenceI findName(SequenceI startAfter, String token, boolean b);
363 * find first sequence in alignment which is involved in the given search result object
365 * @return -1 or index of sequence in alignment
367 public int findIndex(SearchResults results);
370 * append sequences and annotation from another alignment object to this one.
371 * Note: this is a straight transfer of object references, and may result in
372 * toappend's dependent data being transformed to fit the alignment (changing gap characters, etc...).
373 * If you are uncertain, use the copy Alignment copy constructor to create a new version
374 * which can be appended without side effect.
375 * @param toappend - the alignment to be appended.
377 public void append(AlignmentI toappend);
379 * Justify the sequences to the left or right by deleting and inserting gaps before the initial residue or after the terminal residue
380 * @param right true if alignment padded to right, false to justify to left
381 * @return true if alignment was changed
383 public boolean justify(boolean right);