15309b7ea77fb3f2449c2691748e2c6b52071acf
[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     sequences = seqcigararray.getSeqCigarArray();
28   }
29
30   public void setSequences(SeqCigar[] sequences)
31   {
32     this.sequences = sequences;
33   }
34
35   public void setContigs(int[] contigs)
36   {
37     this.contigs = contigs;
38   }
39
40   public SeqCigar[] getSequences()
41   {
42     return sequences;
43   }
44
45   public int[] getContigs()
46   {
47     return contigs;
48   }
49   public Object[] getAlignmentAndColumnSelection(char gapCharacter) {
50     ColumnSelection colsel = new ColumnSelection();
51
52     return new Object[] { SeqCigar.createAlignmentSequences(sequences, gapCharacter, colsel), colsel};
53   }
54   /**
55    * getSequenceStrings
56    *
57    * @param c char
58    * @return String[]
59    */
60   public String[] getSequenceStrings(char c)
61   {
62     String[] seqs=new String[sequences.length];
63     for (int n=0; n<sequences.length; n++) {
64       seqs[n] = sequences[n].getSequenceString(c);
65     }
66     return seqs;
67   }
68 }