2 * Jalview - A Sequence Alignment Editor and Viewer
3 * Copyright (C) 2007 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;
23 /** Data structure to hold and manipulate a multiple sequence alignment
25 public interface AlignmentI
28 * Calculates the number of sequences in an alignment
30 * @return Number of sequences in alignment
32 public int getHeight();
35 * Calculates the maximum width of the alignment, including gaps.
37 * @return Greatest sequence length within alignment.
39 public int getWidth();
42 * Calculates if this set of sequences is all the same length
44 * @return true if all sequences in alignment are the same length
46 public boolean isAligned();
49 * Gets sequences as a Vector
51 * @return All sequences in alignment.
53 public Vector getSequences();
56 * Gets sequences as a SequenceI[]
58 * @return All sequences in alignment.
60 public SequenceI[] getSequencesArray();
63 * Find a specific sequence in this alignment.
65 * @param i Index of required sequence.
67 * @return SequenceI at given index.
69 public SequenceI getSequenceAt(int i);
72 * Add a new sequence to this alignment.
74 * @param seq New sequence will be added at end of alignment.
76 public void addSequence(SequenceI seq);
79 * Used to set a particular index of the alignment with the given sequence.
81 * @param i Index of sequence to be updated.
82 * @param seq New sequence to be inserted.
84 public void setSequenceAt(int i, SequenceI seq);
87 * Deletes a sequence from the alignment
89 * @param s Sequence to be deleted.
91 public void deleteSequence(SequenceI s);
94 * Deletes a sequence from the alignment.
96 * @param i Index of sequence to be deleted.
98 public void deleteSequence(int i);
101 * Finds sequence in alignment using sequence name as query.
103 * @param name Id of sequence to search for.
105 * @return Sequence matching query, if found. If not found returns null.
107 public SequenceI findName(String name);
109 public SequenceI[] findSequenceMatch(String name);
112 * Finds index of a given sequence in the alignment.
114 * @param s Sequence to look for.
116 * @return Index of sequence within the alignment.
118 public int findIndex(SequenceI s);
121 * Finds group that given sequence is part of.
123 * @param s Sequence in alignment.
125 * @return First group found for sequence. WARNING :
126 * Sequences may be members of several groups. This method is incomplete.
128 public SequenceGroup findGroup(SequenceI s);
131 * Finds all groups that a given sequence is part of.
133 * @param s Sequence in alignment.
135 * @return All groups containing given sequence.
137 public SequenceGroup[] findAllGroups(SequenceI s);
140 * Adds a new SequenceGroup to this alignment.
142 * @param sg New group to be added.
144 public void addGroup(SequenceGroup sg);
147 * Deletes a specific SequenceGroup
149 * @param g Group will be deleted from alignment.
151 public void deleteGroup(SequenceGroup g);
154 * Get all the groups associated with this alignment.
156 * @return All groups as a Vector.
158 public Vector getGroups();
162 * Deletes all groups from this alignment.
164 public void deleteAllGroups();
167 * Adds a new AlignmentAnnotation to this alignment
168 * @note Care should be taken to ensure that annotation is at
169 * least as wide as the longest sequence in the alignment
170 * for rendering purposes.
172 public void addAnnotation(AlignmentAnnotation aa);
174 * moves annotation to a specified index in alignment annotation display stack
175 * @param aa the annotation object to be moved
176 * @param index the destination position
178 public void setAnnotationIndex(AlignmentAnnotation aa, int index);
181 * Deletes a specific AlignmentAnnotation from the alignment,
182 * and removes its reference from any SequenceI object's annotation
183 * if and only if aa is contained within the alignment's annotation
184 * vector. Otherwise, it will do nothing.
186 * @param aa the annotation to delete
187 * @return true if annotation was deleted from this alignment.
189 public boolean deleteAnnotation(AlignmentAnnotation aa);
192 * Get the annotation associated with this alignment
194 * @return array of AlignmentAnnotation objects
196 public AlignmentAnnotation[] getAlignmentAnnotation();
199 * Change the gap character used in this alignment to 'gc'
201 * @param gc the new gap character.
203 public void setGapCharacter(char gc);
206 * Get the gap character used in this alignment
208 * @return gap character
210 public char getGapCharacter();
213 * Test for all nucleotide alignment
215 * @return true if alignment is nucleotide sequence
217 public boolean isNucleotide();
220 * Set alignment to be a nucleotide sequence
223 public void setNucleotide(boolean b);
226 * Get the associated dataset for the alignment.
227 * @return Alignment containing dataset sequences or null of this is a dataset.
229 public Alignment getDataset();
232 * Set the associated dataset for the alignment, or create one.
233 * @param dataset The dataset alignment or null to construct one.
235 public void setDataset(Alignment dataset);
238 * pads sequences with gaps (to ensure the set looks like an alignment)
239 * @return boolean true if alignment was modified
241 public boolean padGaps();
243 public HiddenSequences getHiddenSequences();
246 * Compact representation of alignment
249 public CigarArray getCompactAlignment();
252 * Set an arbitrary key value pair for an alignment.
253 * Note: both key and value objects should return a
254 * meaningful, human readable response to .toString()
258 public void setProperty(Object key, Object value);
260 * Get a named property from the alignment.
262 * @return value of property
264 public Object getProperty(Object key);
266 * Get the property hashtable.
267 * @return hashtable of alignment properties (or null if none are defined)
269 public Hashtable getProperties();