bug fixes and clean-up
authorcmzmasek <cmzmasek@yahoo.com>
Thu, 14 May 2015 18:24:17 +0000 (11:24 -0700)
committercmzmasek <cmzmasek@yahoo.com>
Thu, 14 May 2015 18:24:17 +0000 (11:24 -0700)
15 files changed:
forester_applications/src/org/forester/applications/aa.java
forester_applications/src/org/forester/applications/aaa.java
forester_applications/src/org/forester/applications/core_chars.java
forester_applications/src/org/forester/applications/domainloss_replacement.java
forester_applications/src/org/forester/applications/genome_counts_for_once_appearing_dcs.java
forester_applications/src/org/forester/applications/get_distances.java
forester_applications/src/org/forester/applications/get_genome_counts_per_char.java
forester_applications/src/org/forester/applications/get_subtree_specific_chars.java
forester_applications/src/org/forester/applications/inverted_dcs.java
forester_applications/src/org/forester/applications/map_lengths.java
forester_applications/src/org/forester/applications/phylo2coloredgraphics.java
forester_applications/src/org/forester/applications/reinv_count.java
forester_applications/src/org/forester/applications/shared_chars_in_ext_nodes.java
forester_applications/src/org/forester/applications/simple_node_processor.java
forester_applications/src/org/forester/applications/subtree_feature_count.java

index 2a64278..22eac98 100644 (file)
@@ -12,7 +12,7 @@ import java.util.Set;
 import org.forester.io.parsers.FastaParser;
 import org.forester.msa.Msa;
 import org.forester.sequence.BasicSequence;
-import org.forester.sequence.Sequence;
+import org.forester.sequence.MolecularSequence;
 import org.forester.util.ForesterUtil;
 
 public class aa {
@@ -20,10 +20,10 @@ public class aa {
     public static void main( final String args[] ) {
         try {
             System.out.println( "STARTING..." );
-            final List<Sequence> orig = FastaParser
+            final List<MolecularSequence> orig = FastaParser
                     .parse( new FileInputStream( "C:\\Users\\zma\\Desktop\\RRMa_domains_ext_20.fasta" ) );
             final Msa msa = FastaParser.parseMsa( new FileInputStream( "C:\\Users\\zma\\Desktop\\test3_sorted.fasta" ) );
-            final Set<Sequence> all_found_seqs = new HashSet<Sequence>();
+            final Set<MolecularSequence> all_found_seqs = new HashSet<MolecularSequence>();
             for( int i = 0; i < msa.getNumberOfSequences(); ++i ) {
                 final String id = msa.getIdentifier( i );
                 final String id_ = id.substring( 0, id.indexOf( "_" ) );
@@ -38,8 +38,8 @@ public class aa {
                     System.exit( -1 );
                 }
                 int found = 0;
-                final List<Sequence> found_seqs = new ArrayList<Sequence>();
-                for( final Sequence orig_seq : orig ) {
+                final List<MolecularSequence> found_seqs = new ArrayList<MolecularSequence>();
+                for( final MolecularSequence orig_seq : orig ) {
                     final String orig_seq_id = orig_seq.getIdentifier();
                     if ( ( orig_seq_id.indexOf( id_ ) >= 0 ) && ( orig_seq_id.indexOf( "[" + range + "]" ) >= 0 ) ) {
                         found++;
@@ -47,16 +47,16 @@ public class aa {
                     }
                 }
                 if ( found > 0 ) {
-                    for( final Sequence found_seq : found_seqs ) {
+                    for( final MolecularSequence found_seq : found_seqs ) {
                         if ( found_seq.getLength() >= 85 ) {
                             all_found_seqs.add( BasicSequence.createAaSequence( id, found_seq
-                                    .getMolecularSequenceAsString() ) );
+                                                                                .getMolecularSequenceAsString() ) );
                         }
                     }
                     if ( found > 1 ) {
                         System.out.println( i + ": " + id + "=>" + id_ + " " + range );
                         System.out.println( "  found: " + found );
-                        for( final Sequence found_seq : found_seqs ) {
+                        for( final MolecularSequence found_seq : found_seqs ) {
                             System.out.println( found_seq.toString() );
                         }
                     }
@@ -68,7 +68,7 @@ public class aa {
             }
             final String fasta_ary[] = new String[ all_found_seqs.size() ];
             int i = 0;
-            for( final Sequence sequence : all_found_seqs ) {
+            for( final MolecularSequence sequence : all_found_seqs ) {
                 fasta_ary[ i ] = ">" + sequence.getIdentifier() + "\n" + sequence.getMolecularSequenceAsString();
                 System.out.println( sequence );
                 i++;
index d6722a9..cc808a7 100644 (file)
@@ -12,7 +12,7 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import org.forester.io.parsers.FastaParser;
-import org.forester.sequence.Sequence;
+import org.forester.sequence.MolecularSequence;
 import org.forester.util.EasyWriter;
 import org.forester.util.ForesterUtil;
 
@@ -26,12 +26,12 @@ public class aaa {
         try {
             final EasyWriter out = ( EasyWriter ) ForesterUtil.createEasyWriter( "aaa_out" );
             System.out.println( "STARTING..." );
-            final List<Sequence> too_short = new ArrayList<Sequence>();
-            final List<Sequence> orig = FastaParser
+            final List<MolecularSequence> too_short = new ArrayList<MolecularSequence>();
+            final List<MolecularSequence> orig = FastaParser
                     .parse( new FileInputStream( "C:\\Users\\zma\\Desktop\\RRMa_domains_ext_20_2.fasta" ) );
             final int initial_number = orig.size();
             final List<String> new_seqs = new ArrayList<String>();
-            for( final Sequence seq : orig ) {
+            for( final MolecularSequence seq : orig ) {
                 if ( seq.getLength() < MIN_LENGTH ) {
                     too_short.add( seq );
                     continue;
@@ -115,7 +115,7 @@ public class aaa {
             out.println( "" );
             out.println( "" );
             out.println( "Removed because too short:" );
-            for( final Sequence s : too_short ) {
+            for( final MolecularSequence s : too_short ) {
                 out.println( s.toString() );
             }
             out.println( "" );
index bcb3241..a477654 100644 (file)
@@ -57,7 +57,7 @@ public class core_chars {
         try {
             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
             phy = factory.create( infile, org.forester.io.parsers.util.ParserUtils
-                    .createParserDependingOnFileType( infile, true ) )[ 0 ];
+                                  .createParserDependingOnFileType( infile, true ) )[ 0 ];
         }
         catch ( final Exception e ) {
             System.err.println( e + "\nCould not read " + infile + "\n" );
index 15dce45..02860e9 100644 (file)
@@ -23,7 +23,7 @@ public class domainloss_replacement {
         try {
             if ( args.length != 2 ) {
                 System.out
-                        .println( "Usage: domainloss_replacement <phylogeny file> <file with replacement characters>" );
+                .println( "Usage: domainloss_replacement <phylogeny file> <file with replacement characters>" );
                 System.exit( -1 );
             }
             final Phylogeny p = ParserUtils.readPhylogenies( args[ 0 ] )[ 0 ];
@@ -46,7 +46,7 @@ public class domainloss_replacement {
                 final int losses = lost_chars.size();
                 lost_chars.retainAll( replacement_domains );
                 final int intersection = lost_chars.size();
-                final double percentage = 100.0 * intersection / losses;
+                final double percentage = ( 100.0 * intersection ) / losses;
                 System.out.println( name + "\t" + intersection + "\t" + losses + "\t"
                         + ForesterUtil.round( percentage, 3 ) );
             }
index 29320bf..5996052 100644 (file)
@@ -61,7 +61,7 @@ public class genome_counts_for_once_appearing_dcs {
         try {
             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
             phy = factory.create( infile, org.forester.io.parsers.util.ParserUtils
-                    .createParserDependingOnFileType( infile, true ) )[ 0 ];
+                                  .createParserDependingOnFileType( infile, true ) )[ 0 ];
         }
         catch ( final Exception e ) {
             System.err.println( e + "\nCould not read " + infile + "\n" );
index 62cb1b1..11d343b 100644 (file)
@@ -84,7 +84,7 @@ public class get_distances {
         }
         catch ( final IOException e ) {
             System.out.println( "\nError during processing of \"" + names_infile + "\" [" + e.getMessage()
-                    + "] at line \"" + line + "\"\n" );
+                                + "] at line \"" + line + "\"\n" );
             System.exit( -1 );
         }
         System.out.println( "\nDone.\n" );
index dd0b094..14a50d7 100644 (file)
@@ -58,7 +58,7 @@ public class get_genome_counts_per_char {
         try {
             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
             phy = factory.create( infile, org.forester.io.parsers.util.ParserUtils
-                    .createParserDependingOnFileType( infile, true ) )[ 0 ];
+                                  .createParserDependingOnFileType( infile, true ) )[ 0 ];
         }
         catch ( final Exception e ) {
             System.err.println( e + "\nCould not read " + infile + "\n" );
@@ -129,7 +129,7 @@ public class get_genome_counts_per_char {
     }
 
     private static PhylogenyNode find( final String s, final Phylogeny phy ) {
-        final List<PhylogenyNode> l = PhylogenyMethods.searchData( s, phy, true, false, false );
+        final List<PhylogenyNode> l = PhylogenyMethods.searchData( s, phy, true, false, false, false, 0 );
         if ( l.size() != 1 ) {
             System.err.println( "error: " + s );
             System.exit( -1 );
index 9269d42..e27d881 100644 (file)
@@ -59,7 +59,7 @@ public class get_subtree_specific_chars {
         try {
             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
             phy = factory.create( infile, org.forester.io.parsers.util.ParserUtils
-                    .createParserDependingOnFileType( infile, true ) )[ 0 ];
+                                  .createParserDependingOnFileType( infile, true ) )[ 0 ];
         }
         catch ( final Exception e ) {
             System.err.println( e + "\nCould not read " + infile + "\n" );
@@ -105,7 +105,7 @@ public class get_subtree_specific_chars {
                                 if ( !phy.getNode( external_id ).getNodeData().getBinaryCharacters()
                                         .getGainedCharacters().contains( node_char )
                                         && !phy.getNode( external_id ).getNodeData().getBinaryCharacters()
-                                                .getPresentCharacters().contains( node_char ) ) {
+                                        .getPresentCharacters().contains( node_char ) ) {
                                     found = false;
                                     break;
                                 }
index e6e6ba3..de630d0 100644 (file)
@@ -57,7 +57,7 @@ public class inverted_dcs {
         try {
             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
             phy = factory.create( infile, org.forester.io.parsers.util.ParserUtils
-                    .createParserDependingOnFileType( infile, true ) )[ 0 ];
+                                  .createParserDependingOnFileType( infile, true ) )[ 0 ];
         }
         catch ( final Exception e ) {
             System.err.println( e + "\nCould not read " + infile + "\n" );
index c4f3983..2c0e321 100644 (file)
@@ -40,7 +40,7 @@ import org.forester.phylogeny.data.Property;
 import org.forester.phylogeny.data.Property.AppliesTo;
 import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
 import org.forester.phylogeny.factories.PhylogenyFactory;
-import org.forester.sequence.Sequence;
+import org.forester.sequence.MolecularSequence;
 import org.forester.util.CommandLineArguments;
 import org.forester.util.ForesterUtil;
 
@@ -64,9 +64,9 @@ public class map_lengths {
             final Phylogeny phy = phylogenies_0[ 0 ];
             for( int i = 1; i < cla.getNumberOfNames(); i++ ) {
                 final String fasta_name = cla.getName( i );
-                final List<Sequence> seqs = FastaParser.parse( new File( fasta_name ) );
+                final List<MolecularSequence> seqs = FastaParser.parse( new File( fasta_name ) );
                 for( int s = 0; s < seqs.size(); s++ ) {
-                    final Sequence seq = seqs.get( s );
+                    final MolecularSequence seq = seqs.get( s );
                     final int actual_length = seq.getLength() - seq.getNumberOfGapResidues();
                     String node_name = "" + seq.getIdentifier();
                     node_name = node_name.substring( 0, node_name.indexOf( "/" ) );
index 8a7aeb5..8f41755 100644 (file)
@@ -53,9 +53,7 @@ public class phylo2coloredgraphics {
             config.putDisplayColors( TreeColorSet.BRANCH, new Color( 0, 0, 0 ) );
             config.putDisplayColors( TreeColorSet.TAXONOMY, new Color( 0, 0, 0 ) );
             config.setPhylogenyGraphicsType( Options.PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
-            config.setTaxonomyColorize( false );
             config.setColorizeBranches( true );
-            config.setUseBranchesWidths( true );
             config.setDisplayTaxonomyCode( false );
             // Writing to a graphics file.
             AptxUtil.writePhylogenyToGraphicsFile( phy,
index 97760e1..492483a 100644 (file)
@@ -57,7 +57,7 @@ public class reinv_count {
         try {
             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
             phy = factory.create( infile, org.forester.io.parsers.util.ParserUtils
-                    .createParserDependingOnFileType( infile, true ) )[ 0 ];
+                                  .createParserDependingOnFileType( infile, true ) )[ 0 ];
         }
         catch ( final Exception e ) {
             System.err.println( e + "\nCould not read " + infile + "\n" );
index b86d6cc..82b6ebd 100644 (file)
@@ -58,7 +58,7 @@ public class shared_chars_in_ext_nodes {
         try {
             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
             phy = factory.create( infile, org.forester.io.parsers.util.ParserUtils
-                    .createParserDependingOnFileType( infile, true ) )[ 0 ];
+                                  .createParserDependingOnFileType( infile, true ) )[ 0 ];
         }
         catch ( final Exception e ) {
             System.err.println( e + "\nCould not read " + infile + "\n" );
index 9373239..f9788ff 100644 (file)
@@ -124,7 +124,7 @@ public class simple_node_processor {
                     final String c = t.getTaxonomyCode();
                     if ( c.indexOf( "XX" ) == 3 ) {
                         System.out.println( "FAKE_CODE_TO_ID_MAP.put( \"" + c + "\", " + t.getIdentifier().getValue()
-                                + ");" );
+                                            + ");" );
                     }
                     //   SurfacingUtil.obtainHexColorStringDependingOnTaxonomyGroup( t.getTaxonomyCode(), phy );
                 }
index 60c4b16..aed156d 100644 (file)
@@ -92,9 +92,9 @@ public class subtree_feature_count {
                 }
             }
             final int n = l.size();
-            final double xray_p = ForesterUtil.round( 100.0 * xray / n, 1 );
-            final double nmr_p = ForesterUtil.round( 100.0 * nmr / n, 1 );
-            final double model_p = ForesterUtil.round( 100.0 * model / n, 1 );
+            final double xray_p = ForesterUtil.round( ( 100.0 * xray ) / n, 1 );
+            final double nmr_p = ForesterUtil.round( ( 100.0 * nmr ) / n, 1 );
+            final double model_p = ForesterUtil.round( ( 100.0 * model ) / n, 1 );
             final StringBuilder sb = new StringBuilder();
             sb.append( String.valueOf( n ) );
             sb.append( "\t" );