refactored hidden regions methods and made an AlignmentView preserve
[jalview.git] / src / jalview / datamodel / AlignmentView.java
1 package jalview.datamodel;
2
3 /**
4  * <p>Title: </p>
5  *
6  * <p>Description: </p>
7  *
8  * <p>Copyright: Copyright (c) 2004</p>
9  *
10  * <p>Company: Dundee University</p>
11  *
12  * @author not attributable
13  * @version 1.0
14  */
15 public class AlignmentView
16 {
17     /**
18      * Transient object compactly representing a 'view' of an alignment - with discontinuities marked.
19      */
20     private SeqCigar[] sequences = null;
21   private int[] contigs = null;
22   public AlignmentView(CigarArray seqcigararray)
23   {
24     if (!seqcigararray.isSeqCigarArray())
25       throw new Error("Implementation Error - can only make an alignment view from a CigarArray of sequences.");
26     //contigs = seqcigararray.applyDeletions();
27     contigs = seqcigararray.getDeletedRegions();
28     sequences = seqcigararray.getSeqCigarArray();
29   }
30
31   public void setSequences(SeqCigar[] sequences)
32   {
33     this.sequences = sequences;
34   }
35
36   public void setContigs(int[] contigs)
37   {
38     this.contigs = contigs;
39   }
40
41   public SeqCigar[] getSequences()
42   {
43     return sequences;
44   }
45
46   public int[] getContigs()
47   {
48     return contigs;
49   }
50   public Object[] getAlignmentAndColumnSelection(char gapCharacter) {
51     ColumnSelection colsel = new ColumnSelection();
52
53     return new Object[] { SeqCigar.createAlignmentSequences(sequences, gapCharacter, colsel, contigs), colsel};
54   }
55   /**
56    * getSequenceStrings
57    *
58    * @param c char
59    * @return String[]
60    */
61   public String[] getSequenceStrings(char c)
62   {
63     String[] seqs=new String[sequences.length];
64     for (int n=0; n<sequences.length; n++) {
65       seqs[n] = sequences[n].getSequenceString(c);
66     }
67     return seqs;
68   }
69 }