X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Fapplication%2Fsimple_node_processor.java;h=7420bc274ec721ed82ad3875758023cb709bc0f7;hb=e0d3ddb03137a2f01528e995186c657d5067e673;hp=ac60660b027ec9e54550a024bf5d9ee840863f7b;hpb=c6b74aa20ac0c91099597b9474e7da6c0ffdb9a6;p=jalview.git diff --git a/forester/java/src/org/forester/application/simple_node_processor.java b/forester/java/src/org/forester/application/simple_node_processor.java index ac60660..7420bc2 100644 --- a/forester/java/src/org/forester/application/simple_node_processor.java +++ b/forester/java/src/org/forester/application/simple_node_processor.java @@ -1,27 +1,3 @@ -// $Id: -// FORESTER -- software libraries and applications -// for evolutionary biology research and applications. -// -// Copyright (C) 2008-2009 Christian M. Zmasek -// Copyright (C) 2008-2009 Burnham Institute for Medical Research -// All rights reserved -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -// -// Contact: phylosoft @ gmail . com -// WWW: www.phylosoft.org package org.forester.application; @@ -30,6 +6,7 @@ import java.io.File; import org.forester.io.parsers.phyloxml.PhyloXmlParser; import org.forester.phylogeny.Phylogeny; import org.forester.phylogeny.PhylogenyNode; +import org.forester.phylogeny.data.Taxonomy; import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory; import org.forester.phylogeny.factories.PhylogenyFactory; import org.forester.phylogeny.iterators.PhylogenyNodeIterator; @@ -40,14 +17,13 @@ public class simple_node_processor { private final static String BASE = "b_"; public static void main( final String args[] ) { - if ( ( args.length != 2 ) ) { - System.exit( -1 ); - } + File in = null; + File out = null; try { CommandLineArguments cla = null; cla = new CommandLineArguments( args ); - final File in = cla.getFile( 0 ); - final File out = cla.getFile( 1 ); + in = cla.getFile( 0 ); + out = cla.getFile( 1 ); if ( out.exists() ) { System.out.println( out + " already exists" ); System.exit( -1 ); @@ -56,15 +32,16 @@ public class simple_node_processor { final PhyloXmlParser xml_parser = new PhyloXmlParser(); final Phylogeny[] phylogenies_0 = factory.create( in, xml_parser ); final Phylogeny phylogeny_0 = phylogenies_0[ 0 ]; - final PhylogenyNodeIterator it = phylogeny_0.iteratorPostorder(); + // final PhylogenyNodeIterator it = phylogeny_0.iteratorPostorder(); + final PhylogenyNodeIterator it = phylogeny_0.iteratorExternalForward(); int i = 0; while ( it.hasNext() ) { final PhylogenyNode node = it.next(); - processNode( node, i ); + processNode( node, i, out.toString() ); i++; } - // final PhylogenyWriter writer = new PhylogenyWriter(); - // writer.toPhyloXML( out, phylogeny_0, 0 ); + // final PhylogenyWriter writer = new PhylogenyWriter(); + // writer.toPhyloXML( out, phylogeny_0, 0 ); } catch ( final Exception e ) { System.out.println( e.getLocalizedMessage() ); @@ -81,11 +58,42 @@ public class simple_node_processor { // } // } // } - private static void processNode( final PhylogenyNode node, final int i ) { + private static void processNode( final PhylogenyNode node, final int i, final String label ) { + //if ( node.isExternal() ) { + // final String c = "" + node.getNodeData().getBinaryCharacters().getPresentCount(); + // final String s = node.getNodeData().getTaxonomy().getScientificName(); + // System.out.println( s + "\t" + c ); + //} + // if ( !node.isExternal() ) { + // if ( !node.getNodeData().isHasTaxonomy() ) { + // if ( !ForesterUtil.isEmpty( node.getName() ) ) { + // if ( ( node.getName().indexOf( "_" ) < 0 ) && ( node.getName().indexOf( "&" ) < 0 ) + // && ( node.getName().indexOf( " " ) < 0 ) ) { + // Taxonomy t = new Taxonomy(); + // t.setScientificName( node.getName() ); + // node.getNodeData().addTaxonomy( t ); + // node.setName( "" ); + // } + // } + // } + // } if ( node.isExternal() ) { - String c = "" + node.getNodeData().getBinaryCharacters().getPresentCount(); - String s = node.getNodeData().getTaxonomy().getScientificName(); - System.out.println( s + "\t" + c ); + if ( node.getNodeData().isHasTaxonomy() ) { + // final Taxonomy t = node.getNodeData().getTaxonomy(); + // t.setIdentifier( null ); + //if ( !ForesterUtil.isEmpty( t.getTaxonomyCode() ) && t.getTaxonomyCode().length() == 5 ) { + // if ( node.getName().equalsIgnoreCase( t.getTaxonomyCode() ) ) { + // node.setName( "" ); + // } + //} + // node.setName( "" ); + final Taxonomy t = node.getNodeData().getTaxonomy(); + System.out.println( t.getTaxonomyCode() + "\t" + t.getScientificName() + "\t" + t.getCommonName() + + "\t" + label ); + } + else { + //System.out.println( "node " + node + " has not tax" ); + } } } -} +} \ No newline at end of file