Skip to content

Commit

Permalink
try to fix tests #8
Browse files Browse the repository at this point in the history
  • Loading branch information
walterxie committed Nov 16, 2022
1 parent f46ff65 commit 52645e2
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 19 deletions.
14 changes: 9 additions & 5 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,10 @@

<mkdir dir="${pack}"/>
<mkdir dir="${pack}/examples"/>
<mkdir dir="${pack}/examples/data"/>
<mkdir dir="${pack}/fxtemplates"/>
<!--mkdir dir="${pack}/lib"/-->
<mkdir dir="${pack}/doc"/>
<!-- <mkdir dir="${pack}/doc"/>-->

<jar jarfile="${pack}/${fullName}.src.jar" basedir="${src}" />

Expand All @@ -234,16 +235,19 @@

<copy todir="${pack}/examples">
<fileset dir="${examples}" includes="**/*.xml" />
<fileset dir="${examples}" includes="**/*.nex" />
</copy>
<copy todir="${pack}/examples/data">
<fileset dir="${examples}/data" includes="benchmarkData1024T1K.xml" />
<fileset dir="${examples}/data" includes="**/*.nex" />
</copy>

<copy todir="${pack}/fxtemplates">
<fileset dir="${fxtemplates}" includes="*.xml" />
</copy>

<copy todir="${pack}/doc">
<fileset dir="${doc}" includes="*.tex,*.doc,*.lyx,*.txt"/>
</copy>
<!-- <copy todir="${pack}/doc">-->
<!-- <fileset dir="${doc}" includes="*.tex,*.doc,*.lyx,*.txt"/>-->
<!-- </copy>-->

<copy file="version.xml" todir="${pack}" />

Expand Down
5 changes: 3 additions & 2 deletions fxtemplates/CMSubstModels.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<beast version='2.7'
namespace='beast.base.core:beast.base.inference:beast.base.inference.util:
beast.evolution.nuc:beast.base.evolution.alignment:beast.base.evolution.datatype:
beast.base.evolution.branchratemodel:beast.base.evolution.speciation:beast.base.evolution.tree.coalescent:
beast.base.evolution.operator:beast.base.inference.operator:beast.evolution:beast.base.math.distributions:
beast.base.evolution.branchratemodel:beast.base.evolution.speciation:
beast.base.evolution.tree.coalescent:beast.base.math.distributions:
beast.base.evolution.operator:beast.base.inference.operator:beast.evolution:
beast.base.evolution.sitemodel:beast.base.evolution.substitutionmodel:beast.base.evolution.likelihood:
codonmodels:codonmodels.evolution:codonmodels.evolution.alignment:codonmodels.evolution.datatype:
codonmodels.evolution.likelihood:codonmodels.evolution.operators:codonmodels.evolution.tree'
Expand Down
5 changes: 3 additions & 2 deletions fxtemplates/CodonSubstModels.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<beast version='2.7'
namespace='beast.base.core:beast.base.inference:beast.base.inference.util:
beast.evolution.nuc:beast.base.evolution.alignment:beast.base.evolution.datatype:
beast.base.evolution.branchratemodel:beast.base.evolution.speciation:beast.base.evolution.tree.coalescent:
beast.base.evolution.operator:beast.base.inference.operator:beast.evolution:beast.base.math.distributions:
beast.base.evolution.branchratemodel:beast.base.evolution.speciation:
beast.base.evolution.tree.coalescent:beast.base.math.distributions:
beast.base.evolution.operator:beast.base.inference.operator:beast.evolution:
beast.base.evolution.sitemodel:beast.base.evolution.substitutionmodel:beast.base.evolution.likelihood:
codonmodels:codonmodels.evolution:codonmodels.evolution.alignment:codonmodels.evolution.datatype:
codonmodels.evolution.likelihood:codonmodels.evolution.operators:codonmodels.evolution.tree'
Expand Down
13 changes: 13 additions & 0 deletions test/codonmodels/evolution/CodonData.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,30 @@
import beast.base.evolution.tree.Tree;
import beast.base.evolution.tree.TreeParser;
import beast.base.inference.parameter.RealParameter;
import beast.pkgmgmt.BEASTClassLoader;
import codonmodels.CodonFrequencies;
import codonmodels.M0Model;
import codonmodels.evolution.datatype.Codon;

import java.io.File;

/**
* @author Walter Xie
*/
public class CodonData {

public static final Codon codonUNIVERSAL = new Codon();

public static void initDataTypes() {
String PROJECT_DIR = System.getProperty("user.dir");
System.out.println("user.dir = " + PROJECT_DIR);
File versionXML = new File(PROJECT_DIR + File.separator + "version.xml");
if (!versionXML.exists())
throw new IllegalArgumentException("Cannot locate codonsubstmodels/version.xml !");
BEASTClassLoader.initServices();
BEASTClassLoader.addServices(versionXML.getAbsolutePath());
}


// create a Sequence obj using Codon.codeMap
public static Sequence getSeqCodeMap() {
Expand Down
15 changes: 6 additions & 9 deletions test/codonmodels/evolution/alignment/CodonAlignmentTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
import beast.base.evolution.alignment.Sequence;
import beast.base.evolution.datatype.DataType;
import beast.pkgmgmt.BEASTClassLoader;
import beast.pkgmgmt.PackageManager;
import codonmodels.evolution.CodonData;
import codonmodels.evolution.datatype.Codon;
import org.junit.Before;
import org.junit.Test;

import java.io.File;
import java.util.List;
import java.util.Set;

Expand All @@ -22,6 +21,11 @@
*/
public class CodonAlignmentTest {

@Before
public void setUp() throws Exception {
CodonData.initDataTypes();
}

@Test
public void testGetSequence() {
Sequence seq1 = CodonData.getSeqCodeMap();
Expand All @@ -39,13 +43,6 @@ public void testGetSequence() {

@Test
public void testGettingDataType() {
String PROJECT_DIR = System.getProperty("user.dir");
System.out.println("user.dir = " + PROJECT_DIR);
File versionXML = new File(PROJECT_DIR + File.separator + "version.xml");
if (!versionXML.exists())
throw new IllegalArgumentException("Cannot locate codonsubstmodels/version.xml !");
BEASTClassLoader.initServices();
BEASTClassLoader.addServices(versionXML.getAbsolutePath());
Set<String> dataTypes = BEASTClassLoader.loadService(DataType.class);
System.out.println(dataTypes);
assertTrue("Cannot load Codon data type !", dataTypes.contains(Codon.class.getName()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public class DALikelihoodMultithreadingTest {

@Before
public void setUp() {
CodonData.initDataTypes();

Alignment data = CodonData.getAlig6T333();
// create Codon Alignment
CodonAlignment codonAlignment = new CodonAlignment();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class DALikelihoodTest {

@Before
public void setUp() {
CodonData.initDataTypes();
// String newickTree = "(t1:0.5, t2:0.0):0.0;"; // TODO bug for 0 branch length ?
String newickTree = "(t1:0.5, t2:0.1):0.0;";
// boolean adjustTipHeights = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package codonmodels.evolution.likelihood;


import codonmodels.evolution.CodonData;
import org.junit.Before;
import org.junit.Test;

Expand All @@ -27,6 +28,8 @@ public class DAStatesLikelihoodCoreIndexTest {

@Before
public void setUp() throws Exception {
CodonData.initDataTypes();

final int nrOfState = 61;

// ======= transition probability matrix =======
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class M0TreeLikelihoodTest {

@Before
public void setUp() {
CodonData.initDataTypes();

Alignment data = CodonData.getAlig6T333();
// create Codon Alignment
codonAlignment = new CodonAlignment();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class CodonFrequenciesTest {

@Before
public void setUp() {
CodonData.initDataTypes();

Alignment data = CodonData.getAlig6T333();
// create Codon Alignment
codonAlignment = new CodonAlignment();
Expand Down
1 change: 1 addition & 0 deletions test/codonmodels/evolution/substmodel/M0ModelTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class M0ModelTest {

@Before
public void setUp() {
CodonData.initDataTypes();

Alignment data = CodonData.getAlig6T333();
// create Codon Alignment
Expand Down
3 changes: 2 additions & 1 deletion version.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
<provider classname="codonmodels.CodonSubstitutionModel"/>
<provider classname="codonmodels.evolution.alignment.CodonAlignment"/>
<provider classname="codonmodels.evolution.datatype.Codon"/>
<!-- <provider classname="codonmodels.evolution.datatype.GeneticCode"/>-->
<provider classname="codonmodels.evolution.datatype.GeneticCode"/>
<provider classname="codonmodels.evolution.likelihood.DataAugTreeLikelihood"/>
<provider classname="codonmodels.evolution.likelihood.GenericDATreeLikelihood"/>
<provider classname="codonmodels.evolution.operators.GibbsSamplingOperator"/>
<provider classname="codonmodels.evolution.operators.ScaleOperatorGibbs"/>
<provider classname="codonmodels.evolution.operators.UniformGibbs"/>
<provider classname="codonmodels.evolution.tree.NodeStates"/>
<provider classname="codonmodels.evolution.tree.NodeStatesArray"/>
<provider classname="codonmodels.evolution.tree.NodeStatesLogger"/>
<provider classname="codonmodels.util.Report"/>
Expand Down

0 comments on commit 52645e2

Please sign in to comment.