JAL-1432 updated copyright notices
[jalview.git] / src / jalview / datamodel / SequenceI.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
3  * Copyright (C) 2014 The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
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.
10  *  
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.
15  * 
16  * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
17  * The Jalview Authors are detailed in the 'AUTHORS' file.
18  */
19 package jalview.datamodel;
20
21 import java.util.Vector;
22
23 /**
24  * DOCUMENT ME!
25  * 
26  * @author $author$
27  * @version $Revision$
28  */
29 public interface SequenceI
30 {
31   /**
32    * Set the display name for the sequence
33    * 
34    * @param name
35    */
36   public void setName(String name);
37
38   /**
39    * Get the display name
40    */
41   public String getName();
42
43   /**
44    * Set start position of first non-gapped symbol in sequence
45    * 
46    * @param start
47    *          new start position
48    */
49   public void setStart(int start);
50
51   /**
52    * get start position of first non-gapped residue in sequence
53    * 
54    * @return
55    */
56   public int getStart();
57
58   /**
59    * get the displayed id of the sequence
60    * 
61    * @return true means the id will be returned in the form
62    *         DisplayName/Start-End
63    */
64   public String getDisplayId(boolean jvsuffix);
65
66   /**
67    * set end position for last residue in sequence
68    * 
69    * @param end
70    */
71   public void setEnd(int end);
72
73   /**
74    * get end position for last residue in sequence getEnd()>getStart() unless
75    * sequence only consists of gap characters
76    * 
77    * @return
78    */
79   public int getEnd();
80
81   /**
82    * @return length of sequence including gaps
83    * 
84    */
85   public int getLength();
86
87   /**
88    * Replace the sequence with the given string
89    * 
90    * @param sequence
91    *          new sequence string
92    */
93   public void setSequence(String sequence);
94
95   /**
96    * @return sequence as string
97    */
98   public String getSequenceAsString();
99
100   /**
101    * get a range on the sequence as a string
102    * 
103    * @param start
104    *          position relative to start of sequence including gaps (from 0)
105    * @param end
106    *          position relative to start of sequence including gaps (from 0)
107    * 
108    * @return String containing all gap and symbols in specified range
109    */
110   public String getSequenceAsString(int start, int end);
111
112   /**
113    * Get the sequence as a character array
114    * 
115    * @return seqeunce and any gaps
116    */
117   public char[] getSequence();
118
119   /**
120    * get stretch of sequence characters in an array
121    * 
122    * @param start
123    *          absolute index into getSequence()
124    * @param end
125    *          exclusive index of last position in segment to be returned.
126    * 
127    * @return char[max(0,end-start)];
128    */
129   public char[] getSequence(int start, int end);
130
131   /**
132    * create a new sequence object from start to end of this sequence
133    * 
134    * @param start
135    *          int
136    * @param end
137    *          int
138    * @return SequenceI
139    */
140   public SequenceI getSubSequence(int start, int end);
141
142   /**
143    * DOCUMENT ME!
144    * 
145    * @param i
146    *          DOCUMENT ME!
147    * 
148    * @return DOCUMENT ME!
149    */
150   public char getCharAt(int i);
151
152   /**
153    * DOCUMENT ME!
154    * 
155    * @param desc
156    *          DOCUMENT ME!
157    */
158   public void setDescription(String desc);
159
160   /**
161    * DOCUMENT ME!
162    * 
163    * @return DOCUMENT ME!
164    */
165   public String getDescription();
166
167   /**
168    * Return the alignment column for a sequence position * Return the alignment
169    * position for a sequence position
170    * 
171    * @param pos
172    *          lying from start to end
173    * 
174    * @return aligned column for residue (0 if residue is upstream from
175    *         alignment, -1 if residue is downstream from alignment) note.
176    *         Sequence object returns sequence.getEnd() for positions upstream
177    *         currently. TODO: change sequence for
178    *         assert(findIndex(seq.getEnd()+1)==-1) and fix incremental bugs
179    * 
180    */
181   public int findIndex(int pos);
182
183   /**
184    * Returns the sequence position for an alignment position
185    * 
186    * @param i
187    *          column index in alignment (from 1)
188    * 
189    * @return residue number for residue (left of and) nearest ith column
190    */
191   public int findPosition(int i);
192
193   /**
194    * Returns an int array where indices correspond to each residue in the
195    * sequence and the element value gives its position in the alignment
196    * 
197    * @return int[SequenceI.getEnd()-SequenceI.getStart()+1] or null if no
198    *         residues in SequenceI object
199    */
200   public int[] gapMap();
201
202   /**
203    * Returns an int array where indices correspond to each position in sequence
204    * char array and the element value gives the result of findPosition for that
205    * index in the sequence.
206    * 
207    * @return int[SequenceI.getLength()]
208    */
209   public int[] findPositionMap();
210
211   /**
212    * Delete a range of aligned sequence columns, creating a new dataset sequence
213    * if necessary and adjusting start and end positions accordingly.
214    * 
215    * @param i
216    *          first column in range to delete
217    * @param j
218    *          last column in range to delete
219    */
220   public void deleteChars(int i, int j);
221
222   /**
223    * DOCUMENT ME!
224    * 
225    * @param i
226    *          DOCUMENT ME!
227    * @param c
228    *          DOCUMENT ME!
229    */
230   public void insertCharAt(int i, char c);
231
232   /**
233    * DOCUMENT ME!
234    * 
235    * @param i
236    *          DOCUMENT ME!
237    * @param c
238    *          DOCUMENT ME!
239    */
240   public void insertCharAt(int i, int length, char c);
241
242   /**
243    * DOCUMENT ME!
244    * 
245    * @return DOCUMENT ME!
246    */
247   public SequenceFeature[] getSequenceFeatures();
248
249   /**
250    * DOCUMENT ME!
251    * 
252    * @param v
253    *          DOCUMENT ME!
254    */
255   public void setSequenceFeatures(SequenceFeature[] features);
256
257   /**
258    * DOCUMENT ME!
259    * 
260    * @param id
261    *          DOCUMENT ME!
262    */
263   public void setPDBId(Vector ids);
264
265   /**
266    * DOCUMENT ME!
267    * 
268    * @return DOCUMENT ME!
269    */
270   public Vector getPDBId();
271
272   /**
273    * add entry to the vector of PDBIds, if it isn't in the list already
274    * 
275    * @param entry
276    */
277   public void addPDBId(PDBEntry entry);
278
279   /**
280    * update the list of PDBEntrys to include any DBRefEntrys citing structural
281    * databases
282    * 
283    * @return true if PDBEntry list was modified
284    */
285   public boolean updatePDBIds();
286
287   public String getVamsasId();
288
289   public void setVamsasId(String id);
290
291   public void setDBRef(DBRefEntry[] dbs);
292
293   public DBRefEntry[] getDBRef();
294
295   /**
296    * add the given entry to the list of DBRefs for this sequence, or replace a
297    * similar one if entry contains a map object and the existing one doesnt.
298    * 
299    * @param entry
300    */
301   public void addDBRef(DBRefEntry entry);
302
303   public void addSequenceFeature(SequenceFeature sf);
304
305   public void deleteFeature(SequenceFeature sf);
306
307   public void setDatasetSequence(SequenceI seq);
308
309   public SequenceI getDatasetSequence();
310
311   public AlignmentAnnotation[] getAnnotation();
312
313   public void addAlignmentAnnotation(AlignmentAnnotation annotation);
314
315   public void removeAlignmentAnnotation(AlignmentAnnotation annotation);
316
317   /**
318    * Derive a sequence (using this one's dataset or as the dataset)
319    * 
320    * @return duplicate sequence with valid dataset sequence
321    */
322   public SequenceI deriveSequence();
323
324   /**
325    * set the array of associated AlignmentAnnotation for this sequenceI
326    * 
327    * @param revealed
328    */
329   public void setAlignmentAnnotation(AlignmentAnnotation[] annotation);
330
331   /**
332    * Get one or more alignment annotations with a particular label.
333    * 
334    * @param label
335    *          string which each returned annotation must have as a label.
336    * @return null or array of annotations.
337    */
338   public AlignmentAnnotation[] getAnnotation(String label);
339
340   /**
341    * create a new dataset sequence (if necessary) for this sequence and sets
342    * this sequence to refer to it. This call will move any features or
343    * references on the sequence onto the dataset.
344    * 
345    * @return dataset sequence for this sequence
346    */
347   public SequenceI createDatasetSequence();
348
349   /**
350    * Transfer any database references or annotation from entry under a sequence
351    * mapping.
352    * 
353    * @param entry
354    * @param mp
355    *          null or mapping from entry's numbering to local start/end
356    */
357   public void transferAnnotation(SequenceI entry, Mapping mp);
358
359   /**
360    * @param index
361    *          The sequence index in the MSA
362    */
363   public void setIndex(int index);
364
365   /**
366    * @return The index of the sequence in the alignment
367    */
368   public int getIndex();
369
370 }