| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
package dr.app.beauti.datapanel; |
| 27 |
|
| 28 |
|
| 29 |
import java.util.List; |
| 30 |
|
| 31 |
import dr.app.beauti.alignmentviewer.AlignmentBuffer; |
| 32 |
import dr.app.beauti.alignmentviewer.AlignmentBufferListener; |
| 33 |
import dr.evolution.alignment.Alignment; |
| 34 |
import dr.evolution.datatype.DataType; |
| 35 |
import dr.evolution.sequence.Sequence; |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
public class BeautiAlignmentBuffer implements AlignmentBuffer { |
| 42 |
|
| 43 |
public BeautiAlignmentBuffer(Alignment alignment) { |
| 44 |
this.alignment = alignment; |
| 45 |
DataType type = alignment.getDataType(); |
| 46 |
|
| 47 |
stateTable = new String[type.getAmbiguousStateCount()]; |
| 48 |
for (int i = 0; i < stateTable.length; i++) { |
| 49 |
stateTable[i] = Character.toString(type.getChar(i)); |
| 50 |
} |
| 51 |
|
| 52 |
gapState = (byte)type.getGapState(); |
| 53 |
} |
| 54 |
|
| 55 |
public int getSequenceCount() { |
| 56 |
return alignment.getSequenceCount(); |
| 57 |
} |
| 58 |
|
| 59 |
public int getSiteCount() { |
| 60 |
return alignment.getSiteCount(); |
| 61 |
} |
| 62 |
|
| 63 |
public String getTaxonLabel(int i) { |
| 64 |
return alignment.getTaxonId(i); |
| 65 |
} |
| 66 |
|
| 67 |
public String[] getStateTable() { |
| 68 |
return stateTable; |
| 69 |
} |
| 70 |
|
| 71 |
public void getStates(int sequenceIndex, int fromSite, int toSite, byte[] states) { |
| 72 |
Sequence sequence = alignment.getSequence(sequenceIndex); |
| 73 |
int j = 0; |
| 74 |
for (int i = fromSite; i <= toSite; i++) { |
| 75 |
states[j] = (byte)sequence.getState(i); |
| 76 |
j++; |
| 77 |
} |
| 78 |
} |
| 79 |
|
| 80 |
public void addAlignmentBufferListener(AlignmentBufferListener listener) { |
| 81 |
} |
| 82 |
|
| 83 |
private final Alignment alignment; |
| 84 |
private final String[] stateTable; |
| 85 |
private final byte gapState; |
| 86 |
|
| 87 |
} |