diff --git a/src/beast/app/beauti/BeautiDiscreteTraitProvider.java b/src/beast/app/beauti/BeautiDiscreteTraitProvider.java index 95410a1..654a5df 100644 --- a/src/beast/app/beauti/BeautiDiscreteTraitProvider.java +++ b/src/beast/app/beauti/BeautiDiscreteTraitProvider.java @@ -34,7 +34,7 @@ public class BeautiDiscreteTraitProvider extends BeautiAlignmentProvider { @Override - List getAlignments(BeautiDoc doc) { + protected List getAlignments(BeautiDoc doc) { try { List trees = new ArrayList(); doc.scrubAll(true, false); diff --git a/src/beast/app/beauti/BeautiLocationTraitProvider.java b/src/beast/app/beauti/BeautiLocationTraitProvider.java index 004d549..2840a45 100644 --- a/src/beast/app/beauti/BeautiLocationTraitProvider.java +++ b/src/beast/app/beauti/BeautiLocationTraitProvider.java @@ -23,7 +23,7 @@ public class BeautiLocationTraitProvider extends BeautiAlignmentProvider { @Override - List getAlignments(BeautiDoc doc) { + protected List getAlignments(BeautiDoc doc) { try { List trees = new ArrayList(); doc.scrubAll(true, false); diff --git a/src/beast/continuous/AbstractMultivariateTraitLikelihood.java b/src/beast/continuous/AbstractMultivariateTraitLikelihood.java index d932d49..e8c6db9 100644 --- a/src/beast/continuous/AbstractMultivariateTraitLikelihood.java +++ b/src/beast/continuous/AbstractMultivariateTraitLikelihood.java @@ -76,7 +76,7 @@ public abstract class AbstractMultivariateTraitLikelihood extends GenericTreeLik protected double[] m_StoredBranchLengths; @Override - public void initAndValidate() throws Exception { + public void initAndValidate() { //super.initAndValidate(); m_branchLengths = new double[0]; m_StoredBranchLengths = new double[0]; @@ -125,7 +125,7 @@ public void initAndValidate() throws Exception { if (dataInput.get() instanceof AlignmentFromTraitMap) { traitMap = ((AlignmentFromTraitMap) dataInput.get()).getTraitMap(); } else { - throw new Exception ("Expected that data input is AlignmentFromTraitMap"); + throw new IllegalArgumentException ("Expected that data input is AlignmentFromTraitMap"); } recalculateTreeLength(); // printInformtion(); @@ -492,7 +492,7 @@ public final double getLogLikelihood() { } @Override - public double calculateLogP() throws Exception { + public double calculateLogP() { logP = getLogLikelihood(); return logP; } diff --git a/src/beast/continuous/IntegratedMultivariateTraitLikelihood.java b/src/beast/continuous/IntegratedMultivariateTraitLikelihood.java index 9a331b9..925feb0 100644 --- a/src/beast/continuous/IntegratedMultivariateTraitLikelihood.java +++ b/src/beast/continuous/IntegratedMultivariateTraitLikelihood.java @@ -113,7 +113,7 @@ public abstract class IntegratedMultivariateTraitLikelihood extends AbstractMult // super(traitName, treeModel, diffusionModel, traitParameter, deltaParameter, missingIndices, cacheBranches, scaleByTime, // useTreeLength, rateModel, driftModels, samplingDensity, reportAsMultivariate, reciprocalRates); - public void initAndValidate() throws Exception { + public void initAndValidate() { super.initAndValidate(); // Delegate caches to helper diff --git a/src/beast/continuous/MultivariateDiffusionModel.java b/src/beast/continuous/MultivariateDiffusionModel.java index 591ae1b..eabb6f9 100644 --- a/src/beast/continuous/MultivariateDiffusionModel.java +++ b/src/beast/continuous/MultivariateDiffusionModel.java @@ -26,12 +26,12 @@ public class MultivariateDiffusionModel extends ContinuousSubstitutionModel { int dimension; @Override - public void initAndValidate() throws Exception { + public void initAndValidate() { //diffusionPrecisionMatrix = this.diffusionPrecisionMatrixParameter = diffusionPrecisionMatrixInput.get(); dimension = (int) Math.sqrt(diffusionPrecisionMatrixParameter.getDimension()); if (dimension * dimension != diffusionPrecisionMatrixParameter.getDimension()) { - throw new Exception ("Dimension of diffusion matrix should be a square"); + throw new IllegalArgumentException ("Dimension of diffusion matrix should be a square"); } calculatePrecisionInfo(); } diff --git a/src/beast/continuous/SampledMultivariateTraitLikelihood.java b/src/beast/continuous/SampledMultivariateTraitLikelihood.java index 0065a1d..bf22d31 100644 --- a/src/beast/continuous/SampledMultivariateTraitLikelihood.java +++ b/src/beast/continuous/SampledMultivariateTraitLikelihood.java @@ -44,7 +44,7 @@ public class SampledMultivariateTraitLikelihood extends AbstractMultivariateTrai public Input initFromTree = new Input("initFromTree","initiliase initial state from tree", false); @Override - public void initAndValidate() throws Exception { + public void initAndValidate() { super.initAndValidate(); if (initFromTree.get()) { Node [] nodes = treeModel.getNodesAsArray(); diff --git a/src/beast/evolution/alignment/AlignmentFromTrait.java b/src/beast/evolution/alignment/AlignmentFromTrait.java index 0d6feef..db84441 100644 --- a/src/beast/evolution/alignment/AlignmentFromTrait.java +++ b/src/beast/evolution/alignment/AlignmentFromTrait.java @@ -26,7 +26,7 @@ public AlignmentFromTrait() { } @Override - public void initAndValidate() throws Exception { + public void initAndValidate() { traitSet = traitInput.get(); patternIndex = new int[0]; counts = new ArrayList>(); @@ -37,12 +37,17 @@ public void initAndValidate() throws Exception { m_dataType = userDataTypeInput.get(); } else { if (types.indexOf(dataTypeInput.get()) < 0) { - throw new Exception("data type + '" + dataTypeInput.get() + "' cannot be found. " + + throw new IllegalArgumentException("data type + '" + dataTypeInput.get() + "' cannot be found. " + "Choose one of " + Arrays.toString(types.toArray(new String[0]))); } List sDataTypes = AddOnManager.find(beast.evolution.datatype.DataType.class, IMPLEMENTATION_DIR); for (String sDataType : sDataTypes) { - DataType dataType = (DataType) Class.forName(sDataType).newInstance(); + DataType dataType = null; + try { + dataType = (DataType) Class.forName(sDataType).newInstance(); + } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { + throw new IllegalArgumentException(e); + } if (dataTypeInput.get().equals(dataType.getTypeDescription())) { m_dataType = dataType; break; @@ -61,7 +66,7 @@ public void initAndValidate() throws Exception { for (int i = 0; i < taxaNames.size(); i++) { String sValue = traitSet.getStringValue(i); if (sValue == null) { - throw new Exception("Trait not specified for " + i); + throw new IllegalArgumentException("Trait not specified for " + i); } List iStates = m_dataType.string2state(sValue); counts.add(iStates); diff --git a/src/beast/evolution/alignment/AlignmentFromTraitMap.java b/src/beast/evolution/alignment/AlignmentFromTraitMap.java index 1589271..04b5a61 100644 --- a/src/beast/evolution/alignment/AlignmentFromTraitMap.java +++ b/src/beast/evolution/alignment/AlignmentFromTraitMap.java @@ -27,7 +27,7 @@ public AlignmentFromTraitMap() { } @Override - public void initAndValidate() throws Exception { + public void initAndValidate() { traitMap = traitInput.get(); patternIndex = new int[0]; counts = new ArrayList>(); @@ -36,7 +36,7 @@ public void initAndValidate() throws Exception { } m_dataType = userDataTypeInput.get(); if (!(m_dataType instanceof ContinuousDataType)) { - throw new Exception("Data type must be a ContinuousDataType, not " + m_dataType.getClass().getName()); + throw new IllegalArgumentException("Data type must be a ContinuousDataType, not " + m_dataType.getClass().getName()); } taxaNames = new ArrayList(); diff --git a/src/beast/evolution/datatype/ContinuousDataType.java b/src/beast/evolution/datatype/ContinuousDataType.java index 95fa96d..9971fc5 100644 --- a/src/beast/evolution/datatype/ContinuousDataType.java +++ b/src/beast/evolution/datatype/ContinuousDataType.java @@ -22,7 +22,7 @@ public int getStateCount() { } @Override - public List string2state(String sSequence) throws Exception { + public List string2state(String sSequence) { return null; } diff --git a/src/beast/evolution/datatype/LocationDataType.java b/src/beast/evolution/datatype/LocationDataType.java index 176908d..25caf2e 100644 --- a/src/beast/evolution/datatype/LocationDataType.java +++ b/src/beast/evolution/datatype/LocationDataType.java @@ -6,7 +6,7 @@ public class LocationDataType extends ContinuousDataType { @Override - public void initAndValidate() throws Exception { + public void initAndValidate() { // nothing to do } diff --git a/src/beast/evolution/likelihood/AncestralStateTreeLikelihood.java b/src/beast/evolution/likelihood/AncestralStateTreeLikelihood.java index 189830e..b6d2185 100644 --- a/src/beast/evolution/likelihood/AncestralStateTreeLikelihood.java +++ b/src/beast/evolution/likelihood/AncestralStateTreeLikelihood.java @@ -70,7 +70,7 @@ public class AncestralStateTreeLikelihood extends TreeLikelihood implements Tree int[][] tipStates; // used to store tip states when using beagle @Override - public void initAndValidate() throws Exception { + public void initAndValidate() { if (dataInput.get().getSiteCount() == 0) { return; } @@ -127,7 +127,7 @@ public String getTraitString(TreeInterface tree, Node node) { // } if (beagle != null) { if (!(siteModelInput.get() instanceof SiteModel.Base)) { - throw new Exception ("siteModel input should be of type SiteModel.Base"); + throw new IllegalArgumentException ("siteModel input should be of type SiteModel.Base"); } m_siteModel = (SiteModel.Base) siteModelInput.get(); substitutionModel = (SubstitutionModel.Base) m_siteModel.substModelInput.get(); @@ -179,7 +179,7 @@ public String getTraitString(TreeInterface tree, Node node) { parameters[i] = leafTrait.parameter.get(); // sanity check if (parameters[i].getDimension() != traitDimension) { - throw new Exception("Expected parameter dimension to be " + traitDimension + ", not " + throw new IllegalArgumentException("Expected parameter dimension to be " + traitDimension + ", not " + parameters[i].getDimension()); } // identify node @@ -191,7 +191,7 @@ public String getTraitString(TreeInterface tree, Node node) { leafNr[i] = k; // sanity check if (k == taxaNames.size()) { - throw new Exception("Could not find taxon '" + taxon + "' in tree"); + throw new IllegalArgumentException("Could not find taxon '" + taxon + "' in tree"); } // initialise parameter value from states Integer[] values = new Integer[tipStates[k].length]; @@ -334,7 +334,7 @@ public void redrawAncestralStates() { @Override - public double calculateLogP() throws Exception { + public double calculateLogP() { areStatesRedrawn = false; double marginalLogLikelihood = super.calculateLogP(); if (returnMarginalLogLikelihood) { diff --git a/src/beast/evolution/likelihood/LeafTrait.java b/src/beast/evolution/likelihood/LeafTrait.java index 28cbe8a..daec3f6 100644 --- a/src/beast/evolution/likelihood/LeafTrait.java +++ b/src/beast/evolution/likelihood/LeafTrait.java @@ -11,7 +11,7 @@ public class LeafTrait extends CalculationNode { public Input taxonName = new Input("taxon", "taxon name identifying the leaf", Validate.REQUIRED); public Input parameter = new Input("parameter", "parameter associated with the leaf", Validate.REQUIRED); - public void initAndValidate() throws Exception { + public void initAndValidate() { // nothing to do }; } diff --git a/src/beast/evolution/operators/GMRFSkyrideBlockUpdateOperator.java b/src/beast/evolution/operators/GMRFSkyrideBlockUpdateOperator.java index e933d94..682a583 100644 --- a/src/beast/evolution/operators/GMRFSkyrideBlockUpdateOperator.java +++ b/src/beast/evolution/operators/GMRFSkyrideBlockUpdateOperator.java @@ -48,7 +48,7 @@ public class GMRFSkyrideBlockUpdateOperator extends Operator { private double[] zeros; @Override - public void initAndValidate() throws Exception { + public void initAndValidate() { gmrfField = GMRFSkyrideLikelihoodInput .get(); popSizeParameter = gmrfField.getPopSizeParameter(); precisionParameter = gmrfField.getPrecisionParameter(); @@ -385,7 +385,7 @@ public void optimize(double logAlpha) { } @Override - public List listStateNodes() throws Exception { + public List listStateNodes() { List list = new ArrayList(); list.add(precisionParameter); if (lambdaParameter.isEstimatedInput.get()) { diff --git a/src/beast/evolution/operators/GeneralIntegerOperator.java b/src/beast/evolution/operators/GeneralIntegerOperator.java index 0c81719..f9012e7 100644 --- a/src/beast/evolution/operators/GeneralIntegerOperator.java +++ b/src/beast/evolution/operators/GeneralIntegerOperator.java @@ -28,7 +28,7 @@ public class GeneralIntegerOperator extends Operator { IntegerParameter parameter; @Override - public void initAndValidate() throws Exception { + public void initAndValidate() { howMany = howManyyInput.get(); parameter = parameterInput.get(); @@ -61,7 +61,7 @@ public void initAndValidate() throws Exception { RealParameter probsParam = probsInput.get(); IntegerParameter indexParam = indexInput.get(); if (probsParam.getDimension() != indexParam.getDimension()) { - throw new Exception("probs and index must be of the same length"); + throw new IllegalArgumentException("probs and index must be of the same length"); } Integer [] indices = indexParam.getValues(); int max = 0; @@ -80,7 +80,7 @@ public void initAndValidate() throws Exception { sum += f; } if (Math.abs(sum - 1.0) > 1e-6) { - throw new Exception("Probabilities must sum to one (instead of " + sum + ")"); + throw new IllegalArgumentException("Probabilities must sum to one (instead of " + sum + ")"); } // convert to cumulative pdf diff --git a/src/beast/evolution/operators/PrecisionMatrixGibbsOperator.java b/src/beast/evolution/operators/PrecisionMatrixGibbsOperator.java index a4dec86..093a0f4 100644 --- a/src/beast/evolution/operators/PrecisionMatrixGibbsOperator.java +++ b/src/beast/evolution/operators/PrecisionMatrixGibbsOperator.java @@ -77,7 +77,7 @@ public class PrecisionMatrixGibbsOperator extends Operator { TreeTraitMap traitMap; @Override - public void initAndValidate() throws Exception { + public void initAndValidate() { traitMap = mapInput.get(); treeModel = treeInput.get(); precisionParam = precisionParamInput.get(); diff --git a/src/beast/evolution/operators/RegressionGibbsEffectOperator.java b/src/beast/evolution/operators/RegressionGibbsEffectOperator.java index e4df509..3c90ec8 100644 --- a/src/beast/evolution/operators/RegressionGibbsEffectOperator.java +++ b/src/beast/evolution/operators/RegressionGibbsEffectOperator.java @@ -39,7 +39,7 @@ public class RegressionGibbsEffectOperator extends Operator { private double[][] precision = null; @Override - public void initAndValidate() throws Exception { + public void initAndValidate() { this.linearModel = linearModelInput.get(); this.effect = effectInput.get(); this.indicators = indicatorsInput.get(); diff --git a/src/beast/evolution/operators/RegressionGibbsPrecisionOperator.java b/src/beast/evolution/operators/RegressionGibbsPrecisionOperator.java index 941a0bf..571f6d7 100644 --- a/src/beast/evolution/operators/RegressionGibbsPrecisionOperator.java +++ b/src/beast/evolution/operators/RegressionGibbsPrecisionOperator.java @@ -30,7 +30,7 @@ public class RegressionGibbsPrecisionOperator extends Operator { private Gamma prior; @Override - public void initAndValidate() throws Exception { + public void initAndValidate() { //if (!(prior instanceof GammaDistribution)) // throw new RuntimeException("Precision prior must be Gamma"); this.prior = priorInput.get(); diff --git a/src/beast/evolution/operators/SphereRandomWalker.java b/src/beast/evolution/operators/SphereRandomWalker.java index 7fd109c..89d716a 100644 --- a/src/beast/evolution/operators/SphereRandomWalker.java +++ b/src/beast/evolution/operators/SphereRandomWalker.java @@ -41,7 +41,7 @@ public class SphereRandomWalker extends Operator { boolean optimise = false; @Override - public void initAndValidate() throws Exception { + public void initAndValidate() { location = locationInput.get(); windowSize = windowSizeInput.get(); range = 1 + location.getDimension()/2; diff --git a/src/beast/evolution/operators/TraitGibbsOperator.java b/src/beast/evolution/operators/TraitGibbsOperator.java index 6932e9b..97cb34e 100644 --- a/src/beast/evolution/operators/TraitGibbsOperator.java +++ b/src/beast/evolution/operators/TraitGibbsOperator.java @@ -97,7 +97,7 @@ public class TraitGibbsOperator extends Operator { TreeTraitMap traitMap; @Override - public void initAndValidate() throws Exception { + public void initAndValidate() { traitMap = mapInput.get(); this.traitModel = traitModelInput.get(); diff --git a/src/beast/evolution/substitutionmodel/SVSGeneralSubstitutionModel.java b/src/beast/evolution/substitutionmodel/SVSGeneralSubstitutionModel.java index 3708066..a081b07 100644 --- a/src/beast/evolution/substitutionmodel/SVSGeneralSubstitutionModel.java +++ b/src/beast/evolution/substitutionmodel/SVSGeneralSubstitutionModel.java @@ -2,6 +2,7 @@ +import java.lang.reflect.InvocationTargetException; import java.util.Arrays; import beast.core.Function; @@ -36,14 +37,14 @@ public class SVSGeneralSubstitutionModel extends GeneralSubstitutionModel implem private BooleanParameter rateIndicator; @Override - public void initAndValidate() throws Exception{ + public void initAndValidate(){ frequencies = frequenciesInput.get(); updateMatrix = true; nrOfStates = frequencies.getFreqs().length; if (isSymmetricInput.get() && ratesInput.get().getDimension() != nrOfStates * (nrOfStates-1)/2) { - throw new Exception("Dimension of input 'rates' is " + ratesInput.get().getDimension() + " but a " + + throw new IllegalArgumentException("Dimension of input 'rates' is " + ratesInput.get().getDimension() + " but a " + "rate matrix of dimension " + nrOfStates + "x" + (nrOfStates -1) + "/2" + "=" + nrOfStates * (nrOfStates -1) / 2 + " was " + "expected"); } @@ -62,7 +63,12 @@ public void initAndValidate() throws Exception{ Log.warning.println("WARNING: eigenSystemClass is DefautlEigneSystem, which may cause trouble with asymtric analysis. " + "You may want to consider eigensystem='beast.evolution.substitutionmodel.RobustEigenSystem' instead."); } - eigenSystem = createEigenSystem(); + try { + eigenSystem = createEigenSystem(); + } catch (SecurityException | ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException + | InvocationTargetException e) { + throw new IllegalArgumentException(e); + } // if (robust.get()){ // eigenSystem = new RobustEigenSystem(m_nStates); diff --git a/src/beast/evolution/substitutionmodel/SVSGeneralSubstitutionModelLogger.java b/src/beast/evolution/substitutionmodel/SVSGeneralSubstitutionModelLogger.java index db2b94c..715c564 100644 --- a/src/beast/evolution/substitutionmodel/SVSGeneralSubstitutionModelLogger.java +++ b/src/beast/evolution/substitutionmodel/SVSGeneralSubstitutionModelLogger.java @@ -51,7 +51,7 @@ public class SVSGeneralSubstitutionModelLogger extends BEASTObject implements Lo public SVSGeneralSubstitutionModelLogger() { } @Override - public void initAndValidate() throws Exception { + public void initAndValidate() { model = modelInput.get(); } diff --git a/src/beast/evolution/tree/RootTrait.java b/src/beast/evolution/tree/RootTrait.java index dc84b5e..ed2ff72 100644 --- a/src/beast/evolution/tree/RootTrait.java +++ b/src/beast/evolution/tree/RootTrait.java @@ -17,7 +17,7 @@ public class RootTrait extends CalculationNode implements Function, Loggable { RealParameter parameter; int dim; - public void initAndValidate() throws Exception { + public void initAndValidate() { map = mapInput.get(); tree = map.tree; parameter = map.parameterInput.get(); diff --git a/src/beast/evolution/tree/TreeTraitMap.java b/src/beast/evolution/tree/TreeTraitMap.java index 8f84476..21e73f0 100644 --- a/src/beast/evolution/tree/TreeTraitMap.java +++ b/src/beast/evolution/tree/TreeTraitMap.java @@ -40,7 +40,7 @@ public class TreeTraitMap extends CalculationNode implements TreeTrait double [] traitvalues; @Override - public void initAndValidate() throws Exception { + public void initAndValidate() { tree = treeInput.get(); int nNodes = tree.getNodeCount(); parameter = parameterInput.get(); @@ -111,12 +111,12 @@ public void initAndValidate() throws Exception { } String[] sStrs = sTrait.split("="); if (sStrs.length != 2) { - throw new Exception("could not parse trait: " + sTrait); + throw new IllegalArgumentException("could not parse trait: " + sTrait); } String sTaxonID = normalize(sStrs[0]); int iTaxon = sTaxa.indexOf(sTaxonID); if (iTaxon < 0) { - throw new Exception("Trait (" + sTaxonID + ") is not a known taxon. Spelling error perhaps?"); + throw new IllegalArgumentException("Trait (" + sTaxonID + ") is not a known taxon. Spelling error perhaps?"); } String sTraitValue = normalize(sStrs[1]); String [] sTraitValues = sTraitValue.split("\\s"); @@ -129,7 +129,7 @@ public void initAndValidate() throws Exception { } } if (bDone[iTaxon]) { - throw new Exception("Trait for taxon " + sTaxa.get(iTaxon)+ " defined twice"); + throw new IllegalArgumentException("Trait for taxon " + sTaxa.get(iTaxon)+ " defined twice"); } bDone[iTaxon] = true; } diff --git a/src/beast/evolution/tree/TreeTraitProvider.java b/src/beast/evolution/tree/TreeTraitProvider.java index c0627aa..a0594b0 100644 --- a/src/beast/evolution/tree/TreeTraitProvider.java +++ b/src/beast/evolution/tree/TreeTraitProvider.java @@ -133,7 +133,7 @@ public TreeTrait getTreeTrait(String key) { private Map> traits = new HashMap>(); @Override - public void initAndValidate() throws Exception { + public void initAndValidate() { // nothing to do } } diff --git a/src/beast/evolution/tree/TreeWithTraitLogger.java b/src/beast/evolution/tree/TreeWithTraitLogger.java index b64c8a6..3871b35 100644 --- a/src/beast/evolution/tree/TreeWithTraitLogger.java +++ b/src/beast/evolution/tree/TreeWithTraitLogger.java @@ -37,7 +37,7 @@ public class TreeWithTraitLogger extends BEASTObject implements Loggable { Boolean combineParameters; @Override - public void initAndValidate() throws Exception { + public void initAndValidate() { parameters = new ArrayList>(); rates = new ArrayList(); traits = new ArrayList(); @@ -54,7 +54,7 @@ public void initAndValidate() throws Exception { } else if (plugin instanceof Function){ valuables.add((Function) plugin); } else { - throw new Exception ("This entry (id=" + plugin.getID() + ") is not metadata that can be logged with a tree"); + throw new IllegalArgumentException ("This entry (id=" + plugin.getID() + ") is not metadata that can be logged with a tree"); } } } diff --git a/src/beast/evolution/tree/coalescent/GMRFSkyrideLikelihood.java b/src/beast/evolution/tree/coalescent/GMRFSkyrideLikelihood.java index 8cbf81e..515221f 100644 --- a/src/beast/evolution/tree/coalescent/GMRFSkyrideLikelihood.java +++ b/src/beast/evolution/tree/coalescent/GMRFSkyrideLikelihood.java @@ -135,7 +135,7 @@ public GMRFSkyrideLikelihood() { @Override - public void initAndValidate() throws Exception { + public void initAndValidate() { // public GMRFSkyrideLikelihood(List treeList, RealParameter popParameter, RealParameter groupParameter, RealParameter precParameter, // RealParameter lambda, RealParameter beta, RealParameter dMatrix, // boolean timeAwareSmoothing, boolean rescaleByRootHeight) throws Exception { @@ -204,7 +204,7 @@ public void initAndValidate() throws Exception { } @Override - public double calculateLogP() throws Exception { + public double calculateLogP() { logP = getLogLikelihood(); return logP; } diff --git a/src/beast/geo/GeoSpatialDistribution.java b/src/beast/geo/GeoSpatialDistribution.java index 79cb7ef..5bc8c52 100644 --- a/src/beast/geo/GeoSpatialDistribution.java +++ b/src/beast/geo/GeoSpatialDistribution.java @@ -3,8 +3,13 @@ import java.awt.geom.Point2D; +import java.io.IOException; import java.util.List; +import javax.xml.parsers.ParserConfigurationException; + +import org.xml.sax.SAXException; + import beast.core.*; import beast.core.Input.Validate; @@ -30,9 +35,13 @@ public class GeoSpatialDistribution extends CalculationNode implements Multivari public static final String ALL_NODES= "all"; @Override - public void initAndValidate() throws Exception { + public void initAndValidate() { label = labelInput.get(); - regions = Polygon2D.readKMLFile(fileInput.get()); + try { + regions = Polygon2D.readKMLFile(fileInput.get()); + } catch (SAXException | IOException | ParserConfigurationException e) { + throw new IllegalArgumentException(e); + } outside = !insideInput.get(); union = unionInput.get(); } diff --git a/src/beast/geo/Polygon2D.java b/src/beast/geo/Polygon2D.java index 27061f1..6785241 100644 --- a/src/beast/geo/Polygon2D.java +++ b/src/beast/geo/Polygon2D.java @@ -494,7 +494,7 @@ public static void readKMLElement(Element element, List polygons) { } } - public static List readKMLFile(String fileName) throws Exception { + public static List readKMLFile(String fileName) throws SAXException, IOException, ParserConfigurationException { List polygons = new ArrayList(); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); //factory.setValidating(true); diff --git a/src/beast/inference/distribution/GeneralizedLinearModel.java b/src/beast/inference/distribution/GeneralizedLinearModel.java index c4ab4e8..b1e94d7 100644 --- a/src/beast/inference/distribution/GeneralizedLinearModel.java +++ b/src/beast/inference/distribution/GeneralizedLinearModel.java @@ -20,7 +20,7 @@ public class GeneralizedLinearModel extends Distribution implements Function { public Input> designMatrixInput = new Input>("dependentParam", "description here", new ArrayList()); @Override - public void initAndValidate() throws Exception { + public void initAndValidate() { this.dependentParam = dependentParamInput.get(); if (dependentParam != null) { diff --git a/src/beast/inference/distribution/LinearRegression.java b/src/beast/inference/distribution/LinearRegression.java index c61ffb5..8873c33 100644 --- a/src/beast/inference/distribution/LinearRegression.java +++ b/src/beast/inference/distribution/LinearRegression.java @@ -12,7 +12,7 @@ public class LinearRegression extends GeneralizedLinearModel { public Input scaleDesignInput = new Input("scaleDesign", "description here"); @Override - public void initAndValidate() throws Exception { + public void initAndValidate() { super.initAndValidate(); this.logTransform = logTransformInput.get(); diff --git a/src/beast/inference/distribution/LogisticRegression.java b/src/beast/inference/distribution/LogisticRegression.java index 33eb0b9..06144ae 100644 --- a/src/beast/inference/distribution/LogisticRegression.java +++ b/src/beast/inference/distribution/LogisticRegression.java @@ -8,7 +8,7 @@ public class LogisticRegression extends GeneralizedLinearModel { @Override - public void initAndValidate() throws Exception { + public void initAndValidate() { super.initAndValidate(); } diff --git a/src/beast/math/distributions/MultivariateNormalDistribution.java b/src/beast/math/distributions/MultivariateNormalDistribution.java index cfdea96..8597075 100644 --- a/src/beast/math/distributions/MultivariateNormalDistribution.java +++ b/src/beast/math/distributions/MultivariateNormalDistribution.java @@ -21,7 +21,7 @@ public class MultivariateNormalDistribution extends Distribution { Function arg; @Override - public void initAndValidate() throws Exception { + public void initAndValidate() { multivariatenormaldistribution = new dr.math.distributions.MultivariateNormalDistribution( mean.get().getValues(), precision.get().getValues()); @@ -29,7 +29,7 @@ public void initAndValidate() throws Exception { } @Override - public double calculateLogP() throws Exception { + public double calculateLogP() { double [] y = new double[arg.getDimension()]; for (int i = 0; i < y.length; i++) { y[i] = arg.getArrayValue(i); diff --git a/src/beast/math/distributions/WishartDistribution.java b/src/beast/math/distributions/WishartDistribution.java index 52090eb..0aee04e 100644 --- a/src/beast/math/distributions/WishartDistribution.java +++ b/src/beast/math/distributions/WishartDistribution.java @@ -20,7 +20,7 @@ public class WishartDistribution extends Distribution { Function arg; @Override - public void initAndValidate() throws Exception { + public void initAndValidate() { if (scaleMatrix.get() != null) { wishartdistribution = new dr.math.distributions.WishartDistribution(df.get(), scaleMatrix.get().getValues()); } else { @@ -30,7 +30,7 @@ public void initAndValidate() throws Exception { } @Override - public double calculateLogP() throws Exception { + public double calculateLogP() { double [] y = new double[arg.getDimension()]; for (int i = 0; i < y.length; i++) { y[i] = arg.getArrayValue(i);