|
From: <rv...@us...> - 2011-06-06 14:18:26
|
Revision: 900
http://treebase.svn.sourceforge.net/treebase/?rev=900&view=rev
Author: rvos
Date: 2011-06-06 14:18:19 +0000 (Mon, 06 Jun 2011)
Log Message:
-----------
This is pretty much how to convert treebase matrices to nexml ones.
Modified Paths:
--------------
trunk/treebase-core/src/test/java/org/cipres/treebase/domain/nexus/NexmlMatrixConverterTest.java
Modified: trunk/treebase-core/src/test/java/org/cipres/treebase/domain/nexus/NexmlMatrixConverterTest.java
===================================================================
--- trunk/treebase-core/src/test/java/org/cipres/treebase/domain/nexus/NexmlMatrixConverterTest.java 2011-06-04 03:36:27 UTC (rev 899)
+++ trunk/treebase-core/src/test/java/org/cipres/treebase/domain/nexus/NexmlMatrixConverterTest.java 2011-06-06 14:18:19 UTC (rev 900)
@@ -1,18 +1,20 @@
package org.cipres.treebase.domain.nexus;
+import java.util.List;
+
import junit.framework.Assert;
import org.cipres.treebase.dao.AbstractDAOTest;
import org.cipres.treebase.domain.matrix.CharacterMatrix;
-import org.cipres.treebase.domain.matrix.Matrix;
-import org.cipres.treebase.domain.matrix.StandardMatrix;
-import org.cipres.treebase.domain.nexus.nexml.NexmlMatrixConverter;
import org.cipres.treebase.domain.nexus.nexml.NexmlDocumentConverter;
-import org.cipres.treebase.domain.nexus.NexusDataSet;
import org.cipres.treebase.domain.study.Study;
import org.cipres.treebase.domain.taxon.TaxonLabelHome;
+import org.nexml.model.CategoricalMatrix;
+import org.nexml.model.ContinuousMatrix;
import org.nexml.model.DocumentFactory;
import org.nexml.model.Document;
+import org.nexml.model.Matrix;
+import org.nexml.model.MolecularMatrix;
public class NexmlMatrixConverterTest extends AbstractDAOTest {
private TaxonLabelHome mTaxonLabelHome;
@@ -29,30 +31,26 @@
long studyId = 1787;
Study study = (Study)loadObject(Study.class, studyId);
- NexusDataSet nexusDataSet = new NexusDataSet();
Document doc = DocumentFactory.safeCreateDocument();
NexmlDocumentConverter ndc = new NexmlDocumentConverter(study,getTaxonLabelHome(),doc);
- NexmlMatrixConverter nmc = new NexmlMatrixConverter (study,getTaxonLabelHome(),ndc.fromTreeBaseToXml(study));
- nexusDataSet = ndc.fromXmlToTreeBase(doc);
- nexusDataSet.setNexmlProject(doc);
-
- for (org.cipres.treebase.domain.matrix.Matrix matrix : nexusDataSet.getMatrices() ) {
- if ( matrix instanceof CharacterMatrix ) {
- //fromTreeBaseToXml(CharacterMatrix) is main method being tested here--it uses populateXmlMatrix() function
- String xml = ((Document) nmc.fromTreeBaseToXml((CharacterMatrix)matrix)).getXmlString();
- System.out.println(xml);
- Assert.assertNotNull(xml);
+ Document document = ndc.fromTreeBaseToXml(study);
+ List<Matrix<?>> matrices = document.getMatrices();
+ Assert.assertTrue(matrices.size() != 0 );
+ for ( Matrix<?> matrix : matrices ) {
+ if ( matrix instanceof MolecularMatrix ) {
+ System.out.println(matrix.getId() + " is a molecular character state matrix");
}
+ else if ( matrix instanceof ContinuousMatrix ) {
+ System.out.println(matrix.getId() + " is a continuous-valued character matrix");
+ }
+ else if ( matrix instanceof CategoricalMatrix ) {
+ System.out.println(matrix.getId() + " is a categorical character state matrix");
+ }
else {
- System.out.println("im not working");
+ System.out.println("This should not ever happen.");
}
}
-
- //signal that test is over
- if (logger.isInfoEnabled()) {
- logger.info(testName + " - end ");
- }
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|