multiple web service jobs from visible blocks of an alignment.
[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   private int width=0;
23   public AlignmentView(CigarArray seqcigararray)
24   {
25     if (!seqcigararray.isSeqCigarArray())
26       throw new Error("Implementation Error - can only make an alignment view from a CigarArray of sequences.");
27     //contigs = seqcigararray.applyDeletions();
28     contigs = seqcigararray.getDeletedRegions();
29     sequences = seqcigararray.getSeqCigarArray();
30     width = seqcigararray.getWidth(); // visible width
31   }
32
33   public void setSequences(SeqCigar[] sequences)
34   {
35     this.sequences = sequences;
36   }
37
38   public void setContigs(int[] contigs)
39   {
40     this.contigs = contigs;
41   }
42
43   public SeqCigar[] getSequences()
44   {
45     return sequences;
46   }
47
48   public int[] getContigs()
49   {
50     return contigs;
51   }
52   public Object[] getAlignmentAndColumnSelection(char gapCharacter) {
53     ColumnSelection colsel = new ColumnSelection();
54
55     return new Object[] { SeqCigar.createAlignmentSequences(sequences, gapCharacter, colsel, contigs), colsel};
56   }
57   /**
58    * getSequenceStrings
59    *
60    * @param c char
61    * @return String[]
62    */
63   public String[] getSequenceStrings(char c)
64   {
65     String[] seqs=new String[sequences.length];
66     for (int n=0; n<sequences.length; n++) {
67       seqs[n] = sequences[n].getSequenceString(c);
68     }
69     return seqs;
70   }
71   /**
72    * 
73    * @return visible number of columns in alignment view
74    */
75   public int getWidth() {
76     return width;
77   }
78
79   protected void setWidth(int width) {
80     this.width = width;
81   }
82   
83 }