/* * HiddenLinkageModel.java * * Copyright (c) 2002-2015 Alexei Drummond, Andrew Rambaut and Marc Suchard * * This file is part of BEAST. * See the NOTICE file distributed with this work for additional * information regarding copyright ownership and licensing. * * BEAST is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * BEAST is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with BEAST; if not, write to the * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA */ package dr.evomodel.tree; import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set; import dr.evolution.MetagenomeData; import dr.evolution.alignment.Alignment; import dr.evolution.alignment.PatternList; import dr.evolution.datatype.DataType; import dr.evolution.util.Taxon; import dr.evolution.util.TaxonList; import dr.oldevomodel.substmodel.SubstitutionModel; import dr.oldevomodel.treelikelihood.GeneralLikelihoodCore; import dr.oldevomodel.treelikelihood.LikelihoodCore; import dr.oldevomodel.treelikelihood.NativeAminoAcidLikelihoodCore; import dr.oldevomodel.treelikelihood.NativeNucleotideLikelihoodCore; import dr.evomodel.tipstatesmodel.TipStatesModel; import dr.inference.model.Model; import dr.inference.model.Variable; import dr.inference.model.Variable.ChangeType; import dr.math.MathUtils; /** * A model of linkage among sets of metagenome sequence reads * Reads are assumed to derive from a fixed number of organisms, where * the identity of the organisms is unknown, and the assignment of reads * to those organisms is also unknown. * @author Aaron Darling (koadman) * */ public class HiddenLinkageModel extends TipStatesModel implements PatternList { int linkageGroupCount = 0; ArrayList< HashSet > groups = null; MetagenomeData data = null; ArrayList alignmentTaxa; double[][] tipPartials; double[][] storedTipPartials; boolean[] dirtyTipPartials; LikelihoodCore core; double blen = 0.001; SubstitutionModel substitutionModel; public HiddenLinkageModel(int linkageGroupCount, MetagenomeData data) { super("HiddenLinkageModel", data.getReferenceTaxa(), data.getReadsTaxa()); this.linkageGroupCount = linkageGroupCount; this.data = data; // initial state: randomly assign reads to groups groups = new ArrayList< HashSet >(linkageGroupCount); for(int i=0; i()); TaxonList reads = data.getReadsTaxa(); for(int i=0; i