Debian Codegraph @

src/dr/app/beauti/datapanel/BeautiAlignmentBuffer.java

raw symbols SCIP
1 /*
2 * BeautiAlignmentBuffer.java
3 *
4 * Copyright (c) 2002-2015 Alexei Drummond, Andrew Rambaut and Marc Suchard
5 *
6 * This file is part of BEAST.
7 * See the NOTICE file distributed with this work for additional
8 * information regarding copyright ownership and licensing.
9 *
10 * BEAST is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as
12 * published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * BEAST is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with BEAST; if not, write to the
22 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23 * Boston, MA 02110-1301 USA
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 * @author Andrew Rambaut
39 * @version $Id: SimpleAlignmentBuffer.java,v 1.2 2005/12/11 22:41:25 rambaut Exp $
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 }