From 57993b84f60d7830344be6c891a976adafd3bb50 Mon Sep 17 00:00:00 2001 From: cmzmasek Date: Thu, 14 May 2015 11:24:17 -0700 Subject: [PATCH] bug fixes and clean-up --- .../src/org/forester/applications/aa.java | 18 +++++++++--------- .../src/org/forester/applications/aaa.java | 10 +++++----- .../src/org/forester/applications/core_chars.java | 2 +- .../applications/domainloss_replacement.java | 4 ++-- .../genome_counts_for_once_appearing_dcs.java | 2 +- .../src/org/forester/applications/get_distances.java | 2 +- .../applications/get_genome_counts_per_char.java | 4 ++-- .../applications/get_subtree_specific_chars.java | 4 ++-- .../src/org/forester/applications/inverted_dcs.java | 2 +- .../src/org/forester/applications/map_lengths.java | 6 +++--- .../forester/applications/phylo2coloredgraphics.java | 2 -- .../src/org/forester/applications/reinv_count.java | 2 +- .../applications/shared_chars_in_ext_nodes.java | 2 +- .../forester/applications/simple_node_processor.java | 2 +- .../forester/applications/subtree_feature_count.java | 6 +++--- 15 files changed, 33 insertions(+), 35 deletions(-) diff --git a/forester_applications/src/org/forester/applications/aa.java b/forester_applications/src/org/forester/applications/aa.java index 2a64278..22eac98 100644 --- a/forester_applications/src/org/forester/applications/aa.java +++ b/forester_applications/src/org/forester/applications/aa.java @@ -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 orig = FastaParser + final List 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 all_found_seqs = new HashSet(); + final Set all_found_seqs = new HashSet(); 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 found_seqs = new ArrayList(); - for( final Sequence orig_seq : orig ) { + final List found_seqs = new ArrayList(); + 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++; diff --git a/forester_applications/src/org/forester/applications/aaa.java b/forester_applications/src/org/forester/applications/aaa.java index d6722a9..cc808a7 100644 --- a/forester_applications/src/org/forester/applications/aaa.java +++ b/forester_applications/src/org/forester/applications/aaa.java @@ -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 too_short = new ArrayList(); - final List orig = FastaParser + final List too_short = new ArrayList(); + final List orig = FastaParser .parse( new FileInputStream( "C:\\Users\\zma\\Desktop\\RRMa_domains_ext_20_2.fasta" ) ); final int initial_number = orig.size(); final List new_seqs = new ArrayList(); - 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( "" ); diff --git a/forester_applications/src/org/forester/applications/core_chars.java b/forester_applications/src/org/forester/applications/core_chars.java index bcb3241..a477654 100644 --- a/forester_applications/src/org/forester/applications/core_chars.java +++ b/forester_applications/src/org/forester/applications/core_chars.java @@ -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" ); diff --git a/forester_applications/src/org/forester/applications/domainloss_replacement.java b/forester_applications/src/org/forester/applications/domainloss_replacement.java index 15dce45..02860e9 100644 --- a/forester_applications/src/org/forester/applications/domainloss_replacement.java +++ b/forester_applications/src/org/forester/applications/domainloss_replacement.java @@ -23,7 +23,7 @@ public class domainloss_replacement { try { if ( args.length != 2 ) { System.out - .println( "Usage: domainloss_replacement " ); + .println( "Usage: domainloss_replacement " ); 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 ) ); } diff --git a/forester_applications/src/org/forester/applications/genome_counts_for_once_appearing_dcs.java b/forester_applications/src/org/forester/applications/genome_counts_for_once_appearing_dcs.java index 29320bf..5996052 100644 --- a/forester_applications/src/org/forester/applications/genome_counts_for_once_appearing_dcs.java +++ b/forester_applications/src/org/forester/applications/genome_counts_for_once_appearing_dcs.java @@ -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" ); diff --git a/forester_applications/src/org/forester/applications/get_distances.java b/forester_applications/src/org/forester/applications/get_distances.java index 62cb1b1..11d343b 100644 --- a/forester_applications/src/org/forester/applications/get_distances.java +++ b/forester_applications/src/org/forester/applications/get_distances.java @@ -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" ); diff --git a/forester_applications/src/org/forester/applications/get_genome_counts_per_char.java b/forester_applications/src/org/forester/applications/get_genome_counts_per_char.java index dd0b094..14a50d7 100644 --- a/forester_applications/src/org/forester/applications/get_genome_counts_per_char.java +++ b/forester_applications/src/org/forester/applications/get_genome_counts_per_char.java @@ -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 l = PhylogenyMethods.searchData( s, phy, true, false, false ); + final List l = PhylogenyMethods.searchData( s, phy, true, false, false, false, 0 ); if ( l.size() != 1 ) { System.err.println( "error: " + s ); System.exit( -1 ); diff --git a/forester_applications/src/org/forester/applications/get_subtree_specific_chars.java b/forester_applications/src/org/forester/applications/get_subtree_specific_chars.java index 9269d42..e27d881 100644 --- a/forester_applications/src/org/forester/applications/get_subtree_specific_chars.java +++ b/forester_applications/src/org/forester/applications/get_subtree_specific_chars.java @@ -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; } diff --git a/forester_applications/src/org/forester/applications/inverted_dcs.java b/forester_applications/src/org/forester/applications/inverted_dcs.java index e6e6ba3..de630d0 100644 --- a/forester_applications/src/org/forester/applications/inverted_dcs.java +++ b/forester_applications/src/org/forester/applications/inverted_dcs.java @@ -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" ); diff --git a/forester_applications/src/org/forester/applications/map_lengths.java b/forester_applications/src/org/forester/applications/map_lengths.java index c4f3983..2c0e321 100644 --- a/forester_applications/src/org/forester/applications/map_lengths.java +++ b/forester_applications/src/org/forester/applications/map_lengths.java @@ -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 seqs = FastaParser.parse( new File( fasta_name ) ); + final List 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( "/" ) ); diff --git a/forester_applications/src/org/forester/applications/phylo2coloredgraphics.java b/forester_applications/src/org/forester/applications/phylo2coloredgraphics.java index 8a7aeb5..8f41755 100644 --- a/forester_applications/src/org/forester/applications/phylo2coloredgraphics.java +++ b/forester_applications/src/org/forester/applications/phylo2coloredgraphics.java @@ -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, diff --git a/forester_applications/src/org/forester/applications/reinv_count.java b/forester_applications/src/org/forester/applications/reinv_count.java index 97760e1..492483a 100644 --- a/forester_applications/src/org/forester/applications/reinv_count.java +++ b/forester_applications/src/org/forester/applications/reinv_count.java @@ -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" ); diff --git a/forester_applications/src/org/forester/applications/shared_chars_in_ext_nodes.java b/forester_applications/src/org/forester/applications/shared_chars_in_ext_nodes.java index b86d6cc..82b6ebd 100644 --- a/forester_applications/src/org/forester/applications/shared_chars_in_ext_nodes.java +++ b/forester_applications/src/org/forester/applications/shared_chars_in_ext_nodes.java @@ -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" ); diff --git a/forester_applications/src/org/forester/applications/simple_node_processor.java b/forester_applications/src/org/forester/applications/simple_node_processor.java index 9373239..f9788ff 100644 --- a/forester_applications/src/org/forester/applications/simple_node_processor.java +++ b/forester_applications/src/org/forester/applications/simple_node_processor.java @@ -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 ); } diff --git a/forester_applications/src/org/forester/applications/subtree_feature_count.java b/forester_applications/src/org/forester/applications/subtree_feature_count.java index 60c4b16..aed156d 100644 --- a/forester_applications/src/org/forester/applications/subtree_feature_count.java +++ b/forester_applications/src/org/forester/applications/subtree_feature_count.java @@ -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" ); -- 1.7.10.2