2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
3 * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
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 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
18 package jalview.datamodel;
21 import java.util.Vector;
23 import fr.orsay.lri.varna.models.rna.RNA;
31 public interface SequenceI
34 * Set the display name for the sequence
38 public void setName(String name);
41 * Get the display name
43 public String getName();
46 * Set start position of first non-gapped symbol in sequence
51 public void setStart(int start);
54 * get start position of first non-gapped residue in sequence
58 public int getStart();
61 * get the displayed id of the sequence
63 * @return true means the id will be returned in the form
64 * DisplayName/Start-End
66 public String getDisplayId(boolean jvsuffix);
69 * set end position for last residue in sequence
73 public void setEnd(int end);
76 * get end position for last residue in sequence getEnd()>getStart() unless
77 * sequence only consists of gap characters
84 * @return length of sequence including gaps
87 public int getLength();
90 * Replace the sequence with the given string
95 public void setSequence(String sequence);
98 * @return sequence as string
100 public String getSequenceAsString();
103 * get a range on the seuqence as a string
110 * @return DOCUMENT ME!
112 public String getSequenceAsString(int start, int end);
117 * @return DOCUMENT ME!
119 public char[] getSequence();
122 * get stretch of sequence characters in an array
125 * absolute index into getSequence()
127 * exclusive index of last position in segment to be returned.
129 * @return char[max(0,end-start)];
131 public char[] getSequence(int start, int end);
134 * create a new sequence object from start to end of this sequence
142 public SequenceI getSubSequence(int start, int end);
150 * @return DOCUMENT ME!
152 public char getCharAt(int i);
160 public void setDescription(String desc);
165 * @return DOCUMENT ME!
167 public String getDescription();
170 * Return the alignment column for a sequence position
171 * * Return the alignment position for a sequence position
174 * lying from start to end
176 * @return aligned column for residue (0 if residue is upstream from alignment, -1 if residue is downstream from alignment)
177 * note. Sequence object returns sequence.getEnd() for positions upstream currently. TODO: change sequence for assert(findIndex(seq.getEnd()+1)==-1) and fix incremental bugs
180 public int findIndex(int pos);
183 * Returns the sequence position for an alignment position
186 * column index in alignment (from 1)
188 * @return residue number for residue (left of and) nearest ith column
190 public int findPosition(int i);
193 * Returns an int array where indices correspond to each residue in the
194 * sequence and the element value gives its position in the alignment
196 * @return int[SequenceI.getEnd()-SequenceI.getStart()+1] or null if no
197 * residues in SequenceI object
199 public int[] gapMap();
202 * Returns an int array where indices correspond to each position in sequence
203 * char array and the element value gives the result of findPosition for that
204 * index in the sequence.
206 * @return int[SequenceI.getLength()]
208 public int[] findPositionMap();
211 * Delete a range of aligned sequence columns, creating a new dataset sequence
212 * if necessary and adjusting start and end positions accordingly.
215 * first column in range to delete
217 * last column in range to delete
219 public void deleteChars(int i, int j);
229 public void insertCharAt(int i, char c);
239 public void insertCharAt(int i, int length, char c);
244 * @return DOCUMENT ME!
246 public SequenceFeature[] getSequenceFeatures();
254 public void setSequenceFeatures(SequenceFeature[] features);
262 public void setPDBId(Vector ids);
267 * @return DOCUMENT ME!
269 public Vector getPDBId();
272 * add entry to the vector of PDBIds, if it isn't in the list already
276 public void addPDBId(PDBEntry entry);
279 * update the list of PDBEntrys to include any DBRefEntrys citing structural
282 * @return true if PDBEntry list was modified
284 public boolean updatePDBIds();
286 public String getVamsasId();
288 public void setVamsasId(String id);
290 public void setDBRef(DBRefEntry[] dbs);
292 public DBRefEntry[] getDBRef();
295 * add the given entry to the list of DBRefs for this sequence, or replace a
296 * similar one if entry contains a map object and the existing one doesnt.
300 public void addDBRef(DBRefEntry entry);
302 public void addSequenceFeature(SequenceFeature sf);
304 public void deleteFeature(SequenceFeature sf);
306 public void setDatasetSequence(SequenceI seq);
308 public SequenceI getDatasetSequence();
310 public AlignmentAnnotation[] getAnnotation();
312 public void addAlignmentAnnotation(AlignmentAnnotation annotation);
314 public void removeAlignmentAnnotation(AlignmentAnnotation annotation);
317 * Derive a sequence (using this one's dataset or as the dataset)
319 * @return duplicate sequence with valid dataset sequence
321 public SequenceI deriveSequence();
324 * set the array of associated AlignmentAnnotation for this sequenceI
328 public void setAlignmentAnnotation(AlignmentAnnotation[] annotation);
331 * Get one or more alignment annotations with a particular label.
334 * string which each returned annotation must have as a label.
335 * @return null or array of annotations.
337 public AlignmentAnnotation[] getAnnotation(String label);
340 * create a new dataset sequence (if necessary) for this sequence and sets
341 * this sequence to refer to it. This call will move any features or
342 * references on the sequence onto the dataset.
344 * @return dataset sequence for this sequence
346 public SequenceI createDatasetSequence();
349 * Transfer any database references or annotation from entry under a sequence
354 * null or mapping from entry's numbering to local start/end
356 public void transferAnnotation(SequenceI entry, Mapping mp);
359 * @param index The sequence index in the MSA
361 public void setIndex(int index);
364 * @return The index of the sequence in the alignment
366 public int getIndex();
369 * @return The RNA of the sequence in the alignment
375 * @param rna The RNA.
377 public void setRNA(RNA rna);