+ if ( !t3.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
+ return false;
+ }
+ if ( !t3.getNode( "root node" ).getNodeData().getSequence().getName()
+ .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
+ return false;
+ }
+ if ( !t3.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
+ return false;
+ }
+ if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
+ return false;
+ }
+ if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource().equals( "UniProtKB" ) ) {
+ return false;
+ }
+ if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
+ .equals( "apoptosis" ) ) {
+ return false;
+ }
+ if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
+ .equals( "GO:0006915" ) ) {
+ return false;
+ }
+ if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
+ .equals( "UniProtKB" ) ) {
+ return false;
+ }
+ if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
+ .equals( "experimental" ) ) {
+ return false;
+ }
+ if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
+ .equals( "function" ) ) {
+ return false;
+ }
+ if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
+ .getValue() != 1 ) {
+ return false;
+ }
+ if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
+ .getType().equals( "ml" ) ) {
+ return false;
+ }
+ if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
+ .equals( "apoptosis" ) ) {
+ return false;
+ }
+ if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
+ .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
+ return false;
+ }
+ if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
+ .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
+ return false;
+ }
+ if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
+ .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
+ return false;
+ }
+ if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
+ .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
+ return false;
+ }
+ if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
+ .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
+ return false;
+ }
+ if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
+ .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
+ return false;
+ }
+ if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
+ .equals( "GO:0005829" ) ) {
+ return false;
+ }
+ if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
+ .equals( "intracellular organelle" ) ) {
+ return false;
+ }
+ if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
+ return false;
+ }
+ if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
+ .equals( "UniProt link" ) ) ) {
+ return false;
+ }
+ if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
+ return false;
+ }
+ final SortedSet<Accession> x = t3.getNode( "root node" ).getNodeData().getSequence().getCrossReferences();
+ if ( x.size() != 4 ) {
+ return false;
+ }
+ int c = 0;
+ for( final Accession acc : x ) {
+ if ( c == 0 ) {
+ if ( !acc.getSource().equals( "KEGG" ) ) {
+ return false;
+ }
+ if ( !acc.getValue().equals( "hsa:596" ) ) {
+ return false;
+ }
+ }
+ c++;
+ }
+ }
+ catch ( final Exception e ) {
+ e.printStackTrace( System.out );
+ return false;
+ }
+ return true;
+ }
+
+ private static boolean testBasicPhyloXMLparsingRoundtrip() {
+ try {
+ final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
+ final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
+ if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
+ xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
+ }
+ else {
+ xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
+ }
+ final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml" ),
+ xml_parser );
+ if ( xml_parser.getErrorCount() > 0 ) {
+ System.out.println( xml_parser.getErrorMessages().toString() );
+ return false;
+ }
+ if ( phylogenies_0.length != 4 ) {
+ return false;
+ }
+ final StringBuffer t1_sb = new StringBuffer( phylogenies_0[ 0 ].toPhyloXML( 0 ) );
+ final Phylogeny[] phylogenies_t1 = factory.create( t1_sb, xml_parser );
+ if ( phylogenies_t1.length != 1 ) {
+ return false;
+ }
+ final Phylogeny t1_rt = phylogenies_t1[ 0 ];
+ if ( !t1_rt.getDistanceUnit().equals( "cc" ) ) {
+ return false;
+ }
+ if ( !t1_rt.isRooted() ) {
+ return false;
+ }
+ if ( t1_rt.isRerootable() ) {
+ return false;
+ }
+ if ( !t1_rt.getType().equals( "gene_tree" ) ) {
+ return false;
+ }
+ final StringBuffer t2_sb = new StringBuffer( phylogenies_0[ 1 ].toPhyloXML( 0 ) );
+ final Phylogeny[] phylogenies_t2 = factory.create( t2_sb, xml_parser );
+ final Phylogeny t2_rt = phylogenies_t2[ 0 ];
+ if ( t2_rt.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
+ return false;
+ }
+ if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
+ return false;
+ }
+ if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
+ return false;
+ }
+ if ( t2_rt.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
+ return false;
+ }
+ if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
+ .startsWith( "actgtgggggt" ) ) {
+ return false;
+ }
+ if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
+ .startsWith( "ctgtgatgcat" ) ) {
+ return false;
+ }
+ final StringBuffer t3_sb_0 = new StringBuffer( phylogenies_0[ 2 ].toPhyloXML( 0 ) );
+ final Phylogeny[] phylogenies_1_0 = factory.create( t3_sb_0, xml_parser );
+ final StringBuffer t3_sb = new StringBuffer( phylogenies_1_0[ 0 ].toPhyloXML( 0 ) );
+ final Phylogeny[] phylogenies_1 = factory.create( t3_sb, xml_parser );
+ if ( phylogenies_1.length != 1 ) {
+ return false;
+ }
+ final Phylogeny t3_rt = phylogenies_1[ 0 ];
+ if ( !t3_rt.getName().equals( "t3" ) ) {
+ return false;
+ }
+ if ( t3_rt.getNumberOfExternalNodes() != 4 ) {
+ return false;
+ }
+ if ( !t3_rt.getIdentifier().getValue().equals( "1-1" ) ) {
+ return false;
+ }
+ if ( !t3_rt.getIdentifier().getProvider().equals( "treebank" ) ) {
+ return false;
+ }
+ if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
+ return false;
+ }
+ if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getName()
+ .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
+ return false;
+ }
+ if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
+ return false;
+ }
+ if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
+ return false;
+ }
+ if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource()
+ .equals( "UniProtKB" ) ) {
+ return false;
+ }
+ if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
+ .equals( "apoptosis" ) ) {
+ return false;
+ }
+ if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
+ .equals( "GO:0006915" ) ) {
+ return false;
+ }
+ if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
+ .equals( "UniProtKB" ) ) {
+ return false;
+ }
+ if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
+ .equals( "experimental" ) ) {
+ return false;
+ }
+ if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
+ .equals( "function" ) ) {
+ return false;
+ }
+ if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
+ .getValue() != 1 ) {
+ return false;
+ }
+ if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
+ .getType().equals( "ml" ) ) {
+ return false;
+ }
+ if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
+ .equals( "apoptosis" ) ) {
+ return false;
+ }
+ if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
+ .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
+ return false;
+ }
+ if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
+ .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
+ return false;
+ }
+ if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
+ .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
+ return false;
+ }
+ if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
+ .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
+ return false;
+ }
+ if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
+ .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
+ return false;
+ }
+ if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
+ .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
+ return false;
+ }
+ if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
+ .equals( "GO:0005829" ) ) {
+ return false;
+ }
+ if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
+ .equals( "intracellular organelle" ) ) {
+ return false;
+ }
+ if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
+ return false;
+ }
+ if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
+ .equals( "UniProt link" ) ) ) {
+ return false;
+ }
+ if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
+ return false;
+ }
+ if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDoi().equals( "10.1038/387489a0" ) ) ) {
+ return false;
+ }
+ if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription()
+ .equals( "Aguinaldo, A. M. A.; J. M. Turbeville, L. S. Linford, M. C. Rivera, J. R. Garey, R. A. Raff, & J. A. Lake (1997). \"Evidence for a clade of nematodes, arthropods and other moulting animals\". Nature 387 (6632): 489–493." ) ) ) {
+ System.out.println( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription() );
+ return false;
+ }
+ if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getTaxonomyCode().equals( "ECDYS" ) ) {
+ return false;
+ }
+ if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getScientificName().equals( "ecdysozoa" ) ) {
+ return false;
+ }
+ if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getCommonName().equals( "molting animals" ) ) {
+ return false;
+ }
+ if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
+ return false;
+ }
+ if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getProvider()
+ .equals( "ncbi" ) ) {
+ return false;
+ }
+ if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getTotalLength() != 124 ) {
+ return false;
+ }
+ if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
+ .getName().equals( "B" ) ) {
+ return false;
+ }
+ if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
+ .getFrom() != 21 ) {
+ return false;
+ }
+ if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getTo() != 44 ) {
+ return false;
+ }
+ if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
+ .getLength() != 24 ) {
+ return false;
+ }
+ if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
+ .getConfidence() != 0 ) {
+ return false;
+ }
+ if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getId()
+ .equals( "pfam" ) ) {
+ return false;
+ }
+ if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 3 ) {
+ return false;
+ }
+ if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
+ return false;
+ }
+ if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 1 ) {
+ return false;
+ }
+ if ( !t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getType().equals( "domains" ) ) {
+ return false;
+ }
+ final Taxonomy taxbb = t3_rt.getNode( "node bb" ).getNodeData().getTaxonomy();
+ if ( !taxbb.getAuthority().equals( "Stephenson, 1935" ) ) {
+ return false;
+ }
+ if ( !taxbb.getCommonName().equals( "starlet sea anemone" ) ) {
+ return false;
+ }
+ if ( !taxbb.getIdentifier().getProvider().equals( "EOL" ) ) {
+ return false;
+ }
+ if ( !taxbb.getIdentifier().getValue().equals( "704294" ) ) {
+ return false;
+ }
+ if ( !taxbb.getTaxonomyCode().equals( "NEMVE" ) ) {
+ return false;
+ }
+ if ( !taxbb.getScientificName().equals( "Nematostella vectensis" ) ) {
+ return false;
+ }
+ if ( taxbb.getSynonyms().size() != 2 ) {
+ return false;
+ }
+ if ( !taxbb.getSynonyms().contains( "Nematostella vectensis Stephenson1935" ) ) {
+ return false;
+ }
+ if ( !taxbb.getSynonyms().contains( "See Anemone" ) ) {
+ return false;
+ }
+ if ( !taxbb.getUri( 0 ).getDescription().equals( "EOL" ) ) {
+ return false;
+ }
+ if ( !taxbb.getUri( 0 ).getType().equals( "linkout" ) ) {
+ return false;
+ }
+ if ( !taxbb.getUri( 0 ).getValue().toString().equals( "http://www.eol.org/pages/704294" ) ) {
+ return false;
+ }
+ if ( ( ( BinaryCharacters ) t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().copy() )
+ .getLostCount() != BinaryCharacters.COUNT_DEFAULT ) {
+ return false;
+ }
+ if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCount() != 1 ) {
+ return false;
+ }
+ if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 1 ) {
+ return false;
+ }
+ if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCount() != 3 ) {
+ return false;
+ }
+ if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 3 ) {
+ return false;
+ }
+ if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCount() != 2 ) {
+ return false;
+ }
+ if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
+ return false;
+ }
+ if ( !t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getType().equals( "characters" ) ) {
+ return false;
+ }
+ if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getDesc().equals( "Silurian" ) ) {
+ return false;
+ }
+ if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getValue().toPlainString()
+ .equalsIgnoreCase( "435" ) ) {
+ return false;
+ }
+ if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMin().toPlainString().equalsIgnoreCase( "416" ) ) {
+ return false;
+ }
+ if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMax().toPlainString()
+ .equalsIgnoreCase( "443.7" ) ) {
+ return false;
+ }
+ if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getUnit().equals( "mya" ) ) {
+ return false;
+ }
+ if ( !t3_rt.getNode( "node bb" ).getNodeData().getDate().getDesc().equals( "Triassic" ) ) {
+ return false;
+ }
+ if ( !t3_rt.getNode( "node bc" ).getNodeData().getDate().getValue().toPlainString()
+ .equalsIgnoreCase( "433" ) ) {
+ return false;
+ }
+ final SortedSet<Accession> x = t3_rt.getNode( "root node" ).getNodeData().getSequence()
+ .getCrossReferences();
+ if ( x.size() != 4 ) {
+ return false;
+ }
+ int c = 0;
+ for( final Accession acc : x ) {
+ if ( c == 0 ) {
+ if ( !acc.getSource().equals( "KEGG" ) ) {
+ return false;
+ }
+ if ( !acc.getValue().equals( "hsa:596" ) ) {
+ return false;
+ }
+ }
+ c++;
+ }
+ }
+ catch ( final Exception e ) {
+ e.printStackTrace( System.out );
+ return false;
+ }
+ return true;
+ }
+
+ private static boolean testBasicPhyloXMLparsingValidating() {
+ try {
+ final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
+ PhyloXmlParser xml_parser = null;
+ try {
+ xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
+ }
+ catch ( final Exception e ) {
+ // Do nothing -- means were not running from jar.
+ }
+ if ( xml_parser == null ) {
+ xml_parser = PhyloXmlParser.createPhyloXmlParser();
+ if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
+ xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
+ }
+ else {
+ xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
+ }
+ }
+ final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml" ),
+ xml_parser );
+ if ( xml_parser.getErrorCount() > 0 ) {
+ System.out.println( xml_parser.getErrorMessages().toString() );
+ return false;
+ }
+ if ( phylogenies_0.length != 4 ) {
+ return false;
+ }
+ final Phylogeny t1 = phylogenies_0[ 0 ];
+ final Phylogeny t2 = phylogenies_0[ 1 ];
+ final Phylogeny t3 = phylogenies_0[ 2 ];
+ final Phylogeny t4 = phylogenies_0[ 3 ];
+ if ( !t1.getName().equals( "t1" ) ) {
+ return false;
+ }
+ if ( !t2.getName().equals( "t2" ) ) {
+ return false;
+ }
+ if ( !t3.getName().equals( "t3" ) ) {
+ return false;
+ }
+ if ( !t4.getName().equals( "t4" ) ) {
+ return false;
+ }
+ if ( t1.getNumberOfExternalNodes() != 1 ) {
+ return false;
+ }
+ if ( t2.getNumberOfExternalNodes() != 2 ) {
+ return false;
+ }
+ if ( t3.getNumberOfExternalNodes() != 4 ) {
+ return false;
+ }
+ final String x2 = Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml";
+ final Phylogeny[] phylogenies_1 = factory.create( new File( x2 ), xml_parser );
+ if ( xml_parser.getErrorCount() > 0 ) {
+ System.out.println( "errors:" );
+ System.out.println( xml_parser.getErrorMessages().toString() );
+ return false;
+ }
+ if ( phylogenies_1.length != 4 ) {
+ return false;
+ }
+ final Phylogeny[] phylogenies_2 = factory.create( new File(Test.PATH_TO_TEST_DATA + "phyloxml_test_t3.xml" ),
+ xml_parser );
+ if ( xml_parser.getErrorCount() > 0 ) {
+ System.out.println( "errors:" );
+ System.out.println( xml_parser.getErrorMessages().toString() );
+ return false;
+ }
+ if ( phylogenies_2.length != 1 ) {
+ return false;
+ }
+ if ( phylogenies_2[ 0 ].getNumberOfExternalNodes() != 2 ) {
+ return false;
+ }
+ final Phylogeny[] phylogenies_3 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_t4.xml" ),
+ xml_parser );
+ if ( xml_parser.getErrorCount() > 0 ) {
+ System.out.println( xml_parser.getErrorMessages().toString() );
+ return false;
+ }
+ if ( phylogenies_3.length != 2 ) {
+ return false;
+ }
+ final Phylogeny a = phylogenies_3[ 0 ];
+ if ( !a.getName().equals( "tree 4" ) ) {
+ return false;
+ }
+ if ( a.getNumberOfExternalNodes() != 3 ) {
+ return false;
+ }
+ if ( !a.getNode( "node b1" ).getNodeData().getSequence().getName().equals( "b1 gene" ) ) {
+ return false;
+ }
+ if ( !a.getNode( "node b1" ).getNodeData().getTaxonomy().getCommonName().equals( "b1 species" ) ) {
+ return false;
+ }
+ final Phylogeny[] phylogenies_4 = factory.create( new File( Test.PATH_TO_TEST_DATA + "special_characters.xml") ,
+ xml_parser );
+ if ( xml_parser.getErrorCount() > 0 ) {
+ System.out.println( xml_parser.getErrorMessages().toString() );
+ return false;
+ }
+ if ( phylogenies_4.length != 1 ) {
+ return false;
+ }
+ final Phylogeny s = phylogenies_4[ 0 ];
+ if ( s.getNumberOfExternalNodes() != 6 ) {
+ return false;
+ }
+ s.getNode( "first" );
+ s.getNode( "<>" );
+ s.getNode( "\"<a'b&c'd\">\"" );
+ s.getNode( "'''\"" );
+ s.getNode( "\"\"\"" );
+ s.getNode( "dick & doof" );
+ }
+ catch ( final Exception e ) {
+ e.printStackTrace( System.out );
+ return false;
+ }
+ return true;
+ }
+
+ private static boolean testBasicProtein() {
+ try {
+ final BasicProtein p0 = new BasicProtein( "p0", "owl", 0 );
+ final Domain a = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
+ final Domain b = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
+ final Domain c = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
+ final Domain d = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
+ final Domain e = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
+ final Domain x = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
+ final Domain y = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
+ p0.addProteinDomain( y );
+ p0.addProteinDomain( e );
+ p0.addProteinDomain( b );
+ p0.addProteinDomain( c );
+ p0.addProteinDomain( d );
+ p0.addProteinDomain( a );
+ p0.addProteinDomain( x );
+ if ( !p0.toDomainArchitectureString( "~" ).equals( "a~b~c~d~e~x~y" ) ) {
+ return false;
+ }
+ if ( !p0.toDomainArchitectureString( "~", 3, "=" ).equals( "a~b~c~d~e~x~y" ) ) {
+ return false;
+ }
+ //
+ final BasicProtein aa0 = new BasicProtein( "aa", "owl", 0 );
+ final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
+ aa0.addProteinDomain( a1 );
+ if ( !aa0.toDomainArchitectureString( "~" ).equals( "a" ) ) {
+ return false;
+ }
+ if ( !aa0.toDomainArchitectureString( "~", 3, "" ).equals( "a" ) ) {
+ return false;
+ }
+ //
+ final BasicProtein aa1 = new BasicProtein( "aa", "owl", 0 );
+ final Domain a11 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
+ final Domain a12 = new BasicDomain( "a", 2, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
+ aa1.addProteinDomain( a11 );
+ aa1.addProteinDomain( a12 );
+ if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a" ) ) {
+ return false;
+ }
+ if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "a~a" ) ) {