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