Skip to content

Commit

Permalink
make input constraints optional in ConstrainedClusterTree
Browse files Browse the repository at this point in the history
  • Loading branch information
rbouckaert committed May 1, 2019
1 parent 528d656 commit 65aeced
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions src/beast/evolution/tree/ConstrainedClusterTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public class ConstrainedClusterTree extends Tree implements StateNodeInitialiser
// The tree in the XML should have a taxon set, since it is not fully initialised at this stage
public Input<List<MRCAPrior>> calibrationsInput = new Input<List<MRCAPrior>>("constraint", "specifies (monophyletic or height distribution) constraints on internal nodes", new ArrayList<MRCAPrior>());
public final Input<MultiMonophyleticConstraint> allConstraints = new Input<>("constraints",
"all constraints as encoded by one unresolved tree.", Input.Validate.REQUIRED);
"all constraints as encoded by one unresolved tree.");
public final Input<Double> epsilonInput = new Input<Double>("minBranchLength", "lower bound on lengths used for creating branches", 1e-10);

enum Type {single, average, complete, upgma, mean, centroid, ward, adjcomplete, neighborjoining, neighborjoining2}
Expand Down Expand Up @@ -280,21 +280,22 @@ public static List<MRCAPrior> collectCalibrations(List<String> taxaNames, Tree t
}

final MultiMonophyleticConstraint mul = multiMonophyleticConstraint;
List<List<String>> allc = mul.getConstraints();

for( List<String> c : allc ) {
final boolean [] bTaxa = new boolean[nrOfTaxa];
for( String sTaxonID : c ) {
final int iID = taxaNames.indexOf(sTaxonID);
if (iID < 0) {
throw new IllegalArgumentException("Taxon <" + sTaxonID + "> could not be found in list of taxa. Choose one of " + taxaNames.toArray(new String[0]));
}
bTaxa[iID] = true;
if (mul != null) {
List<List<String>> allc = mul.getConstraints();

for( List<String> c : allc ) {
final boolean [] bTaxa = new boolean[nrOfTaxa];
for( String sTaxonID : c ) {
final int iID = taxaNames.indexOf(sTaxonID);
if (iID < 0) {
throw new IllegalArgumentException("Taxon <" + sTaxonID + "> could not be found in list of taxa. Choose one of " + taxaNames.toArray(new String[0]));
}
bTaxa[iID] = true;
}
constraints.add(bTaxa);
constraintsize.add(c.size());
}
constraints.add(bTaxa);
constraintsize.add(c.size());
}

return calibrations;
}

Expand Down

0 comments on commit 65aeced

Please sign in to comment.