From e9ca0dc1764303d53fc6b9b087f33cdee53726ea Mon Sep 17 00:00:00 2001 From: "cmzmasek@gmail.com" Date: Thu, 6 Dec 2012 23:21:12 +0000 Subject: [PATCH] refactoring --- .../java/src/org/forester/application/rio.java | 6 ++-- .../io/parsers/HmmscanPerDomainTableParser.java | 2 +- forester/java/src/org/forester/sdi/RIO.java | 34 ++++++++++---------- .../sdi/{RioException.java => RIOException.java} | 6 ++-- 4 files changed, 24 insertions(+), 24 deletions(-) rename forester/java/src/org/forester/sdi/{RioException.java => RIOException.java} (59%) diff --git a/forester/java/src/org/forester/application/rio.java b/forester/java/src/org/forester/application/rio.java index 3c2684b..ad0c33a 100644 --- a/forester/java/src/org/forester/application/rio.java +++ b/forester/java/src/org/forester/application/rio.java @@ -40,7 +40,7 @@ import org.forester.phylogeny.Phylogeny; import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory; import org.forester.phylogeny.factories.PhylogenyFactory; import org.forester.sdi.RIO; -import org.forester.sdi.RioException; +import org.forester.sdi.RIOException; import org.forester.sdi.SDIException; import org.forester.util.CommandLineArguments; import org.forester.util.EasyWriter; @@ -214,7 +214,7 @@ public class rio { tableOutput( table_outfile, rio ); } } - catch ( final RioException e ) { + catch ( final RIOException e ) { ForesterUtil.fatalError( PRG_NAME, e.getLocalizedMessage() ); } catch ( final SDIException e ) { @@ -235,7 +235,7 @@ public class rio { System.exit( 0 ); } - private static void tableOutput( final File table_outfile, final RIO rio ) throws IOException, RioException { + private static void tableOutput( final File table_outfile, final RIO rio ) throws IOException, RIOException { final IntMatrix m = RIO.calculateOrthologTable( rio.getAnalyzedGeneTrees() ); writeTable( table_outfile, rio, m ); } diff --git a/forester/java/src/org/forester/io/parsers/HmmscanPerDomainTableParser.java b/forester/java/src/org/forester/io/parsers/HmmscanPerDomainTableParser.java index 2aa4497..b5d1bc1 100644 --- a/forester/java/src/org/forester/io/parsers/HmmscanPerDomainTableParser.java +++ b/forester/java/src/org/forester/io/parsers/HmmscanPerDomainTableParser.java @@ -64,7 +64,7 @@ public final class HmmscanPerDomainTableParser { private static final ReturnType RETURN_TYPE_DEFAULT = ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN; private static final boolean IGNORE_DUFS_DEFAULT = false; private static final int MAX_ALLOWED_OVERLAP_DEFAULT = -1; - private static final boolean IGNORE_REPLACED_RRMS = true; + private static final boolean IGNORE_REPLACED_RRMS = false; private final Set _filter; private final FilterType _filter_type; private final File _input_file; diff --git a/forester/java/src/org/forester/sdi/RIO.java b/forester/java/src/org/forester/sdi/RIO.java index 55c50ec..31e2fc7 100644 --- a/forester/java/src/org/forester/sdi/RIO.java +++ b/forester/java/src/org/forester/sdi/RIO.java @@ -65,10 +65,10 @@ public final class RIO { * Default constructor. * @throws SDIException * @throws IOException - * @throws RioException + * @throws RIOException */ public RIO( final File gene_trees_file, final Phylogeny species_tree, final String query ) throws IOException, - SDIException, RioException { + SDIException, RIOException { if ( ForesterUtil.isEmpty( query ) ) { throw new IllegalArgumentException( "query is empty" ); } @@ -77,7 +77,7 @@ public final class RIO { } public RIO( final File gene_trees_file, final Phylogeny species_tree ) throws IOException, SDIException, - RioException { + RIOException { init(); inferOrthologs( gene_trees_file, species_tree, null ); } @@ -374,12 +374,12 @@ public final class RIO { * the sequence name of the squence whose orthologs are to be * inferred * @throws SDIException - * @throws RioException + * @throws RIOException * @throws IOException * @throws FileNotFoundException */ private final void inferOrthologs( final File gene_trees_file, final Phylogeny species_tree, final String query ) - throws SDIException, RioException, FileNotFoundException, IOException { + throws SDIException, RIOException, FileNotFoundException, IOException { // Read in first tree to get its sequence names // and strip species_tree. final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance(); @@ -394,16 +394,16 @@ public final class RIO { // Removes from species_tree all species not found in gene_tree. PhylogenyMethods.taxonomyBasedDeletionOfExternalNodes( gene_trees[ 0 ], species_tree ); if ( species_tree.isEmpty() ) { - throw new RioException( "failed to establish species based mapping between gene and species trees" ); + throw new RIOException( "failed to establish species based mapping between gene and species trees" ); } if ( !ForesterUtil.isEmpty( query ) ) { PhylogenyMethods.taxonomyBasedDeletionOfExternalNodes( species_tree, gene_trees[ 0 ] ); if ( gene_trees[ 0 ].isEmpty() ) { - throw new RioException( "failed to establish species based mapping between gene and species trees" ); + throw new RIOException( "failed to establish species based mapping between gene and species trees" ); } _seq_names = getAllExternalSequenceNames( gene_trees[ 0 ] ); if ( ( _seq_names == null ) || ( _seq_names.size() < 1 ) ) { - throw new RioException( "could not get sequence names" ); + throw new RIOException( "could not get sequence names" ); } _o_maps = new HashMap>(); _so_maps = new HashMap>(); @@ -418,7 +418,7 @@ public final class RIO { // Removes from gene_tree all species not found in species_tree. PhylogenyMethods.taxonomyBasedDeletionOfExternalNodes( species_tree, gt ); if ( gt.isEmpty() ) { - throw new RioException( "failed to establish species based mapping between gene and species trees" ); + throw new RIOException( "failed to establish species based mapping between gene and species trees" ); } _analyzed_gene_trees[ c++ ] = inferOrthologsHelper( gt, species_tree, query ); } @@ -429,7 +429,7 @@ public final class RIO { // the external node with seqname query. private final Phylogeny inferOrthologsHelper( final Phylogeny gene_tree, final Phylogeny species_tree, - final String query ) throws SDIException, RioException { + final String query ) throws SDIException, RIOException { final SDIR sdiunrooted = new SDIR(); final Phylogeny assigned_tree = sdiunrooted.infer( gene_tree, species_tree, @@ -442,10 +442,10 @@ public final class RIO { if ( !ForesterUtil.isEmpty( query ) ) { final List nodes = getNodesViaSequenceName( assigned_tree, query ); if ( nodes.size() > 1 ) { - throw new RioException( "node named [" + query + "] not unique" ); + throw new RIOException( "node named [" + query + "] not unique" ); } else if ( nodes.isEmpty() ) { - throw new RioException( "no node containing a sequence named [" + query + "] found" ); + throw new RIOException( "no node containing a sequence named [" + query + "] found" ); } final PhylogenyNode query_node = nodes.get( 0 ); updateCounts( _o_maps, query, PhylogenyMethods.getOrthologousNodes( assigned_tree, query_node ) ); @@ -502,7 +502,7 @@ public final class RIO { } } - public final static IntMatrix calculateOrthologTable( final Phylogeny[] analyzed_gene_trees ) throws RioException { + public final static IntMatrix calculateOrthologTable( final Phylogeny[] analyzed_gene_trees ) throws RIOException { final List labels = new ArrayList(); final Set labels_set = new HashSet(); String label; @@ -536,7 +536,7 @@ public final class RIO { final String mx = m.getLabel( x ); final PhylogenyNode nx = map.get( mx ); if ( nx == null ) { - throw new RioException( "node \"" + mx + "\" not present in gene tree #" + counter ); + throw new RIOException( "node \"" + mx + "\" not present in gene tree #" + counter ); } String my; PhylogenyNode ny; @@ -544,7 +544,7 @@ public final class RIO { my = m.getLabel( y ); ny = map.get( my ); if ( ny == null ) { - throw new RioException( "node \"" + my + "\" not present in gene tree #" + counter ); + throw new RIOException( "node \"" + my + "\" not present in gene tree #" + counter ); } if ( !PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( nx, ny ).isDuplication() ) { m.inreaseByOne( x, y ); @@ -649,7 +649,7 @@ public final class RIO { return s; } - private final static List getAllExternalSequenceNames( final Phylogeny phy ) throws RioException { + private final static List getAllExternalSequenceNames( final Phylogeny phy ) throws RIOException { final List names = new ArrayList(); for( final PhylogenyNodeIterator iter = phy.iteratorExternalForward(); iter.hasNext(); ) { final PhylogenyNode n = iter.next(); @@ -660,7 +660,7 @@ public final class RIO { names.add( n.getName() ); } else { - throw new RioException( "node has no (sequence) name: " + n ); + throw new RIOException( "node has no (sequence) name: " + n ); } } return names; diff --git a/forester/java/src/org/forester/sdi/RioException.java b/forester/java/src/org/forester/sdi/RIOException.java similarity index 59% rename from forester/java/src/org/forester/sdi/RioException.java rename to forester/java/src/org/forester/sdi/RIOException.java index 25eeb8e..b9b7eb6 100644 --- a/forester/java/src/org/forester/sdi/RioException.java +++ b/forester/java/src/org/forester/sdi/RIOException.java @@ -1,18 +1,18 @@ package org.forester.sdi; -public class RioException extends Exception { +public class RIOException extends Exception { /** * */ private static final long serialVersionUID = 4691098852783522097L; - public RioException() { + public RIOException() { super(); } - public RioException( final String message ) { + public RIOException( final String message ) { super( message ); } } -- 1.7.10.2