/* * AbstractOutbreak.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.epidemiology.casetocase; import dr.evolution.alignment.PatternList; import dr.evolution.datatype.DataType; import dr.evolution.datatype.GeneralDataType; import dr.evolution.util.Taxa; import dr.evolution.util.Taxon; import dr.evolution.util.TaxonList; import dr.inference.model.AbstractModel; import dr.inference.model.Parameter; import java.util.*; /** * Abstract class for outbreaks. Implements PatternList for ease of compatibility with AbstractTreeLikelihood, * but there is one and only one pattern. * * User: Matthew Hall * Date: 14/04/13 */ public abstract class AbstractOutbreak extends AbstractModel implements PatternList { protected GeneralDataType caseDataType; protected TaxonList taxa; private boolean hasLatentPeriods; protected final boolean hasGeography; private final String CASE_NAME = "hostID"; protected ArrayList cases; protected int infectedSize = 0; public AbstractOutbreak(String name, Taxa taxa){ this(name, taxa, false, true); } public AbstractOutbreak(String name, Taxa taxa, boolean hasLatentPeriods, boolean hasGeography){ super(name); this.taxa = taxa; ArrayList caseNames = new ArrayList(); for(int i=0; i getCases(){ return new ArrayList(cases); } public boolean hasLatentPeriods() { return hasLatentPeriods; } public boolean hasGeography(){ return hasGeography; } // todo this should be in terms of arbitary distance functions, not kernels public abstract double getLatentPeriod(AbstractCase aCase); public double getKernelValue(AbstractCase a, AbstractCase b, SpatialKernel kernel){ if(!hasGeography){ return 1; } else { return kernel.value(getDistance(a,b)); } } // all the kernel values going TO case a (this is symmetric, usually, but potentially might not be) public double[] getKernelValues(AbstractCase aCase, SpatialKernel kernel){ double[] out = new double[cases.size()]; for(int i=0; i asList(){ return taxa.asList(); } public Object getTaxonAttribute(int taxonIndex, String name){ return taxa.getTaxonAttribute(taxonIndex, name); } public Iterator iterator() { if (taxa == null) throw new RuntimeException("Patterns has no TaxonList"); return taxa.iterator(); } }