From 9dea135f3eb004158bb67693021f7eb055d0b287 Mon Sep 17 00:00:00 2001 From: Walter Date: Mon, 23 Nov 2020 11:28:00 +1300 Subject: [PATCH] use D.taxa() and deprecate taxa(D) #110 --- examples/dataModelBlocks.lphy | 2 +- examples/fullDataExample.lphy | 2 +- examples/h3n2.lphy | 2 +- src/lphy/core/functions/TaxaFunction.java | 2 ++ .../alignment/AbstractAlignment.java | 20 ++++++++++++------- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/examples/dataModelBlocks.lphy b/examples/dataModelBlocks.lphy index 63dd2ef09..17b4c1376 100644 --- a/examples/dataModelBlocks.lphy +++ b/examples/dataModelBlocks.lphy @@ -1,7 +1,7 @@ data { D = readNexus(file="examples/primate.nex"); L = nchar(D); - taxa = D.getTaxa(); + taxa = D.taxa(); } model { theta ~ LogNormal(meanlog=3, sdlog=1); diff --git a/examples/fullDataExample.lphy b/examples/fullDataExample.lphy index a8573dd65..03809b409 100644 --- a/examples/fullDataExample.lphy +++ b/examples/fullDataExample.lphy @@ -1,7 +1,7 @@ data { D = readNexus(file="examples/primate.nex"); L = nchar(D); - taxa = D.getTaxa(); + taxa = D.taxa(); } model { theta ~ LogNormal(meanlog=3, sdlog=1); diff --git a/examples/h3n2.lphy b/examples/h3n2.lphy index f7a156c6b..d832dc9b9 100644 --- a/examples/h3n2.lphy +++ b/examples/h3n2.lphy @@ -1,7 +1,7 @@ data { options = {ageDirection="forward", ageRegex="_(\d*\.\d+|\d+\.\d*)$"}; D = readFasta(file="examples/h3n2_2deme.fna", options=options); - taxa = D.getTaxa(); + taxa = D.taxa(); L = nchar(D); demes = split(str=D.getTaxaNames(), regex="_", i=1); } diff --git a/src/lphy/core/functions/TaxaFunction.java b/src/lphy/core/functions/TaxaFunction.java index cbe61d32d..b482bc0bb 100644 --- a/src/lphy/core/functions/TaxaFunction.java +++ b/src/lphy/core/functions/TaxaFunction.java @@ -9,6 +9,7 @@ import java.util.Arrays; +@Deprecated public class TaxaFunction extends DeterministicFunction { final String paramName; @@ -18,6 +19,7 @@ public TaxaFunction(@ParameterInfo(name = "taxa", description = "the taxa value setParam(paramName, x); } + @Deprecated @GeneratorInfo(name="taxa",description = "The taxa of the given taxa-dimensioned object (e.g. alignment, tree et cetera).") public Value apply() { Value v = getParams().get(paramName); diff --git a/src/lphy/evolution/alignment/AbstractAlignment.java b/src/lphy/evolution/alignment/AbstractAlignment.java index 8d89eee5a..3e009cd16 100644 --- a/src/lphy/evolution/alignment/AbstractAlignment.java +++ b/src/lphy/evolution/alignment/AbstractAlignment.java @@ -82,12 +82,24 @@ public AbstractAlignment(final AbstractAlignment source) { public abstract boolean hasParts(); - //****** Sites ****** + //****** MethodInfo ****** + @MethodInfo(description="The number of characters/sites in this alignment.") public Integer nchar() { return nchar; } + @Override + @MethodInfo(description="The names of the taxa.") + public String[] getTaxaNames() { + return taxa.getTaxaNames(); + } + + @MethodInfo(description = "the taxa of the alignment.") + public Taxa taxa() { + return getTaxa(); + } + //****** Taxa ****** @Override @@ -109,18 +121,12 @@ public String getTaxonName(int taxonIndex) { return getTaxon(taxonIndex).getName(); } - @Override - @MethodInfo(description="The names of the taxa.") - public String[] getTaxaNames() { - return taxa.getTaxaNames(); - } @Override public Taxon[] getTaxonArray() { return taxa.getTaxonArray(); } - @MethodInfo(description = "the taxa of the alignment.") public Taxa getTaxa() { return taxa; }