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