Debian Codegraph @

src/dr/evolution/alignment/ShuffledSiteList.java

raw symbols SCIP
1 /*
2 * ShuffledSiteList.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.evolution.alignment;
27
28 import dr.math.MathUtils;
29
30 /**
31 * Provides bootstrap replicate patterns
32 *
33 * @version $Id: ShuffledSiteList.java,v 1.3 2005/04/20 21:26:19 rambaut Exp $
34 *
35 * @author Andrew Rambaut
36 */
37 public class ShuffledSiteList extends ResamplePatterns implements SiteList
38 {
39
40 /**
41 * Constructor
42 */
43 public ShuffledSiteList() {
44 }
45
46 /**
47 * Constructor
48 */
49 public ShuffledSiteList(SiteList patterns) {
50 setPatterns(patterns);
51 }
52
53 public void setPatterns(SiteList patterns) {
54 this.patterns = patterns;
55 resamplePatterns();
56 }
57 /**
58 * Perform a bootstrap resampling of the patterns
59 */
60 public void resamplePatterns() {
61
62 int siteCount = patterns.getSiteCount();
63 siteIndices = MathUtils.shuffled(siteCount);
64 }
65
66 public int getSiteCount() {
67 return siteIndices.length;
68 }
69
70 public int[] getSitePattern(int siteIndex) {
71 return patterns.getSitePattern(siteIndices[siteIndex]);
72 }
73
74 @Override
75 public double[][] getUncertainSitePattern(int siteIndex) {
76 return patterns.getUncertainSitePattern(siteIndices[siteIndex]);
77 }
78
79 public int getPatternIndex(int siteIndex) {
80 return patterns.getPatternIndex(siteIndices[siteIndex]);
81 }
82
83 public int getState(int taxonIndex, int siteIndex) {
84 return patterns.getState(taxonIndex, siteIndices[siteIndex]);
85 }
86
87 @Override
88 public double[] getUncertainState(int taxonIndex, int siteIndex) {
89 return patterns.getUncertainState(taxonIndex, siteIndices[siteIndex]);
90 }
91
92 int siteIndices[] = null;
93
94 @Override
95 public boolean areUncertain() {
96 return false;
97 }
98 }