2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3 * Copyright (C) 2014 The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.datamodel;
26 * Data structure to hold and manipulate a multiple sequence alignment
28 public interface AlignmentI extends AnnotatedCollectionI
31 * Calculates the number of sequences in an alignment
33 * @return Number of sequences in alignment
35 public int getHeight();
38 * Calculates the maximum width of the alignment, including gaps.
40 * @return Greatest sequence length within alignment.
43 public int getWidth();
46 * Calculates if this set of sequences (visible and invisible) are all the
49 * @return true if all sequences in alignment are the same length
51 public boolean isAligned();
54 * Calculates if this set of sequences is all the same length
56 * @param includeHidden
57 * optionally exclude hidden sequences from test
58 * @return true if all (or just visible) sequences are the same length
60 public boolean isAligned(boolean includeHidden);
63 * Gets sequences as a Synchronized collection
65 * @return All sequences in alignment.
68 public List<SequenceI> getSequences();
71 * Gets sequences as a SequenceI[]
73 * @return All sequences in alignment.
75 public SequenceI[] getSequencesArray();
78 * Find a specific sequence in this alignment.
81 * Index of required sequence.
83 * @return SequenceI at given index.
85 public SequenceI getSequenceAt(int i);
88 * Add a new sequence to this alignment.
91 * New sequence will be added at end of alignment.
93 public void addSequence(SequenceI seq);
96 * Used to set a particular index of the alignment with the given sequence.
99 * Index of sequence to be updated.
101 * New sequence to be inserted.
103 public void setSequenceAt(int i, SequenceI seq);
106 * Deletes a sequence from the alignment
109 * Sequence to be deleted.
111 public void deleteSequence(SequenceI s);
114 * Deletes a sequence from the alignment.
117 * Index of sequence to be deleted.
119 public void deleteSequence(int i);
122 * Finds sequence in alignment using sequence name as query.
125 * Id of sequence to search for.
127 * @return Sequence matching query, if found. If not found returns null.
129 public SequenceI findName(String name);
131 public SequenceI[] findSequenceMatch(String name);
134 * Finds index of a given sequence in the alignment.
137 * Sequence to look for.
139 * @return Index of sequence within the alignment or -1 if not found
141 public int findIndex(SequenceI s);
144 * Finds group that given sequence is part of.
147 * Sequence in alignment.
149 * @return First group found for sequence. WARNING : Sequences may be members
150 * of several groups. This method is incomplete.
152 public SequenceGroup findGroup(SequenceI s);
155 * Finds all groups that a given sequence is part of.
158 * Sequence in alignment.
160 * @return All groups containing given sequence.
162 public SequenceGroup[] findAllGroups(SequenceI s);
165 * Adds a new SequenceGroup to this alignment.
168 * New group to be added.
170 public void addGroup(SequenceGroup sg);
173 * Deletes a specific SequenceGroup
176 * Group will be deleted from alignment.
178 public void deleteGroup(SequenceGroup g);
181 * Get all the groups associated with this alignment.
183 * @return All groups as a list.
185 public List<SequenceGroup> getGroups();
188 * Deletes all groups from this alignment.
190 public void deleteAllGroups();
193 * Adds a new AlignmentAnnotation to this alignment
195 * @note Care should be taken to ensure that annotation is at least as wide as
196 * the longest sequence in the alignment for rendering purposes.
198 public void addAnnotation(AlignmentAnnotation aa);
201 * moves annotation to a specified index in alignment annotation display stack
204 * the annotation object to be moved
206 * the destination position
208 public void setAnnotationIndex(AlignmentAnnotation aa, int index);
211 * Deletes a specific AlignmentAnnotation from the alignment, and removes its
212 * reference from any SequenceI or SequenceGroup object's annotation if and
213 * only if aa is contained within the alignment's annotation vector.
214 * Otherwise, it will do nothing.
217 * the annotation to delete
218 * @return true if annotation was deleted from this alignment.
220 public boolean deleteAnnotation(AlignmentAnnotation aa);
223 * Deletes a specific AlignmentAnnotation from the alignment, and optionally
224 * removes any reference from any SequenceI or SequenceGroup object's
225 * annotation if and only if aa is contained within the alignment's annotation
226 * vector. Otherwise, it will do nothing.
229 * the annotation to delete
231 * flag indicating if any references should be removed from
232 * annotation - use this if you intend to add the annotation back
234 * @return true if annotation was deleted from this alignment.
236 public boolean deleteAnnotation(AlignmentAnnotation aa, boolean unhook);
239 * Get the annotation associated with this alignment (this can be null if no
240 * annotation has ever been created on the alignment)
242 * @return array of AlignmentAnnotation objects
245 public AlignmentAnnotation[] getAlignmentAnnotation();
248 * Change the gap character used in this alignment to 'gc'
251 * the new gap character.
253 public void setGapCharacter(char gc);
256 * Get the gap character used in this alignment
258 * @return gap character
260 public char getGapCharacter();
263 * Test for all nucleotide alignment
265 * @return true if alignment is nucleotide sequence
267 public boolean isNucleotide();
270 * Test if alignment contains RNA structure
272 * @return true if RNA structure AligmnentAnnotation was added to alignment
274 public boolean hasRNAStructure();
277 * Set alignment to be a nucleotide sequence
280 public void setNucleotide(boolean b);
283 * Get the associated dataset for the alignment.
285 * @return Alignment containing dataset sequences or null of this is a
288 public Alignment getDataset();
291 * Set the associated dataset for the alignment, or create one.
294 * The dataset alignment or null to construct one.
296 public void setDataset(Alignment dataset);
299 * pads sequences with gaps (to ensure the set looks like an alignment)
301 * @return boolean true if alignment was modified
303 public boolean padGaps();
305 public HiddenSequences getHiddenSequences();
308 * Compact representation of alignment
312 public CigarArray getCompactAlignment();
315 * Set an arbitrary key value pair for an alignment. Note: both key and value
316 * objects should return a meaningful, human readable response to .toString()
321 public void setProperty(Object key, Object value);
324 * Get a named property from the alignment.
327 * @return value of property
329 public Object getProperty(Object key);
332 * Get the property hashtable.
334 * @return hashtable of alignment properties (or null if none are defined)
336 public Hashtable getProperties();
339 * add a reference to a frame of aligned codons for this alignment
343 public void addCodonFrame(AlignedCodonFrame codons);
346 * remove a particular codon frame reference from this alignment
349 * @return true if codon frame was removed.
351 public boolean removeCodonFrame(AlignedCodonFrame codons);
354 * get all codon frames associated with this alignment
358 public AlignedCodonFrame[] getCodonFrames();
361 * get a particular codon frame
366 public AlignedCodonFrame getCodonFrame(int index);
369 * get codon frames involving sequenceI
371 public AlignedCodonFrame[] getCodonFrame(SequenceI seq);
374 * find sequence with given name in alignment
379 * true implies that case insensitive matching will <em>also</em> be
381 * @return matched sequence or null
383 public SequenceI findName(String token, boolean b);
386 * find next sequence with given name in alignment starting after a given
390 * the sequence after which the search will be started (usually the
391 * result of the last call to findName)
395 * true implies that case insensitive matching will <em>also</em> be
397 * @return matched sequence or null
399 public SequenceI findName(SequenceI startAfter, String token, boolean b);
402 * find first sequence in alignment which is involved in the given search
406 * @return -1 or index of sequence in alignment
408 public int findIndex(SearchResults results);
411 * append sequences and annotation from another alignment object to this one.
412 * Note: this is a straight transfer of object references, and may result in
413 * toappend's dependent data being transformed to fit the alignment (changing
414 * gap characters, etc...). If you are uncertain, use the copy Alignment copy
415 * constructor to create a new version which can be appended without side
419 * - the alignment to be appended.
421 public void append(AlignmentI toappend);
424 * Justify the sequences to the left or right by deleting and inserting gaps
425 * before the initial residue or after the terminal residue
428 * true if alignment padded to right, false to justify to left
429 * @return true if alignment was changed TODO: return undo object
431 public boolean justify(boolean right);
434 * add given annotation row at given position (0 is start, -1 is end)
439 public void addAnnotation(AlignmentAnnotation consensus, int i);
442 * search for or create a specific annotation row on the alignment
445 * name for annotation (must match)
447 * calcId for the annotation (null or must match)
449 * - value of autocalc flag for the annotation
451 * - null or specific sequence reference
453 * - null or specific group reference
455 * - CalcId for the annotation (must match)
457 * @return existing annotation matching the given attributes
459 public AlignmentAnnotation findOrCreateAnnotation(String name,
460 String calcId, boolean autoCalc, SequenceI seqRef,
461 SequenceGroup groupRef);
464 * move the given group up or down in the alignment by the given number of
465 * rows. Implementor assumes given group is already present on alignment - no
466 * recalculations are triggered.
473 public void moveSelectedSequencesByOne(SequenceGroup sg,
474 Map<SequenceI, SequenceCollectionI> map, boolean up);
477 * validate annotation after an edit and update any alignment state flags
480 * @param alignmentAnnotation
482 public void validateAnnotation(AlignmentAnnotation alignmentAnnotation);