in progress
[jalview.git] / forester / java / src / org / forester / application / get_subtree_specific_chars.java
index 830b043..3b6de88 100644 (file)
@@ -39,6 +39,8 @@ import org.forester.util.ForesterUtil;
 
 public class get_subtree_specific_chars {
 
+    final static boolean SIMPLE = true;
+
     public static void main( final String args[] ) {
         if ( args.length != 1 ) {
             System.err.println();
@@ -63,6 +65,9 @@ public class get_subtree_specific_chars {
         System.out.println();
         for( final PhylogenyNodeIterator iter = phy.iteratorPostorder(); iter.hasNext(); ) {
             final PhylogenyNode node = iter.next();
+            if ( !SIMPLE && node.isExternal() ) {
+                continue;
+            }
             if ( !node.isRoot() ) {
                 System.out.println();
                 if ( node.getNodeData().isHasTaxonomy()
@@ -84,7 +89,24 @@ public class get_subtree_specific_chars {
                 final SortedSet<String> unique_chars = new TreeSet<String>();
                 for( final String node_char : node_chars ) {
                     if ( !not_node_chars.contains( node_char ) ) {
-                        unique_chars.add( node_char );
+                        if ( SIMPLE ) {
+                            unique_chars.add( node_char );
+                        }
+                        else {
+                            boolean found = true;
+                            for( final int external_id : external_ids ) {
+                                if ( !phy.getNode( external_id ).getNodeData().getBinaryCharacters()
+                                        .getGainedCharacters().contains( node_char )
+                                        && !phy.getNode( external_id ).getNodeData().getBinaryCharacters()
+                                                .getPresentCharacters().contains( node_char ) ) {
+                                    found = false;
+                                    break;
+                                }
+                            }
+                            if ( found ) {
+                                unique_chars.add( node_char );
+                            }
+                        }
                     }
                 }
                 System.out.println( "\tSUM:\t" + unique_chars.size() );