Skip to content

Commit

Permalink
some changes to exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
fbielejec committed Apr 27, 2015
1 parent 783ffc5 commit d7c3794
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .classpath
Expand Up @@ -15,6 +15,6 @@
<classpathentry kind="lib" path="lib/options.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/commons-math-2.2.jar"/>
<classpathentry kind="lib" path="lib/freemarker.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

1 change: 1 addition & 0 deletions .gitignore
@@ -1,3 +1,4 @@
*.iml
*.ipr
*.iws
bin/
Expand Up @@ -16,6 +16,8 @@
@SuppressWarnings("serial")
public class RandomBranchAssignmentModel extends AbstractModel implements BranchModel {

public static final boolean DEBUG = true;

public static final String RANDOM_BRANCH_ASSIGNMENT_MODEL = "randomBranchAssignmentModel";
private final TreeModel treeModel;
private final List<SubstitutionModel> substitutionModels;
Expand All @@ -40,9 +42,28 @@ public RandomBranchAssignmentModel(TreeModel treeModel,
for (int i = 0; i < nodeCount; i++) {

NodeRef node = treeModel.getNode(i);
int branchClass = MathUtils.nextInt(nModels);
int branchClass = Integer.MAX_VALUE; //MathUtils.nextInt(nModels);

if(DEBUG) {

// System.out.println(node.toString());

// hack to get fixed indexing
if(node.toString().equalsIgnoreCase("node 0, height=0.0: SimSeq1") ||
node.toString().equalsIgnoreCase("node 1, height=0.0: SimSeq2") ||
node.toString().equalsIgnoreCase("node 4, height=22.0")
) {
branchClass = 0; // 5
} else {
branchClass = 1; // 10
}//END: node check

} else {
branchClass = MathUtils.nextInt(nModels);
}//END: DEBUG check

branchAssignmentMap.put(node, branchClass);

}// END: nodes loop

}//END: Constructor
Expand Down
Expand Up @@ -45,8 +45,8 @@ public BeagleBranchLikelihood(TreeModel treeModel,

if(this.treeModel != null) {

this.categoriesProvider = new CountableBranchCategoryProvider.IndependentBranchCategoryModel( treeModel, categoriesParameter);
// this.categoriesProvider = new CountableBranchCategoryProvider.CladeBranchCategoryModel(treeModel, categoriesParameter);
// this.categoriesProvider = new CountableBranchCategoryProvider.IndependentBranchCategoryModel( treeModel, categoriesParameter);
this.categoriesProvider = new CountableBranchCategoryProvider.CladeBranchCategoryModel(treeModel, categoriesParameter);

}

Expand Down
41 changes: 31 additions & 10 deletions src/dr/app/bss/BeagleSequenceSimulatorConsoleApp.java
Expand Up @@ -28,13 +28,16 @@
import dr.app.beagle.tools.BeagleSequenceSimulator;
import dr.app.beagle.tools.Partition;
import dr.app.util.Arguments;
import dr.app.util.Arguments.ArgumentException;
import dr.evolution.alignment.SimpleAlignment;
import dr.evolution.io.Importer.ImportException;
import dr.evolution.tree.Tree;
import dr.evolution.util.Taxa;
import dr.math.MathUtils;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -623,16 +626,34 @@ public void simulate(String[] args) {
writer.println(alignment.toString());
writer.close();

} catch (Exception e) {

System.out.println();
printUsage(arguments);
System.out.println();
System.out.println(e.getMessage());
e.printStackTrace();
System.exit(1);

}// END: try-catch block
} catch (ArgumentException e) {

System.out.println();
printUsage(arguments);
System.out.println();
System.out.println(e.getMessage());
e.printStackTrace();
System.exit(1);

} catch (IOException e) {

System.out.println();
printUsage(arguments);
System.out.println();
System.out.println(e.getMessage());
e.printStackTrace();
System.exit(1);

} catch (ImportException e) {

System.out.println();
printUsage(arguments);
System.out.println();
System.out.println(e.getMessage());
e.printStackTrace();
System.exit(1);

}// END: try-catch block

}// END: simulate

Expand Down

0 comments on commit d7c3794

Please sign in to comment.