BEAST2-Dev / BEASTLabs

A package for BEAST 2 implementing generally useful stuff
6 stars 4 forks source link

`PrunedAlignment` checks whether `taxonSet` is `null`, but it never is. #3

Open Anaphory opened 8 years ago

Anaphory commented 8 years ago

PrunedAlignment uses a given TaxonSet based on whether taxonSet is null or not. However, the corresponding input is optional with a default value of TaxonSet(). This means that PA's initAndValidate should instead check whether taxonSet is empty.

Anaphory commented 8 years ago

example diff:

diff --git a/src/beast/evolution/alignment/PrunedAlignment.java b/src/beast/evolution/alignment/PrunedAlignment.java
index 7be8dfc..645ce8c 100644
--- a/src/beast/evolution/alignment/PrunedAlignment.java
+++ b/src/beast/evolution/alignment/PrunedAlignment.java
@@ -46,7 +46,7 @@ public class PrunedAlignment extends Alignment {

           final List<String> srcTaxa = source.taxaNames;
           final List<List<Integer>> srcCounts = source.counts;
-          if( taxonSet != null ) {
+          if( taxonSet.getTaxonCount() > 0 ) {
              for(int i = 0; i < source.taxaNames.size(); ++i) {

                  if( taxonSet.getTaxonIndex(srcTaxa.get(i)) < 0  ) {