searhc of domains only when domains are shown!
authorcmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Fri, 7 Sep 2012 23:47:46 +0000 (23:47 +0000)
committercmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Fri, 7 Sep 2012 23:47:46 +0000 (23:47 +0000)
forester/java/src/org/forester/application/decorator.java
forester/java/src/org/forester/archaeopteryx/Constants.java
forester/java/src/org/forester/archaeopteryx/ControlPanel.java
forester/java/src/org/forester/phylogeny/PhylogenyMethods.java
forester/java/src/org/forester/tools/PhylogenyDecorator.java

index 6f37ff3..d96d868 100644 (file)
@@ -55,6 +55,7 @@ public final class decorator {
     private static final String  NODE_NAME_FIELD                        = "n";
     final static private String  PICKY_OPTION                           = "p";
     final static private String  FIELD_OPTION                           = "f";
+    final static private String  TRIM_AFTER_TILDE_OPTION                = "t";
     final static private String  MOVE_DOMAIN_NUMBER_OPTION              = "mdn";       // Hidden expert option.
     final static private String  TREE_NAME_OPTION                       = "pn";
     final static private String  TREE_ID_OPTION                         = "pi";
@@ -112,6 +113,7 @@ public final class decorator {
         System.out.println( " -" + decorator.PROCESS_SIMILAR_TO_OPTION
                 + "    : process name \"intelligently\" and process information after \"similar to\" (only for -f=n)" );
         System.out.println( " -c     : cut name after first space (only for -f=n)" );
+        System.out.println( " -" + decorator.TRIM_AFTER_TILDE_OPTION + "    : trim after tilde" );
         System.out.println();
         System.exit( -1 );
     }
@@ -153,6 +155,7 @@ public final class decorator {
         allowed_options.add( decorator.TREE_ID_OPTION );
         allowed_options.add( decorator.TREE_DESC_OPTION );
         allowed_options.add( decorator.MOVE_DOMAIN_NUMBER_OPTION );
+        allowed_options.add( decorator.TRIM_AFTER_TILDE_OPTION );
         final String dissallowed_options = cla.validateAllowedOptionsAsString( allowed_options );
         if ( dissallowed_options.length() > 0 ) {
             ForesterUtil.fatalError( decorator.PRG_NAME, "unknown option(s): " + dissallowed_options );
@@ -184,6 +187,7 @@ public final class decorator {
         boolean process_similar_to = false;
         boolean extract_bracketed_scientific_name = false;
         boolean move_domain_numbers_at_end_to_middle = false;
+        boolean trim_after_tilde = false;
         String tree_name = "";
         String tree_id = "";
         String tree_desc = "";
@@ -233,6 +237,12 @@ public final class decorator {
                 }
                 process_similar_to = true;
             }
+            if ( cla.isOptionSet( decorator.TRIM_AFTER_TILDE_OPTION ) ) {
+                if ( advanced_table ) {
+                    argumentsError();
+                }
+                trim_after_tilde = true;
+            }
             if ( cla.isOptionSet( decorator.ALLOW_REMOVAL_OF_CHARS_OPTION ) ) {
                 numbers_of_chars_allowed_to_remove_if_not_found_in_map = cla
                         .getOptionValueAsInt( decorator.ALLOW_REMOVAL_OF_CHARS_OPTION );
@@ -362,7 +372,8 @@ public final class decorator {
                                              process_name_intelligently,
                                              process_similar_to,
                                              numbers_of_chars_allowed_to_remove_if_not_found_in_map,
-                                             move_domain_numbers_at_end_to_middle );
+                                             move_domain_numbers_at_end_to_middle,
+                                             trim_after_tilde );
             }
         }
         catch ( final NullPointerException e ) {
index d5ed89f..ed9dea5 100644 (file)
@@ -43,7 +43,7 @@ public final class Constants {
     public final static boolean ALLOW_DDBJ_BLAST                                              = false;
     public final static String  PRG_NAME                                                      = "Archaeopteryx";
     final static String         VERSION                                                       = "0.973";
-    final static String         PRG_DATE                                                      = "120904";
+    final static String         PRG_DATE                                                      = "120907";
     final static String         DEFAULT_CONFIGURATION_FILE_NAME                               = "_aptx_configuration_file";
     final static String[]       DEFAULT_FONT_CHOICES                                          = { "Verdana", "Tahoma",
             "Arial", "Helvetica", "Dialog", "Lucida Sans", "SansSerif", "Sans-serif", "Sans" };
index 5495b9e..0682605 100644 (file)
@@ -212,6 +212,10 @@ final class ControlPanel extends JPanel implements ActionListener {
                 }
                 displayedPhylogenyMightHaveChanged( false );
             }
+            else if ( e.getSource() == _show_domain_architectures ) {
+                search();
+                displayedPhylogenyMightHaveChanged( false );
+            }
             else if ( ( tp != null ) && ( tp.getPhylogeny() != null ) ) {
                 if ( e.getSource() == getDisplayAsPhylogramCb() ) {
                     setDrawPhylogram( getDisplayAsPhylogramCb().isSelected() );
@@ -950,14 +954,18 @@ final class ControlPanel extends JPanel implements ActionListener {
                 }
                 query = query.trim();
                 if ( query.indexOf( '+' ) >= 0 ) {
-                    nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ), tree, getOptions()
-                            .isSearchCaseSensitive(), !getOptions().isMatchWholeTermsOnly() ) );
+                    nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ),
+                                                                         tree,
+                                                                         getOptions().isSearchCaseSensitive(),
+                                                                         !getOptions().isMatchWholeTermsOnly(),
+                                                                         isShowDomainArchitectures() ) );
                 }
                 else {
                     nodes.addAll( PhylogenyMethods.searchData( query,
                                                                tree,
                                                                getOptions().isSearchCaseSensitive(),
-                                                               !getOptions().isMatchWholeTermsOnly() ) );
+                                                               !getOptions().isMatchWholeTermsOnly(),
+                                                               isShowDomainArchitectures() ) );
                 }
             }
             if ( getOptions().isInverseSearchResult() ) {
index 4c86166..6678e70 100644 (file)
@@ -1331,7 +1331,8 @@ public class PhylogenyMethods {
     public static List<PhylogenyNode> searchData( final String query,
                                                   final Phylogeny phy,
                                                   final boolean case_sensitive,
-                                                  final boolean partial ) {
+                                                  final boolean partial,
+                                                  final boolean search_domains ) {
         final List<PhylogenyNode> nodes = new ArrayList<PhylogenyNode>();
         if ( phy.isEmpty() || ( query == null ) ) {
             return nodes;
@@ -1391,7 +1392,7 @@ public class PhylogenyMethods {
                               partial ) ) {
                 match = true;
             }
-            if ( !match && node.getNodeData().isHasSequence()
+            if ( search_domains && !match && node.getNodeData().isHasSequence()
                     && ( node.getNodeData().getSequence().getDomainArchitecture() != null ) ) {
                 final DomainArchitecture da = node.getNodeData().getSequence().getDomainArchitecture();
                 I: for( int i = 0; i < da.getNumberOfDomains(); ++i ) {
@@ -1427,7 +1428,8 @@ public class PhylogenyMethods {
     public static List<PhylogenyNode> searchDataLogicalAnd( final String[] queries,
                                                             final Phylogeny phy,
                                                             final boolean case_sensitive,
-                                                            final boolean partial ) {
+                                                            final boolean partial,
+                                                            final boolean search_domains ) {
         final List<PhylogenyNode> nodes = new ArrayList<PhylogenyNode>();
         if ( phy.isEmpty() || ( queries == null ) || ( queries.length < 1 ) ) {
             return nodes;
@@ -1490,7 +1492,7 @@ public class PhylogenyMethods {
                                   partial ) ) {
                     match = true;
                 }
-                if ( !match && node.getNodeData().isHasSequence()
+                if ( search_domains && !match && node.getNodeData().isHasSequence()
                         && ( node.getNodeData().getSequence().getDomainArchitecture() != null ) ) {
                     final DomainArchitecture da = node.getNodeData().getSequence().getDomainArchitecture();
                     I: for( int i = 0; i < da.getNumberOfDomains(); ++i ) {
@@ -1515,22 +1517,6 @@ public class PhylogenyMethods {
                             break I;
                         }
                     }
-                    //                    final String[] bcp_ary = node.getNodeData().getBinaryCharacters()
-                    //                            .getPresentCharactersAsStringArray();
-                    //                    I: for( final String bc : bcp_ary ) {
-                    //                        if ( match( bc, query, case_sensitive, partial ) ) {
-                    //                            match = true;
-                    //                            break I;
-                    //                        }
-                    //                    }
-                    //                    final String[] bcg_ary = node.getNodeData().getBinaryCharacters()
-                    //                            .getGainedCharactersAsStringArray();
-                    //                    I: for( final String bc : bcg_ary ) {
-                    //                        if ( match( bc, query, case_sensitive, partial ) ) {
-                    //                            match = true;
-                    //                            break I;
-                    //                        }
-                    //                    }
                 }
                 if ( !match ) {
                     all_matched = false;
index acf6b39..891864b 100644 (file)
@@ -188,8 +188,9 @@ public final class PhylogenyDecorator {
                                  final boolean process_name_intelligently,
                                  final boolean process_similar_to,
                                  final int numbers_of_chars_allowed_to_remove_if_not_found_in_map,
-                                 final boolean move_domain_numbers_at_end_to_middle ) throws IllegalArgumentException,
-            NHXFormatException, PhyloXmlDataFormatException {
+                                 final boolean move_domain_numbers_at_end_to_middle,
+                                 final boolean trim_after_tilde ) throws IllegalArgumentException, NHXFormatException,
+            PhyloXmlDataFormatException {
         PhylogenyDecorator.decorate( phylogeny,
                                      map,
                                      field,
@@ -200,7 +201,8 @@ public final class PhylogenyDecorator {
                                      process_name_intelligently,
                                      process_similar_to,
                                      numbers_of_chars_allowed_to_remove_if_not_found_in_map,
-                                     move_domain_numbers_at_end_to_middle );
+                                     move_domain_numbers_at_end_to_middle,
+                                     trim_after_tilde );
     }
 
     /**
@@ -228,7 +230,8 @@ public final class PhylogenyDecorator {
                                  final boolean process_name_intelligently,
                                  final boolean process_similar_to,
                                  final int numbers_of_chars_allowed_to_remove_if_not_found_in_map,
-                                 final boolean move_domain_numbers_at_end_to_middle ) throws IllegalArgumentException,
+                                 final boolean move_domain_numbers_at_end_to_middle,
+                                 final boolean trim_after_tilde ) throws IllegalArgumentException,
             PhyloXmlDataFormatException {
         if ( extract_bracketed_scientific_name && ( field == FIELD.TAXONOMY_SCIENTIFIC_NAME ) ) {
             throw new IllegalArgumentException( "Attempt to extract bracketed scientific name together with data field pointing to scientific name" );
@@ -236,6 +239,9 @@ public final class PhylogenyDecorator {
         for( final PhylogenyNodeIterator iter = phylogeny.iteratorPostorder(); iter.hasNext(); ) {
             final PhylogenyNode node = iter.next();
             String name = node.getName();
+            if ( trim_after_tilde && ( name.indexOf( '~' ) > 0 ) ) {
+                name = name.substring( 0, name.indexOf( '~' ) );
+            }
             if ( !ForesterUtil.isEmpty( name ) ) {
                 if ( intermediate_map != null ) {
                     name = PhylogenyDecorator.extractIntermediate( intermediate_map, name );
@@ -384,8 +390,9 @@ public final class PhylogenyDecorator {
                                  final boolean process_name_intelligently,
                                  final boolean process_similar_to,
                                  final int numbers_of_chars_allowed_to_remove_if_not_found_in_map,
-                                 final boolean move_domain_numbers_at_end_to_middle ) throws IllegalArgumentException,
-            NHXFormatException, PhyloXmlDataFormatException {
+                                 final boolean move_domain_numbers_at_end_to_middle,
+                                 final boolean trim_after_tilde ) throws IllegalArgumentException, NHXFormatException,
+            PhyloXmlDataFormatException {
         for( int i = 0; i < phylogenies.length; ++i ) {
             PhylogenyDecorator.decorate( phylogenies[ i ],
                                          map,
@@ -396,7 +403,8 @@ public final class PhylogenyDecorator {
                                          process_name_intelligently,
                                          process_similar_to,
                                          numbers_of_chars_allowed_to_remove_if_not_found_in_map,
-                                         move_domain_numbers_at_end_to_middle );
+                                         move_domain_numbers_at_end_to_middle,
+                                         trim_after_tilde );
         }
     }
 
@@ -410,8 +418,9 @@ public final class PhylogenyDecorator {
                                  final boolean process_name_intelligently,
                                  final boolean process_similar_to,
                                  final int numbers_of_chars_allowed_to_remove_if_not_found_in_map,
-                                 final boolean move_domain_numbers_at_end_to_middle ) throws IllegalArgumentException,
-            NHXFormatException, PhyloXmlDataFormatException {
+                                 final boolean move_domain_numbers_at_end_to_middle,
+                                 final boolean trim_after_tilde ) throws IllegalArgumentException, NHXFormatException,
+            PhyloXmlDataFormatException {
         for( int i = 0; i < phylogenies.length; ++i ) {
             PhylogenyDecorator.decorate( phylogenies[ i ],
                                          map,
@@ -423,7 +432,8 @@ public final class PhylogenyDecorator {
                                          process_name_intelligently,
                                          process_similar_to,
                                          numbers_of_chars_allowed_to_remove_if_not_found_in_map,
-                                         move_domain_numbers_at_end_to_middle );
+                                         move_domain_numbers_at_end_to_middle,
+                                         trim_after_tilde );
         }
     }