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