|| !ForesterUtil.isEmpty( desc.getNodeData().getTaxonomy().getScientificName() )
|| !ForesterUtil.isEmpty( desc.getNodeData().getTaxonomy().getLineage() )
|| !ForesterUtil.isEmpty( desc.getNodeData().getTaxonomy().getTaxonomyCode() ) || !ForesterUtil
- .isEmpty( desc.getNodeData().getTaxonomy().getCommonName() ) ) ) {
+ .isEmpty( desc.getNodeData().getTaxonomy().getCommonName() ) ) ) {
final UniProtTaxonomy up_tax = TaxonomyDataManager.obtainUniProtTaxonomy( desc.getNodeData()
.getTaxonomy(), null, null );
if ( ( up_tax == null ) && ForesterUtil.isEmpty( desc.getNodeData().getTaxonomy().getLineage() ) ) {
i++;
}
Arrays.sort( fasta_ary );
- for( int j = 0; j < fasta_ary.length; ++j ) {
- System.out.println( fasta_ary[ j ] );
+ for( final String element : fasta_ary ) {
+ System.out.println( element );
}
System.out.println( "DONE." );
}
}
double value = 1;
if ( norm > 0 ) {
- value = norm / ( 1 + last - first );
+ value = norm / ( ( 1 + last ) - first );
}
ForesterUtil.programMessage( PRG_NAME, "first topology to use: " + first );
String is_last = "";
is_last = " (corresponds to last topology in file)";
}
ForesterUtil.programMessage( PRG_NAME, "last topology to use : " + last + is_last );
- ForesterUtil.programMessage( PRG_NAME, "sum of topologies used as evaluators: " + ( last - first + 1 ) );
+ ForesterUtil.programMessage( PRG_NAME, "sum of topologies used as evaluators: " + ( ( last - first ) + 1 ) );
if ( norm > 0 ) {
ForesterUtil.programMessage( PRG_NAME, "normalizer: " + norm + " (" + ForesterUtil.round( value, 6 ) + ")" );
}
phylogenies[ 0 ].setIdentifier( new Identifier( s_ary[ 1 ], s_ary[ 0 ] ) );
}
if ( !ForesterUtil.isEmpty( tree_desc ) ) {
- for( int i = 0; i < phylogenies.length; ++i ) {
- phylogenies[ i ].setDescription( tree_desc );
+ for( final Phylogeny phylogenie : phylogenies ) {
+ phylogenie.setDescription( tree_desc );
}
}
}
final int counts = counts_id.get( id );
double percentage = 0.0;
if ( sum > 0 ) {
- percentage = 100.0 * counts / ( sum );
+ percentage = ( 100.0 * counts ) / ( sum );
}
System.out.println( counts + "\t" + counts + "/" + sum + "\t" + percentage + "\t" + id + "\t"
+ goid_to_term_map.get( id ).getName() );
step = 1;
}
final double id_ratios[] = new double[ msa.getLength() ];
- for( int i = 0; i <= msa.getLength() - 1; ++i ) {
+ for( int i = 0; i <= ( msa.getLength() - 1 ); ++i ) {
id_ratios[ i ] = MsaMethods.calculateIdentityRatio( msa, i );
}
String min_pos = "";
String max_pos = "";
double min = 1;
double max = 0;
- for( int i = 0; i <= msa.getLength() - 1; i += step ) {
- int to = i + window - 1;
+ for( int i = 0; i <= ( msa.getLength() - 1 ); i += step ) {
+ int to = ( i + window ) - 1;
if ( to > ( msa.getLength() - 1 ) ) {
to = msa.getLength() - 1;
}
final GoId go_id = pfam_to_go_mapping.getValue();
final Set<GoId> supers = GoUtils.getAllSuperGoIds( go_id, goid_to_term_map );
supers.add( go_id );
- for( int i = 0; i < queries.length; ++i ) {
- if ( supers.contains( queries[ i ] ) ) {
+ for( final GoId querie : queries ) {
+ if ( supers.contains( querie ) ) {
pfams.add( domain_id.toString() );
}
}
else if ( ( args.length < 3 ) || ( args.length > 18 ) ) {
errorInCommandLine();
}
- for( int i = 0; i < args.length; ++i ) {
- if ( args[ i ].trim().charAt( 0 ) != 'p' ) {
- if ( args[ i ].trim().length() < 3 ) {
+ for( final String arg2 : args ) {
+ if ( arg2.trim().charAt( 0 ) != 'p' ) {
+ if ( arg2.trim().length() < 3 ) {
errorInCommandLine();
}
else {
- arg = args[ i ].trim().substring( 2 );
+ arg = arg2.trim().substring( 2 );
}
}
try {
- switch ( args[ i ].trim().charAt( 0 ) ) {
+ switch ( arg2.trim().charAt( 0 ) ) {
case 'M':
multiple_trees_file = new File( arg );
break;
suffix = suffix.trim();
out = new PrintWriter( new FileWriter( outfile ), true );
//nodecount0 = PhylogenyNode.getNodeCount();
- for( int i = 0; i < filenames.length; ++i ) {
- filename = filenames[ i ];
+ for( final String filename2 : filenames ) {
+ filename = filename2;
if ( ( suffix.length() < 1 ) || filename.endsWith( suffix ) ) {
final File gene_tree_file = new File( indir.getPath(), filename );
if ( gene_tree_file.exists() && gene_tree_file.isFile() ) {
}
out.println();
if ( write_trees ) {
- outtree = new File( outdir, new File( filenames[ i ] ).getName() );
+ outtree = new File( outdir, new File( filename2 ).getName() );
final PhylogenyWriter writer = new PhylogenyWriter();
writer.toPhyloXML( outtree, trees[ 0 ], 1 );
}
}
else {
names = new String[ args.length - 3 ];
- for( int i = 0; i < args.length - 3; ++i ) {
+ for( int i = 0; i < ( args.length - 3 ); ++i ) {
names[ i ] = args[ i + 3 ];
}
}
"Average of proteins with a least one domain assigned: "
+ ( 100 * protein_coverage_stats.arithmeticMean() ) + "% (+/-"
+ ( 100 * protein_coverage_stats.sampleStandardDeviation() ) + "%)" );
- ForesterUtil.programMessage( PRG_NAME, "Range of proteins with a least one domain assigned: " + 100
- * protein_coverage_stats.getMin() + "%-" + 100 * protein_coverage_stats.getMax() + "%" );
+ ForesterUtil.programMessage( PRG_NAME, "Range of proteins with a least one domain assigned: "
+ + ( 100 * protein_coverage_stats.getMin() ) + "%-" + ( 100 * protein_coverage_stats.getMax() )
+ + "%" );
log( "Average of prot with a least one dom assigned : " + ( 100 * protein_coverage_stats.arithmeticMean() )
+ "% (+/-" + ( 100 * protein_coverage_stats.sampleStandardDeviation() ) + "%)", log_writer );
- log( "Range of prot with a least one dom assigned : " + 100 * protein_coverage_stats.getMin() + "%-"
- + 100 * protein_coverage_stats.getMax() + "%", log_writer );
+ log( "Range of prot with a least one dom assigned : " + ( 100 * protein_coverage_stats.getMin() ) + "%-"
+ + ( 100 * protein_coverage_stats.getMax() ) + "%", log_writer );
}
catch ( final IOException e2 ) {
ForesterUtil.fatalError( surfacing.PRG_NAME, e2.getLocalizedMessage() );
System.out.print( ", not mapped domains = " + mapping_results.getSumOfFailures() );
if ( total_domains > 0 ) {
System.out.println( ", mapped ratio = "
- + ( 100 * mapping_results.getSumOfSuccesses() / total_domains ) + "%" );
+ + ( ( 100 * mapping_results.getSumOfSuccesses() ) / total_domains ) + "%" );
}
else {
System.out.println( ", mapped ratio = n/a (total domains = 0 )" );
for( final Entry<Integer, Integer> entry : all_genomes_domains_per_potein_histo.entrySet() ) {
sum += entry.getValue();
}
- final double percentage = 100.0 * ( sum - all_genomes_domains_per_potein_histo.get( 1 ) ) / sum;
+ final double percentage = ( 100.0 * ( sum - all_genomes_domains_per_potein_histo.get( 1 ) ) ) / sum;
ForesterUtil.programMessage( PRG_NAME, "Percentage of multidomain proteins: " + percentage + "%" );
log( "Percentage of multidomain proteins: : " + percentage + "%", log_writer );
}
}
System.out.println( "--" );
}
- for( int i = 0; i < input_file_properties.length; ++i ) {
+ for( final String[] input_file_propertie : input_file_properties ) {
try {
- intree.getNode( input_file_properties[ i ][ 1 ] );
+ intree.getNode( input_file_propertie[ 1 ] );
}
catch ( final IllegalArgumentException e ) {
- ForesterUtil.fatalError( surfacing.PRG_NAME, "node named [" + input_file_properties[ i ][ 1 ]
+ ForesterUtil.fatalError( surfacing.PRG_NAME, "node named [" + input_file_propertie[ 1 ]
+ "] not present/not unique in input tree" );
}
}
if ( n.getNodeData().isHasTaxonomy()
&& ( !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getScientificName() )
|| !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getCommonName() ) || !ForesterUtil
- .isEmpty( n.getNodeData().getTaxonomy().getTaxonomyCode() ) ) ) {
+ .isEmpty( n.getNodeData().getTaxonomy().getTaxonomyCode() ) ) ) {
if ( !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getRank() )
&& n.getNodeData().getTaxonomy().getRank().equalsIgnoreCase( rank ) ) {
final BranchColor c = new BranchColor( tree_panel.calculateTaxonomyBasedColor( n.getNodeData()
/**
* Action performed.
*/
+ @Override
public void actionPerformed( final ActionEvent e ) {
final Object o = e.getSource();
boolean is_applet = false;
// See "Swing's Threading Policy".
SwingUtilities.invokeLater( new Runnable() {
+ @Override
public void run() {
doUpdateProcessMenu();
}
}
}
if ( !phylogeny_node.isRoot() ) {
- addSubelement( category, "Depth", String.valueOf( phylogeny_node.calculateDepth() ) );
+ addSubelement( category, "Depth", String.valueOf( phylogeny_node.calculateDepth() ) );
final double d = phylogeny_node.calculateDistanceToRoot();
if ( d > 0 ) {
addSubelement( category, "Distance to root", String.valueOf( ForesterUtil.FORMATTER_6.format( d ) ) );
}
void cycleColorScheme() {
- if ( getCurrentColorScheme() >= _color_schemes.length - 1 ) {
+ if ( getCurrentColorScheme() >= ( _color_schemes.length - 1 ) ) {
setColorSchema( 0 );
}
else {
}
}
+ @Override
final public void actionPerformed( final ActionEvent e ) {
boolean done = false;
final JMenuItem node_popup_menu_item = ( JMenuItem ) e.getSource();
if ( ( _phylogeny == null ) || _phylogeny.isEmpty() ) {
return null;
}
- final int half_box_size_plus_wiggle = getOptions().getDefaultNodeShapeSize() / 2 + WIGGLE;
+ final int half_box_size_plus_wiggle = ( getOptions().getDefaultNodeShapeSize() / 2 ) + WIGGLE;
for( final PhylogenyNodeIterator iter = _phylogeny.iteratorPostorder(); iter.hasNext(); ) {
final PhylogenyNode node = iter.next();
if ( ( _phylogeny.isRooted() || !node.isRoot() || ( node.getNumberOfDescendants() > 2 ) )
}
final private void increaseOvSize() {
- if ( ( getOvMaxWidth() < getMainPanel().getCurrentScrollPane().getViewport().getVisibleRect().getWidth() / 2 )
- && ( getOvMaxHeight() < getMainPanel().getCurrentScrollPane().getViewport().getVisibleRect()
- .getHeight() / 2 ) ) {
+ if ( ( getOvMaxWidth() < ( getMainPanel().getCurrentScrollPane().getViewport().getVisibleRect().getWidth() / 2 ) )
+ && ( getOvMaxHeight() < ( getMainPanel().getCurrentScrollPane().getViewport().getVisibleRect()
+ .getHeight() / 2 ) ) ) {
setOvMaxWidth( getOvMaxWidth() + 5 );
setOvMaxHeight( getOvMaxHeight() + 5 );
updateOvSettings();
setTreeFile( null );
setEdited( false );
initializeOvSettings();
- setStartingAngle( TWO_PI * 3 / 4 );
+ setStartingAngle( ( TWO_PI * 3 ) / 4 );
final ImageLoader il = new ImageLoader( this );
new Thread( il ).start();
}
}
final boolean inOv( final MouseEvent e ) {
- return ( ( e.getX() > getVisibleRect().x + getOvXPosition() + 1 )
- && ( e.getX() < getVisibleRect().x + getOvXPosition() + getOvMaxWidth() - 1 )
- && ( e.getY() > getVisibleRect().y + getOvYPosition() + 1 ) && ( e.getY() < getVisibleRect().y
- + getOvYPosition() + getOvMaxHeight() - 1 ) );
+ return ( ( e.getX() > ( getVisibleRect().x + getOvXPosition() + 1 ) )
+ && ( e.getX() < ( ( getVisibleRect().x + getOvXPosition() + getOvMaxWidth() ) - 1 ) )
+ && ( e.getY() > ( getVisibleRect().y + getOvYPosition() + 1 ) ) && ( e.getY() < ( ( getVisibleRect().y
+ + getOvYPosition() + getOvMaxHeight() ) - 1 ) ) );
}
final boolean inOvRectangle( final MouseEvent e ) {
- return ( ( e.getX() >= getOvRectangle().getX() - 1 )
- && ( e.getX() <= getOvRectangle().getX() + getOvRectangle().getWidth() + 1 )
- && ( e.getY() >= getOvRectangle().getY() - 1 ) && ( e.getY() <= getOvRectangle().getY()
- + getOvRectangle().getHeight() + 1 ) );
+ return ( ( e.getX() >= ( getOvRectangle().getX() - 1 ) )
+ && ( e.getX() <= ( getOvRectangle().getX() + getOvRectangle().getWidth() + 1 ) )
+ && ( e.getY() >= ( getOvRectangle().getY() - 1 ) ) && ( e.getY() <= ( getOvRectangle().getY()
+ + getOvRectangle().getHeight() + 1 ) ) );
}
final private boolean inOvVirtualRectangle( final int x, final int y ) {
- return ( ( x >= getOvVirtualRectangle().x - 1 )
- && ( x <= getOvVirtualRectangle().x + getOvVirtualRectangle().width + 1 )
- && ( y >= getOvVirtualRectangle().y - 1 ) && ( y <= getOvVirtualRectangle().y
- + getOvVirtualRectangle().height + 1 ) );
+ return ( ( x >= ( getOvVirtualRectangle().x - 1 ) )
+ && ( x <= ( getOvVirtualRectangle().x + getOvVirtualRectangle().width + 1 ) )
+ && ( y >= ( getOvVirtualRectangle().y - 1 ) ) && ( y <= ( getOvVirtualRectangle().y
+ + getOvVirtualRectangle().height + 1 ) ) );
}
final private boolean inOvVirtualRectangle( final MouseEvent e ) {
if ( getControlPanel().isShowTaxonomyImages() ) {
y_dist = 40 + ( int ) getYdistance();
}
- return ( ( node.getYcoord() < getVisibleRect().getMinY() - y_dist )
- || ( node.getYcoord() > getVisibleRect().getMaxY() + y_dist ) || ( ( node.getParent() != null ) && ( node
+ return ( ( node.getYcoord() < ( getVisibleRect().getMinY() - y_dist ) )
+ || ( node.getYcoord() > ( getVisibleRect().getMaxY() + y_dist ) ) || ( ( node.getParent() != null ) && ( node
.getParent().getXcoord() > getVisibleRect().getMaxX() ) ) );
}
final private boolean isNodeDataInvisibleUnrootedCirc( final PhylogenyNode node ) {
- return ( ( node.getYcoord() < getVisibleRect().getMinY() - 20 )
- || ( node.getYcoord() > getVisibleRect().getMaxY() + 20 )
- || ( node.getXcoord() < getVisibleRect().getMinX() - 20 ) || ( node.getXcoord() > getVisibleRect()
- .getMaxX() + 20 ) );
+ return ( ( node.getYcoord() < ( getVisibleRect().getMinY() - 20 ) )
+ || ( node.getYcoord() > ( getVisibleRect().getMaxY() + 20 ) )
+ || ( node.getXcoord() < ( getVisibleRect().getMinX() - 20 ) ) || ( node.getXcoord() > ( getVisibleRect()
+ .getMaxX() + 20 ) ) );
}
final private boolean isNonLinedUpCladogram() {
if ( getOptions().isShowOverview() && isOvOn() && isInOv() ) {
final double w_ratio = getVisibleRect().width / getOvRectangle().getWidth();
final double h_ratio = getVisibleRect().height / getOvRectangle().getHeight();
- double x = ( e.getX() - getVisibleRect().x - getOvXPosition() - getOvRectangle().getWidth() / 2.0 )
+ double x = ( e.getX() - getVisibleRect().x - getOvXPosition() - ( getOvRectangle().getWidth() / 2.0 ) )
* w_ratio;
- double y = ( e.getY() - getVisibleRect().y - getOvYPosition() - getOvRectangle().getHeight() / 2.0 )
+ double y = ( e.getY() - getVisibleRect().y - getOvYPosition() - ( getOvRectangle().getHeight() / 2.0 ) )
* h_ratio;
if ( x < 0 ) {
x = 0;
final double w_ratio = getVisibleRect().width / getOvRectangle().getWidth();
final double h_ratio = getVisibleRect().height / getOvRectangle().getHeight();
final Point scroll_position = getMainPanel().getCurrentScrollPane().getViewport().getViewPosition();
- double dx = ( w_ratio * e.getX() - w_ratio * getLastDragPointX() );
- double dy = ( h_ratio * e.getY() - h_ratio * getLastDragPointY() );
+ double dx = ( ( w_ratio * e.getX() ) - ( w_ratio * getLastDragPointX() ) );
+ double dy = ( ( h_ratio * e.getY() ) - ( h_ratio * getLastDragPointY() ) );
scroll_position.x = ForesterUtil.roundToInt( scroll_position.x + dx );
scroll_position.y = ForesterUtil.roundToInt( scroll_position.y + dy );
if ( scroll_position.x <= 0 ) {
setCursor( ARROW_CURSOR );
}
+ @Override
final public void mouseWheelMoved( final MouseWheelEvent e ) {
final int notches = e.getWheelRotation();
if ( inOvVirtualRectangle( e ) ) {
final double root_y = _root.getYcoord();
final double dx = root_x - p.getXcoord();
final double dy = root_y - p.getYcoord();
- final double parent_radius = Math.sqrt( dx * dx + dy * dy );
+ final double parent_radius = Math.sqrt( ( dx * dx ) + ( dy * dy ) );
final double arc = ( _urt_nodeid_angle_map.get( p.getId() ) ) - angle;
assignGraphicsForBranchWithColorForParentBranch( c, false, g, to_pdf, to_graphics_file );
if ( ( c.isFirstChildNode() || c.isLastChildNode() )
if ( c.isExternal() ) {
final boolean is_in_found_nodes = isInFoundNodes( c );
if ( ( _dynamic_hiding_factor > 1 ) && !is_in_found_nodes
- && ( _urt_nodeid_index_map.get( c.getId() ) % _dynamic_hiding_factor != 1 ) ) {
+ && ( ( _urt_nodeid_index_map.get( c.getId() ) % _dynamic_hiding_factor ) != 1 ) ) {
return;
}
paintNodeDataUnrootedCirc( g, c, to_pdf, to_graphics_file, radial_labels, 0, is_in_found_nodes );
final double dx = root_x - p.getXSecondary();
final double dy = root_y - p.getYSecondary();
final double arc = ( _urt_nodeid_angle_map.get( p.getId() ) ) - angle;
- final double parent_radius = Math.sqrt( dx * dx + dy * dy );
+ final double parent_radius = Math.sqrt( ( dx * dx ) + ( dy * dy ) );
g.setColor( getTreeColorSet().getOvColor() );
if ( ( c.isFirstChildNode() || c.isLastChildNode() ) && ( Math.abs( arc ) > 0.02 ) ) {
final double r2 = 2.0 * parent_radius;
|| ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED ) ) {
if ( !to_graphics_file
&& !to_pdf
- && ( ( ( y2 < getVisibleRect().getMinY() - 20 ) && ( y1 < getVisibleRect().getMinY() - 20 ) ) || ( ( y2 > getVisibleRect()
- .getMaxY() + 20 ) && ( y1 > getVisibleRect().getMaxY() + 20 ) ) ) ) {
+ && ( ( ( y2 < ( getVisibleRect().getMinY() - 20 ) ) && ( y1 < ( getVisibleRect().getMinY() - 20 ) ) ) || ( ( y2 > ( getVisibleRect()
+ .getMaxY() + 20 ) ) && ( y1 > ( getVisibleRect().getMaxY() + 20 ) ) ) ) ) {
// Do nothing.
}
else {
}
// draw the horizontal line
if ( !to_graphics_file && !to_pdf
- && ( ( y2 < getVisibleRect().getMinY() - 20 ) || ( y2 > getVisibleRect().getMaxY() + 20 ) ) ) {
+ && ( ( y2 < ( getVisibleRect().getMinY() - 20 ) ) || ( y2 > ( getVisibleRect().getMaxY() + 20 ) ) ) ) {
return;
}
float x1_r = 0;
double current_angle = starting_angle;
for( final PhylogenyNodeIterator it = phy.iteratorExternalForward(); it.hasNext(); ) {
final PhylogenyNode n = it.next();
- n.setXSecondary( ( float ) ( center_x + radius * Math.cos( current_angle ) ) );
- n.setYSecondary( ( float ) ( center_y + radius * Math.sin( current_angle ) ) );
+ n.setXSecondary( ( float ) ( center_x + ( radius * Math.cos( current_angle ) ) ) );
+ n.setYSecondary( ( float ) ( center_y + ( radius * Math.sin( current_angle ) ) ) );
_urt_nodeid_angle_map.put( n.getId(), current_angle );
current_angle += ( TWO_PI / circ_num_ext_nodes );
}
}
double r = 0;
if ( !n.isRoot() ) {
- r = 1 - ( ( ( double ) _circ_max_depth - n.calculateDepth() ) / _circ_max_depth );
+ r = 1 - ( ( ( double ) _circ_max_depth - n.calculateDepth() ) / _circ_max_depth );
}
final double theta = sum / descs.size();
- n.setXcoord( ( float ) ( center_x + r * radius * Math.cos( theta ) ) );
- n.setYcoord( ( float ) ( center_y + r * radius * Math.sin( theta ) ) );
+ n.setXcoord( ( float ) ( center_x + ( r * radius * Math.cos( theta ) ) ) );
+ n.setYcoord( ( float ) ( center_y + ( r * radius * Math.sin( theta ) ) ) );
_urt_nodeid_angle_map.put( n.getId(), theta );
for( final PhylogenyNode desc : descs ) {
paintBranchCircular( n, desc, g, radial_labels, to_pdf, to_graphics_file );
}
float r = 0;
if ( !n.isRoot() ) {
- r = 1 - ( ( ( float ) _circ_max_depth - n.calculateDepth() ) / _circ_max_depth );
+ r = 1 - ( ( ( float ) _circ_max_depth - n.calculateDepth() ) / _circ_max_depth );
}
final double theta = _urt_nodeid_angle_map.get( n.getId() );
- n.setXSecondary( ( float ) ( center_x + radius * r * Math.cos( theta ) ) );
- n.setYSecondary( ( float ) ( center_y + radius * r * Math.sin( theta ) ) );
+ n.setXSecondary( ( float ) ( center_x + ( radius * r * Math.cos( theta ) ) ) );
+ n.setYSecondary( ( float ) ( center_y + ( radius * r * Math.sin( theta ) ) ) );
for( final PhylogenyNode desc : descs ) {
paintBranchCircularLite( n, desc, g );
}
x += CONFIDENCE_LEFT_MARGIN + confidenceWidth;
}
}
- if ( x + nodeTextBoundsWidth > 0 ) /* we only underline if there is something displayed */
+ if ( ( x + nodeTextBoundsWidth ) > 0 ) /* we only underline if there is something displayed */
{
if ( nodeTextBoundsWidth == 0 ) {
nodeTextBoundsWidth -= 3; /* the gap between taxonomy code and node name should not be underlined if nothing comes after it */
}
// y = y - ( 0.9 * getYdistance() );
final double hs = bi.getHeight() * scaling_factor;
- double ws = bi.getWidth() * scaling_factor + offset;
+ double ws = ( bi.getWidth() * scaling_factor ) + offset;
final double my_y = y - ( 0.5 * hs );
final int x_w = ( int ) ( x + ws + 0.5 );
final int y_h = ( int ) ( my_y + hs + 0.5 );
- if ( ( x_w - x > 7 ) && ( y_h - my_y > 7 ) ) {
+ if ( ( ( x_w - x ) > 7 ) && ( ( y_h - my_y ) > 7 ) ) {
g.drawImage( bi,
( int ) ( x + 0.5 + offset ),
( int ) ( my_y + 0.5 ),
}
if ( dynamically_hide
&& !is_in_found_nodes
- && ( ( node.isExternal() && ( _external_node_index % dynamic_hiding_factor != 1 ) ) || ( !node
- .isExternal() && ( ( new_x_min < 20 ) || ( _y_distance * node.getNumberOfExternalNodes() < getTreeFontSet()._fm_large
+ && ( ( node.isExternal() && ( ( _external_node_index % dynamic_hiding_factor ) != 1 ) ) || ( !node
+ .isExternal() && ( ( new_x_min < 20 ) || ( ( _y_distance * node.getNumberOfExternalNodes() ) < getTreeFontSet()._fm_large
.getHeight() ) ) ) ) ) {
return;
}
final float y_ratio = ( float ) getHeight() / getVisibleRect().y;
final float width = getOvMaxWidth() / w_ratio;
final float height = getOvMaxHeight() / h_ratio;
- final float x = getVisibleRect().x + getOvXPosition() + getOvMaxWidth() / x_ratio;
- final float y = getVisibleRect().y + getOvYPosition() + getOvMaxHeight() / y_ratio;
+ final float x = getVisibleRect().x + getOvXPosition() + ( getOvMaxWidth() / x_ratio );
+ final float y = getVisibleRect().y + getOvYPosition() + ( getOvMaxHeight() / y_ratio );
g.setColor( getTreeColorSet().getFoundColor() );
getOvRectangle().setRect( x, y, width, height );
if ( ( width < 6 ) && ( height < 6 ) ) {
// paintNodeRectangular( g, it.next(), to_pdf, getControlPanel().isDynamicallyHideData()
// && ( dynamic_hiding_factor > 1 ), dynamic_hiding_factor, to_graphics_file );
//}
- for( int i = 0; i < _nodes_in_preorder.length; ++i ) {
- paintNodeRectangular( g, _nodes_in_preorder[ i ], to_pdf, getControlPanel().isDynamicallyHideData()
+ for( final PhylogenyNode element : _nodes_in_preorder ) {
+ paintNodeRectangular( g, element, to_pdf, getControlPanel().isDynamicallyHideData()
&& ( dynamic_hiding_factor > 1 ), dynamic_hiding_factor, to_graphics_file );
}
if ( getOptions().isShowScale() && getControlPanel().isDrawPhylogram() && ( getScaleDistance() > 0.0 ) ) {
}
paintUnrooted( _phylogeny.getRoot(),
angle,
- ( float ) ( angle + 2 * Math.PI ),
+ ( float ) ( angle + ( 2 * Math.PI ) ),
radial_labels,
g,
to_pdf,
g.setColor( getTreeColorSet().getOvColor() );
paintUnrootedLite( _phylogeny.getRoot(),
angle,
- angle + 2 * Math.PI,
+ angle + ( 2 * Math.PI ),
g,
( getUrtFactorOv() / ( getVisibleRect().width / getOvMaxWidth() ) ) );
paintOvRectangle( g );
//for( it = _phylogeny.iteratorPreorder(); it.hasNext(); ) {
// paintNodeLite( g, it.next() );
//}
- for( int i = 0; i < _nodes_in_preorder.length; ++i ) {
- paintNodeLite( g, _nodes_in_preorder[ i ] );
+ for( final PhylogenyNode element : _nodes_in_preorder ) {
+ paintNodeLite( g, element );
}
paintOvRectangle( g );
}
else {
length = getUrtFactor();
}
- final double mid_angle = current_angle + arc_size / 2;
- final float new_x = ( float ) ( x + Math.cos( mid_angle ) * length );
- final float new_y = ( float ) ( y + Math.sin( mid_angle ) * length );
+ final double mid_angle = current_angle + ( arc_size / 2 );
+ final float new_x = ( float ) ( x + ( Math.cos( mid_angle ) * length ) );
+ final float new_y = ( float ) ( y + ( Math.sin( mid_angle ) * length ) );
desc.setXcoord( new_x );
desc.setYcoord( new_y );
paintUnrooted( desc, current_angle, current_angle + arc_size, radial_labels, g, to_pdf, to_graphics_file );
final Graphics2D g,
final float urt_ov_factor ) {
if ( n.isRoot() ) {
- final int x_pos = ( int ) ( getVisibleRect().x + getOvXPosition() + getOvMaxWidth() / 2 );
- final int y_pos = ( int ) ( getVisibleRect().y + getOvYPosition() + getOvMaxHeight() / 2 );
+ final int x_pos = ( int ) ( getVisibleRect().x + getOvXPosition() + ( getOvMaxWidth() / 2 ) );
+ final int y_pos = ( int ) ( getVisibleRect().y + getOvYPosition() + ( getOvMaxHeight() / 2 ) );
n.setXSecondary( x_pos );
n.setYSecondary( y_pos );
}
else {
length = urt_ov_factor;
}
- final double mid_angle = current_angle + arc_size / 2;
- final float new_x = ( float ) ( x + Math.cos( mid_angle ) * length );
- final float new_y = ( float ) ( y + Math.sin( mid_angle ) * length );
+ final double mid_angle = current_angle + ( arc_size / 2 );
+ final float new_x = ( float ) ( x + ( Math.cos( mid_angle ) * length ) );
+ final float new_y = ( float ) ( y + ( Math.sin( mid_angle ) * length ) );
desc.setXSecondary( new_x );
desc.setYSecondary( new_y );
if ( isInFoundNodes( desc ) ) {
}
final Phylogeny buffer_phy = getCutOrCopiedTree().copy();
buffer_phy.setAllNodesToNotCollapse();
- buffer_phy.preOrderReId();
+ PhylogenyMethods.preOrderReId( buffer_phy );
buffer_phy.setRooted( true );
boolean need_to_show_whole = false;
if ( paste_as_sibling ) {
repaint();
}
+ @Override
final public int print( final Graphics g, final PageFormat page_format, final int page_index )
throws PrinterException {
if ( page_index > 0 ) {
_node_frame_index--;
_node_frames[ i ] = null;
if ( i < _node_frame_index ) {
- for( int j = 0; j < _node_frame_index - 1; j++ ) {
+ for( int j = 0; j < ( _node_frame_index - 1 ); j++ ) {
_node_frames[ j ] = _node_frames[ j + 1 ];
}
_node_frames[ _node_frame_index ] = null;
}
final void updateOvSizes() {
- if ( ( getWidth() > 1.05 * getVisibleRect().width ) || ( getHeight() > 1.05 * getVisibleRect().height ) ) {
+ if ( ( getWidth() > ( 1.05 * getVisibleRect().width ) ) || ( getHeight() > ( 1.05 * getVisibleRect().height ) ) ) {
setOvOn( true );
float l = getLongestExtNodeInfo();
final float w_ratio = getOvMaxWidth() / getWidth();
for( int i = 0; i < _domain_structure.getDomains().size(); ++i ) {
final ProteinDomain d = _domain_structure.getDomain( i );
if ( d.getConfidence() <= Math.pow( 10, _e_value_threshold_exp ) ) {
- final double xa = start + d.getFrom() * f;
- final double xb = xa + d.getLength() * f;
+ final double xa = start + ( d.getFrom() * f );
+ final double xb = xa + ( d.getLength() * f );
if ( tree_panel.getMainPanel().getOptions().isShowDomainLabels() ) {
g.setFont( tree_panel.getMainPanel().getTreeFontSet().getSmallFont() );
g.setColor( getConfiguration().getDomainStructureFontColor() );
final double width = ( double ) DEFAULT_WIDTH / _values.size();
for( int i = 0; i < _values.size(); ++i ) {
g.setColor( calculateColor( _values.get( i ) ) );
- _rectangle.setFrame( start + i * width, y - 0.5, width, getRenderingHeight() );
+ _rectangle.setFrame( start + ( i * width ), y - 0.5, width, getRenderingHeight() );
g.fill( _rectangle );
}
}
@Override
public String toString() {
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
for( int x = 0; x < size(); ++x ) {
if ( getLabel( x ) != null ) {
sb.append( getLabel( x ) );
final Random r = new Random();
PhylogenyNode n = t.getFirstExternalNode();
while ( n != null ) {
- final String code = ( ( Math.abs( r.nextInt() ) % ( ma - mi + 1 ) ) + mi ) + "";
+ final String code = ( ( Math.abs( r.nextInt() ) % ( ( ma - mi ) + 1 ) ) + mi ) + "";
try {
PhylogenyMethods.setTaxonomyCode( n, code );
}
@Override
public Dimension getPreferredSize() {
final int width = ( getWellSize() + 1 ) * ( getColumns() + 1 );
- final int hight = ( getWellSize() + 1 ) * ( getRows() + 1 ) + 30;
+ final int hight = ( ( getWellSize() + 1 ) * ( getRows() + 1 ) ) + 30;
return new Dimension( width, hight );
}
private void initializeWells() {
_wells = new AbstractRenderer[ getRows() + 1 ][ getColumns() + 1 ];
for( int row = 0; row < getRows(); row++ ) {
- for( int col = 0; col < getColumns() + 1; col++ ) {
+ for( int col = 0; col < ( getColumns() + 1 ); col++ ) {
AbstractRenderer r;
if ( col == getColumns() ) {
// r = new LabelRenderer( PlateData.ALPHABET[ row % PlateData.ALPHABET.length ] + "", this );
// setAbstractRenderer( r, row, col );
}
}
- for( int col = 0; col < getColumns() + 1; col++ ) {
+ for( int col = 0; col < ( getColumns() + 1 ); col++ ) {
// AbstractRenderer r;
if ( col == getColumns() ) {
// r = new LabelRenderer( "", this );
// g
// .drawString( "Number:" + getPlateData().getName() + " Replicate:"
// + ( getPlateData().getReplicateNumber() + 1 ), 10, 20 );
- for( int row = 0; row < getRows() + 1; row++ ) {
- for( int col = 0; col < getColumns() + 1; col++ ) {
+ for( int row = 0; row < ( getRows() + 1 ); row++ ) {
+ for( int col = 0; col < ( getColumns() + 1 ); col++ ) {
getAbstractRenderer( row, col ).paint( g );
}
}
public void resetWellSize( final int well_size ) {
setWellSize( well_size );
final int factor = well_size + 0;
- for( int row = 0; row < getRows() + 1; row++ ) {
- for( int col = 0; col < getColumns() + 1; col++ ) {
+ for( int row = 0; row < ( getRows() + 1 ); row++ ) {
+ for( int col = 0; col < ( getColumns() + 1 ); col++ ) {
final AbstractRenderer r = getAbstractRenderer( row, col );
- r.setX( 10 + factor * col );
- r.setY( factor * row + 30 );
+ r.setX( 10 + ( factor * col ) );
+ r.setY( ( factor * row ) + 30 );
r.setWellSize( well_size );
}
}
}
private void setIsSelectedOfAll( final boolean isSelected ) {
- for( int col = 0; col < getColumns() + 1; col++ ) {
+ for( int col = 0; col < ( getColumns() + 1 ); col++ ) {
setIsSelectedOfColumn( col, isSelected );
}
}
private void setIsSelectedOfColumn( final int column, final boolean isSelected ) {
- for( int row = 0; row < getRows() + 1; row++ ) {
+ for( int row = 0; row < ( getRows() + 1 ); row++ ) {
getAbstractRenderer( row, column ).setIsSelected( isSelected );
}
}
private void setIsSelectedOfRow( final int row, final boolean isSelected ) {
- for( int col = 0; col < getColumns() + 1; col++ ) {
+ for( int col = 0; col < ( getColumns() + 1 ); col++ ) {
getAbstractRenderer( row, col ).setIsSelected( isSelected );
}
}
value = max;
}
final double x = ( 255D * ( value - min ) ) / ( max - min );
- final int red = ( int ) ( minColor.getRed() + x * calcFactor( minColor.getRed(), maxColor.getRed() ) );
- final int green = ( int ) ( minColor.getGreen() + x * calcFactor( minColor.getGreen(), maxColor.getGreen() ) );
- final int blue = ( int ) ( minColor.getBlue() + x * calcFactor( minColor.getBlue(), maxColor.getBlue() ) );
+ final int red = ( int ) ( minColor.getRed() + ( x * calcFactor( minColor.getRed(), maxColor.getRed() ) ) );
+ final int green = ( int ) ( minColor.getGreen() + ( x * calcFactor( minColor.getGreen(), maxColor.getGreen() ) ) );
+ final int blue = ( int ) ( minColor.getBlue() + ( x * calcFactor( minColor.getBlue(), maxColor.getBlue() ) ) );
return new Color( red, green, blue );
}
}
if ( value < mean ) {
final double x = ( 255D * ( value - min ) ) / ( mean - min );
- final int red = ( int ) ( minColor.getRed() + x * calcFactor( minColor.getRed(), meanColor.getRed() ) );
- final int green = ( int ) ( minColor.getGreen() + x
- * calcFactor( minColor.getGreen(), meanColor.getGreen() ) );
- final int blue = ( int ) ( minColor.getBlue() + x * calcFactor( minColor.getBlue(), meanColor.getBlue() ) );
+ final int red = ( int ) ( minColor.getRed() + ( x * calcFactor( minColor.getRed(), meanColor.getRed() ) ) );
+ final int green = ( int ) ( minColor.getGreen() + ( x * calcFactor( minColor.getGreen(),
+ meanColor.getGreen() ) ) );
+ final int blue = ( int ) ( minColor.getBlue() + ( x * calcFactor( minColor.getBlue(), meanColor.getBlue() ) ) );
return new Color( red, green, blue );
}
if ( value > mean ) {
final double x = ( 255D * ( value - mean ) ) / ( max - mean );
- final int red = ( int ) ( meanColor.getRed() + x * calcFactor( meanColor.getRed(), maxColor.getRed() ) );
- final int green = ( int ) ( meanColor.getGreen() + x
- * calcFactor( meanColor.getGreen(), maxColor.getGreen() ) );
- final int blue = ( int ) ( meanColor.getBlue() + x * calcFactor( meanColor.getBlue(), maxColor.getBlue() ) );
+ final int red = ( int ) ( meanColor.getRed() + ( x * calcFactor( meanColor.getRed(), maxColor.getRed() ) ) );
+ final int green = ( int ) ( meanColor.getGreen() + ( x * calcFactor( meanColor.getGreen(),
+ maxColor.getGreen() ) ) );
+ final int blue = ( int ) ( meanColor.getBlue() + ( x * calcFactor( meanColor.getBlue(), maxColor.getBlue() ) ) );
return new Color( red, green, blue );
}
else {
// } /* coeffs */
// compute cosine and sine of theta
void coeffs( final double x, final double y, final DoublePointer c, final DoublePointer s, final double accuracy ) {
- final double root = Math.sqrt( x * x + y * y );
+ final double root = Math.sqrt( ( x * x ) + ( y * y ) );
if ( root < accuracy ) {
c.setValue( 1.0 );
s.setValue( 0.0 );
do {
TEMP = a[ i - 2 ][ i - 2 ] - a[ i - 1 ][ i - 1 ];
TEMP1 = a[ i - 1 ][ i - 2 ];
- d = Math.sqrt( TEMP * TEMP + TEMP1 * TEMP1 );
+ d = Math.sqrt( ( TEMP * TEMP ) + ( TEMP1 * TEMP1 ) );
approx = a[ i - 2 ][ i - 2 ] + a[ i - 1 ][ i - 1 ];
if ( a[ i - 1 ][ i - 1 ] < a[ i - 2 ][ i - 2 ] ) {
approx = ( approx - d ) / 2.0;
double d;
for( k = 0; k < n; k++ ) {
if ( left ) {
- d = ctheta * a[ i - 1 ][ k ] + stheta * a[ j - 1 ][ k ];
- a[ j - 1 ][ k ] = ctheta * a[ j - 1 ][ k ] - stheta * a[ i - 1 ][ k ];
+ d = ( ctheta * a[ i - 1 ][ k ] ) + ( stheta * a[ j - 1 ][ k ] );
+ a[ j - 1 ][ k ] = ( ctheta * a[ j - 1 ][ k ] ) - ( stheta * a[ i - 1 ][ k ] );
a[ i - 1 ][ k ] = d;
}
else {
- d = ctheta * a[ k ][ i - 1 ] + stheta * a[ k ][ j - 1 ];
- a[ k ][ j - 1 ] = ctheta * a[ k ][ j - 1 ] - stheta * a[ k ][ i - 1 ];
+ d = ( ctheta * a[ k ][ i - 1 ] ) + ( stheta * a[ k ][ j - 1 ] );
+ a[ k ][ j - 1 ] = ( ctheta * a[ k ][ j - 1 ] ) - ( stheta * a[ k ][ i - 1 ] );
a[ k ][ i - 1 ] = d;
}
}
}
// _d_values[ _mappings[ otu1 ] ][ _mappings[ i ] ] = ( getValueFromD( otu1, i ) + getValueFromD( i, otu2 ) - d ) / 2;
i_m = _mappings[ i ];
- _d_values[ otu1_m ][ i_m ] = ( _d_values[ otu1_m ][ i_m ] + _d_values[ i_m ][ otu2_m ] - 2 ) / 2;
+ _d_values[ otu1_m ][ i_m ] = ( ( _d_values[ otu1_m ][ i_m ] + _d_values[ i_m ][ otu2_m ] ) - 2 ) / 2;
}
}
j_m = _mappings[ j ];
for( int i = 0; i < j; ++i ) {
// _m_values[ i ][ j ] = getValueFromD( i, j ) - ( _r[ i ] + r_j ) / ( _n - 2 );
- _m_values[ i ][ j ] = _d_values[ _mappings[ i ] ][ j_m ] - ( _r[ i ] + r_j ) / ( _n_2 );
+ _m_values[ i ][ j ] = _d_values[ _mappings[ i ] ][ j_m ] - ( ( _r[ i ] + r_j ) / ( _n_2 ) );
}
}
}
// otu2 will, in effect, be "deleted" from the matrix.
private final void updateMappings( final int otu2 ) {
- for( int i = otu2; i < _mappings.length - 1; ++i ) {
+ for( int i = otu2; i < ( _mappings.length - 1 ); ++i ) {
_mappings[ i ] = _mappings[ i + 1 ];
}
}
final String c = getCharacter( character );
writer.write( c != null ? ForesterUtil.pad( c, longest, ' ', false ).toString() : ForesterUtil
.pad( "", longest, ' ', false ).toString() );
- if ( character < getNumberOfCharacters() - 1 ) {
+ if ( character < ( getNumberOfCharacters() - 1 ) ) {
writer.write( ' ' );
}
}
final S state = getState( identifier, character );
writer.write( state != null ? ForesterUtil.pad( state.toString(), longest, ' ', false ).toString()
: ForesterUtil.pad( "", longest, ' ', false ).toString() );
- if ( character < getNumberOfCharacters() - 1 ) {
+ if ( character < ( getNumberOfCharacters() - 1 ) ) {
writer.write( ' ' );
}
}
- if ( identifier < getNumberOfIdentifiers() - 1 ) {
+ if ( identifier < ( getNumberOfIdentifiers() - 1 ) ) {
writer.write( ForesterUtil.LINE_SEPARATOR );
}
}
final String state = getState( identifier, character ).toString();
writer.write( state != null ? ForesterUtil.pad( state, pad, ' ', false ).toString() : ForesterUtil
.pad( "", pad, ' ', false ).toString() );
- if ( character < getNumberOfCharacters() - 1 ) {
+ if ( character < ( getNumberOfCharacters() - 1 ) ) {
writer.write( ' ' );
writer.write( ' ' );
}
}
- if ( identifier < getNumberOfIdentifiers() - 1 ) {
+ if ( identifier < ( getNumberOfIdentifiers() - 1 ) ) {
writer.write( ForesterUtil.LINE_SEPARATOR );
}
}
w.write( " " + ( i + 1 ) + " '" );
w.write( getCharacter( i ) );
w.write( "'" );
- if ( i < getNumberOfCharacters() - 1 ) {
+ if ( i < ( getNumberOfCharacters() - 1 ) ) {
w.write( "," );
w.write( ForesterUtil.LINE_SEPARATOR );
}
}
w.write( state.toString() );
}
- if ( identifier < getNumberOfIdentifiers() - 1 ) {
+ if ( identifier < ( getNumberOfIdentifiers() - 1 ) ) {
w.write( ForesterUtil.LINE_SEPARATOR );
}
}
}
for( int col = 0; col < getSize(); ++col ) {
w.write( PHYLIP_FORMATTER.format( getValue( col, row ) ) );
- if ( col < getSize() - 1 ) {
+ if ( col < ( getSize() - 1 ) ) {
w.write( ' ' );
w.write( ' ' );
}
}
- if ( row < getSize() - 1 ) {
+ if ( row < ( getSize() - 1 ) ) {
w.write( ForesterUtil.LINE_SEPARATOR );
}
}
//sb.append( "" );
for( int col = 0; col < getSize(); ++col ) {
sb.append( PHYLIP_FORMATTER.format( getValue( col, row ) ) );
- if ( col < getSize() - 1 ) {
+ if ( col < ( getSize() - 1 ) ) {
sb.append( ' ' );
sb.append( ' ' );
}
}
- if ( row < getSize() - 1 ) {
+ if ( row < ( getSize() - 1 ) ) {
sb.append( ForesterUtil.LINE_SEPARATOR );
}
}
throw new IOException( "illegal format for distance [" + table_value + "] at [" + ( col - 1 ) + ", " + row
+ "]" );
}
- distance_matrix.setValue( col - 1 + col_offset, row, d );
+ distance_matrix.setValue( ( col - 1 ) + col_offset, row, d );
}
private DistanceMatrix transform( final BasicTable<String> table ) throws IllegalArgumentException, IOException {
if ( table.getNumberOfColumns() == table.getNumberOfRows() ) {
first_line_is_size = true;
}
- else if ( table.getNumberOfColumns() != table.getNumberOfRows() + 1 ) {
+ else if ( table.getNumberOfColumns() != ( table.getNumberOfRows() + 1 ) ) {
throw new IllegalArgumentException( "attempt to create distance matrix with illegal dimensions [columns: "
+ table.getNumberOfColumns() + ", rows: " + table.getNumberOfRows() + "]" );
}
if ( first_line_is_size ) {
start_row = 1;
}
- for( int row = 0; row < table.getNumberOfRows() - start_row; row++ ) {
+ for( int row = 0; row < ( table.getNumberOfRows() - start_row ); row++ ) {
distance_matrix.setIdentifier( row, table.getValue( 0, row + start_row ) );
switch ( getInputMatrixType() ) {
case LOWER_TRIANGLE:
final private DescriptiveStatistics[] calcStats() {
final DescriptiveStatistics stats[] = calc();
sort( stats );
- for( int i = 0; i < stats.length; ++i ) {
- final DescriptiveStatistics s = stats[ i ];
- // System.out.print( s.getDescription() );
- // System.out.print( "\t" );
- // System.out.print( s.arithmeticMean() );
- // System.out.print( "\t(" );
- // System.out.print( s.arithmeticMean() );
- // System.out.print( ")" );
- // System.out.print( "\t" );
- // System.out.print( s.getMin() );
- // System.out.print( "\t" );
- // System.out.print( s.getMax() );
- // System.out.println();
+ for( final DescriptiveStatistics s : stats ) {
}
return stats;
}
final CoverageCalculator cc = CoverageCalculator.getInstance( new ExternalNodeBasedCoverageMethod(),
options );
Coverage cov = cc.calculateCoverage( phylogenies, names, false );
- if ( !TestPccx.isEqual( cov.getScore(), ( 1.0 + 1.0 / 2 + 1.0 / 3 + 1.0 / 4 + 1.0 / 7 + 1.0 / 7 + 1.0 / 7
- + 1.0 / 7 + 1.0 / 5 ) / 9 ) ) {
+ if ( !TestPccx.isEqual( cov.getScore(), ( 1.0 + ( 1.0 / 2 ) + ( 1.0 / 3 ) + ( 1.0 / 4 ) + ( 1.0 / 7 )
+ + ( 1.0 / 7 ) + ( 1.0 / 7 ) + ( 1.0 / 7 ) + ( 1.0 / 5 ) ) / 9 ) ) {
return false;
}
names.add( "B" );
names.add( "B" );
cov = cc.calculateCoverage( phylogenies, names, false );
- if ( !TestPccx.isEqual( cov.getScore(), ( 1.0 + 1.0 + 1.0 / 3 + 1.0 / 4 + 1.0 / 7 + 1.0 / 7 + 1.0 / 7 + 1.0
- / 7 + 1.0 / 5 ) / 9 ) ) {
+ if ( !TestPccx.isEqual( cov.getScore(), ( 1.0 + 1.0 + ( 1.0 / 3 ) + ( 1.0 / 4 ) + ( 1.0 / 7 ) + ( 1.0 / 7 )
+ + ( 1.0 / 7 ) + ( 1.0 / 7 ) + ( 1.0 / 5 ) ) / 9 ) ) {
return false;
}
names.add( "G" );
cov = cc.calculateCoverage( phylogenies, names, false );
- if ( !TestPccx
- .isEqual( cov.getScore(),
- ( 1.0 + 1.0 + 1.0 / 3 + 1.0 / 4 + 1.0 / 4 + 1.0 / 4 + 1.0 + 1.0 / 2 + 1.0 / 4 ) / 9 ) ) {
+ if ( !TestPccx.isEqual( cov.getScore(), ( 1.0 + 1.0 + ( 1.0 / 3 ) + ( 1.0 / 4 ) + ( 1.0 / 4 ) + ( 1.0 / 4 )
+ + 1.0 + ( 1.0 / 2 ) + ( 1.0 / 4 ) ) / 9 ) ) {
return false;
}
names.add( "E" );
cov = cc.calculateCoverage( phylogenies, names, false );
- if ( !TestPccx.isEqual( cov.getScore(),
- ( 1.0 + 1.0 + 1.0 / 3 + 1.0 / 4 + 1.0 + 1.0 / 2 + 1.0 + 1.0 / 2 + 1.0 / 4 ) / 9 ) ) {
+ if ( !TestPccx.isEqual( cov.getScore(), ( 1.0 + 1.0 + ( 1.0 / 3 ) + ( 1.0 / 4 ) + 1.0 + ( 1.0 / 2 ) + 1.0
+ + ( 1.0 / 2 ) + ( 1.0 / 4 ) ) / 9 ) ) {
return false;
}
names.add( "X" );
cov = cc.calculateCoverage( phylogenies, names, false );
- if ( !TestPccx.isEqual( cov.getScore(),
- ( 1.0 + 1.0 + 1.0 / 3 + 1.0 / 3 + 1.0 + 1.0 / 2 + 1.0 + 1.0 / 2 + 1.0 ) / 9 ) ) {
+ if ( !TestPccx.isEqual( cov.getScore(), ( 1.0 + 1.0 + ( 1.0 / 3 ) + ( 1.0 / 3 ) + 1.0 + ( 1.0 / 2 ) + 1.0
+ + ( 1.0 / 2 ) + 1.0 ) / 9 ) ) {
return false;
}
names.add( "C" );
names.add( "C" );
names.add( "C" );
cov = cc.calculateCoverage( phylogenies, names, false );
- if ( !TestPccx.isEqual( cov.getScore(),
- ( 1.0 + 1.0 + 1.0 + 1.0 / 3 + 1.0 + 1.0 / 2 + 1.0 + 1.0 / 2 + 1.0 ) / 9 ) ) {
+ if ( !TestPccx.isEqual( cov.getScore(), ( 1.0 + 1.0 + 1.0 + ( 1.0 / 3 ) + 1.0 + ( 1.0 / 2 ) + 1.0
+ + ( 1.0 / 2 ) + 1.0 ) / 9 ) ) {
return false;
}
names.add( "D" );
cov = cc.calculateCoverage( phylogenies, names, false );
- if ( !TestPccx
- .isEqual( cov.getScore(), ( 1.0 + 1.0 + 1.0 + 1.0 + 1.0 + 1.0 / 2 + 1.0 + 1.0 / 2 + 1.0 ) / 9 ) ) {
+ if ( !TestPccx.isEqual( cov.getScore(),
+ ( 1.0 + 1.0 + 1.0 + 1.0 + 1.0 + ( 1.0 / 2 ) + 1.0 + ( 1.0 / 2 ) + 1.0 ) / 9 ) ) {
return false;
}
names.add( "F" );
cov = cc.calculateCoverage( phylogenies, names, false );
- if ( !TestPccx.isEqual( cov.getScore(), ( 1.0 + 1.0 + 1.0 + 1.0 + 1.0 + 1.0 + 1.0 + 1.0 / 2 + 1.0 ) / 9 ) ) {
+ if ( !TestPccx
+ .isEqual( cov.getScore(), ( 1.0 + 1.0 + 1.0 + 1.0 + 1.0 + 1.0 + 1.0 + ( 1.0 / 2 ) + 1.0 ) / 9 ) ) {
return false;
}
names.add( "H" );
final CoverageCalculator cc2 = CoverageCalculator.getInstance( new ExternalNodeBasedCoverageMethod(),
options2 );
Coverage cov2 = cc2.calculateCoverage( phylogenies2, names2, false );
- final double nf = 1 / ( 1 / 0.1 + 1 / 0.7 + 1 / 1.0 + 1 / 1.7 + 1 / 0.3 + 1 / 0.4 + 1 / 0.5 + 1 / 0.6 + 1 / 2.0 );
- if ( !TestPccx.isEqual( cov2.getScore(), ( 1 / 0.1 + ( 1 / 0.8 + 1 / 0.2 + 1 / 0.15 ) / 3 + 1 / 1.3 + 1
- / 4.0 + 1 / 6.4 + 1 / 6.5 + 1 / 6.7 + 1 / 6.8 + 1 / 5.6 )
+ final double nf = 1 / ( ( 1 / 0.1 ) + ( 1 / 0.7 ) + ( 1 / 1.0 ) + ( 1 / 1.7 ) + ( 1 / 0.3 ) + ( 1 / 0.4 )
+ + ( 1 / 0.5 ) + ( 1 / 0.6 ) + ( 1 / 2.0 ) );
+ if ( !TestPccx.isEqual( cov2.getScore(), ( ( 1 / 0.1 )
+ + ( ( ( 1 / 0.8 ) + ( 1 / 0.2 ) + ( 1 / 0.15 ) ) / 3 ) + ( 1 / 1.3 ) + ( 1 / 4.0 ) + ( 1 / 6.4 )
+ + ( 1 / 6.5 ) + ( 1 / 6.7 ) + ( 1 / 6.8 ) + ( 1 / 5.6 ) )
* nf ) ) {
return false;
}
names2.add( "C" );
cov2 = cc2.calculateCoverage( phylogenies2, names2, false );
- if ( !TestPccx.isEqual( cov2.getScore(), ( 1 / 0.1 + ( 1 / 0.8 + 1 / 0.2 + 1 / 0.15 ) / 3 + 1 / 1.0 + 1
- / 4.0 + 1 / 6.4 + 1 / 6.5 + 1 / 6.7 + 1 / 6.8 + 1 / 5.6 )
+ if ( !TestPccx.isEqual( cov2.getScore(), ( ( 1 / 0.1 )
+ + ( ( ( 1 / 0.8 ) + ( 1 / 0.2 ) + ( 1 / 0.15 ) ) / 3 ) + ( 1 / 1.0 ) + ( 1 / 4.0 ) + ( 1 / 6.4 )
+ + ( 1 / 6.5 ) + ( 1 / 6.7 ) + ( 1 / 6.8 ) + ( 1 / 5.6 ) )
* nf ) ) {
return false;
}
names2.add( "E" );
cov2 = cc2.calculateCoverage( phylogenies2, names2, false );
- if ( !TestPccx.isEqual( cov2.getScore(), ( 1 / 0.1 + ( 1 / 0.8 + 1 / 0.2 + 1 / 0.15 ) / 3 + 1 / 1.0 + +1
- / 4.0 + 1 / 0.3 + 1 / 0.7 + 1 / 3.1 + 1 / 3.2 + 1 / 4.8 )
+ if ( !TestPccx.isEqual( cov2.getScore(), ( ( 1 / 0.1 )
+ + ( ( ( 1 / 0.8 ) + ( 1 / 0.2 ) + ( 1 / 0.15 ) ) / 3 ) + ( 1 / 1.0 ) + ( +1 / 4.0 ) + ( 1 / 0.3 )
+ + ( 1 / 0.7 ) + ( 1 / 3.1 ) + ( 1 / 3.2 ) + ( 1 / 4.8 ) )
* nf ) ) {
return false;
}
PhylogenyNode.setNodeCount( max + 1 );
}
- public void preOrderReId() {
- if ( isEmpty() ) {
- return;
- }
- setIdToNodeMap( null );
- int i = PhylogenyNode.getNodeCount();
- for( final PhylogenyNodeIterator it = iteratorPreorder(); it.hasNext(); ) {
- it.next().setId( i++ );
- }
- PhylogenyNode.setNodeCount( i );
- }
-
/**
* Prints descriptions of all external Nodes of this Phylogeny to
* System.out.
_identifier = identifier;
}
- private void setIdToNodeMap( final HashMap<Integer, PhylogenyNode> idhash ) {
+ public void setIdToNodeMap( final HashMap<Integer, PhylogenyNode> idhash ) {
_id_to_node_map = idhash;
}
hc_2 = node_2_hc;
}
}
- result = PRIME * result + ( ( _data == null ) ? 0 : _data.hashCode() );
- result = PRIME * result + ( _is_directed ? 1231 : 1237 );
- result = PRIME * result + hc_1;
- result = PRIME * result + hc_2;
+ result = ( PRIME * result ) + ( ( _data == null ) ? 0 : _data.hashCode() );
+ result = ( PRIME * result ) + ( _is_directed ? 1231 : 1237 );
+ result = ( PRIME * result ) + hc_1;
+ result = ( PRIME * result ) + hc_2;
return result;
}
* @return distance between node1 and node2
*/
public double calculateDistance( final PhylogenyNode node1, final PhylogenyNode node2 ) {
- final PhylogenyNode lca =calculateLCA( node1, node2 );
+ final PhylogenyNode lca = calculateLCA( node1, node2 );
final PhylogenyNode n1 = node1;
final PhylogenyNode n2 = node2;
return ( PhylogenyMethods.getDistance( n1, lca ) + PhylogenyMethods.getDistance( n2, lca ) );
if ( node1 == node2 ) {
return node1;
}
- if (( node1.getParent() == node2.getParent() ) /*&& node1.getParent() != null */ ) {
+ if ( ( node1.getParent() == node2.getParent() ) ) {
return node1.getParent();
}
- int depth1 = node1.calculateDepth() ;
- int depth2 = node2.calculateDepth() ;
+ int depth1 = node1.calculateDepth();
+ int depth2 = node2.calculateDepth();
while ( ( depth1 > -1 ) && ( depth2 > -1 ) ) {
if ( depth1 > depth2 ) {
node1 = node1.getParent();
throw new IllegalArgumentException( "illegal attempt to calculate LCA of two nodes which do not share a common root" );
}
+ public static final void preOrderReId( final Phylogeny phy ) {
+ if ( phy.isEmpty() ) {
+ return;
+ }
+ phy.setIdToNodeMap( null );
+ int i = PhylogenyNode.getNodeCount();
+ for( final PhylogenyNodeIterator it = phy.iteratorPreorder(); it.hasNext(); ) {
+ it.next().setId( i++ );
+ }
+ PhylogenyNode.setNodeCount( i );
+ }
+
+ /**
+ * Returns the LCA of PhylogenyNodes node1 and node2.
+ * Precondition: ids are in pre-order (or level-order).
+ *
+ *
+ * @param node1
+ * @param node2
+ * @return LCA of node1 and node2
+ */
+ public final static PhylogenyNode calculateLCAonTreeWithIdsInPreOrder( PhylogenyNode node1, PhylogenyNode node2 ) {
+ while ( node1 != node2 ) {
+ if ( node1.getId() > node2.getId() ) {
+ node1 = node1.getParent();
+ }
+ else {
+ node2 = node2.getParent();
+ }
+ }
+ return node1;
+ }
+
/**
* Returns all orthologs of the external PhylogenyNode n of this Phylogeny.
* Orthologs are returned as List of node references.
* of this Phylogeny, null if this Phylogeny is empty or if n is
* internal
*/
- public List<PhylogenyNode> getOrthologousNodes( final Phylogeny phy, final PhylogenyNode node ) {
+ public final static List<PhylogenyNode> getOrthologousNodes( final Phylogeny phy, final PhylogenyNode node ) {
final List<PhylogenyNode> nodes = new ArrayList<PhylogenyNode>();
+ PhylogenyMethods.preOrderReId( phy );
final PhylogenyNodeIterator it = phy.iteratorExternalForward();
while ( it.hasNext() ) {
final PhylogenyNode temp_node = it.next();
- if ( ( temp_node != node ) && isAreOrthologous( node, temp_node ) ) {
+ if ( ( temp_node != node ) && !calculateLCAonTreeWithIdsInPreOrder( node, temp_node ).isDuplication() ) {
nodes.add( temp_node );
}
}
return nodes;
}
- public static boolean isAreOrthologous( final PhylogenyNode node1, final PhylogenyNode node2 ) {
- return !calculateLCA( node1, node2 ).isDuplication();
- }
-
public final static Phylogeny[] readPhylogenies( final PhylogenyParser parser, final File file ) throws IOException {
final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
final Phylogeny[] trees = factory.create( file, parser );
previous_node = current_node;
current_node = current_node.getParent();
}
- if ( index < current_node.getNumberOfDescendants() - 1 ) {
+ if ( index < ( current_node.getNumberOfDescendants() - 1 ) ) {
current_node = current_node.getChildNode( index + 1 );
}
while ( current_node.isInternal() && !current_node.isCollapse() ) {
}
return steps;
}
-
+
public final double calculateDistanceToRoot() {
PhylogenyNode n = this;
double d = 0.0;
return d;
}
-
-
/**
* Checks whether this PhylogenyNode is a root.
*
return ( getDate() != null )
&& ( !ForesterUtil.isEmpty( getDate().getDesc() ) || !ForesterUtil.isNull( getDate().getMax() )
|| !ForesterUtil.isNull( getDate().getMin() ) || !ForesterUtil.isNull( getDate().getValue() ) || !ForesterUtil
- .isEmpty( getDate().getUnit() ) );
+ .isEmpty( getDate().getUnit() ) );
}
public boolean isHasDistribution() {
}
public int getLength() {
- return ( getTo() - getFrom() + 1 );
+ return ( ( getTo() - getFrom() ) + 1 );
}
public String getName() {
&& ForesterUtil.isEmpty( getCommonName() ) && ForesterUtil.isEmpty( getScientificName() )
&& ForesterUtil.isEmpty( getRank() ) && ForesterUtil.isEmpty( _uris )
&& ForesterUtil.isEmpty( getAuthority() ) && ForesterUtil.isEmpty( _synonyms ) && ForesterUtil
- .isEmpty( _lineage ) );
+ .isEmpty( _lineage ) );
}
/**
import org.forester.phylogeny.Phylogeny;
import org.forester.phylogeny.PhylogenyNode;
-// import java.util.Iterator; TODO should implement this, not some iterator of
-// this package.
-/*
- * @author Christian M. Zmasek
- *
- * @version 1.020 -- last modified: 10/10/05
- */
-public class PreorderTreeIterator implements PhylogenyNodeIterator {
+public final class PreorderTreeIterator implements PhylogenyNodeIterator {
final private Phylogeny _tree;
final private Stack<PhylogenyNode> _stack;
reset( node );
}
- private Stack<PhylogenyNode> getStack() {
- return _stack;
- }
-
- private Phylogeny getTree() {
- return _tree;
- }
-
/*
* (non-Javadoc)
*
* @see java.util.Iterator#hasNext()
*/
@Override
- public boolean hasNext() {
- return !getStack().isEmpty();
+ public final boolean hasNext() {
+ return !_stack.isEmpty();
}
/**
* Advances the Iterator by one.
*/
@Override
- public PhylogenyNode next() throws NoSuchElementException {
+ public final PhylogenyNode next() throws NoSuchElementException {
if ( !hasNext() ) {
throw new NoSuchElementException( "Attempt to call \"next()\" on iterator which has no more next elements." );
}
- final PhylogenyNode node = getStack().pop();
+ final PhylogenyNode node = _stack.pop();
if ( !node.isExternal() ) {
for( int i = node.getNumberOfDescendants() - 1; i >= 0; --i ) {
- getStack().push( node.getChildNode( i ) );
+ _stack.push( node.getChildNode( i ) );
}
}
return node;
- } // next()
+ }
/**
* Not supported.
*
*/
@Override
- public void remove() {
+ public final void remove() {
throw new UnsupportedOperationException();
}
@Override
- public void reset() {
- getStack().clear();
- getStack().push( getTree().getRoot() );
+ public final void reset() {
+ _stack.clear();
+ _stack.push( _tree.getRoot() );
}
- private void reset( final PhylogenyNode node ) {
- getStack().clear();
- getStack().push( node );
+ private final void reset( final PhylogenyNode node ) {
+ _stack.clear();
+ _stack.push( node );
}
-} // End of class PreorderTreeIterator.
+}
@Override
public int getLength() {
- return 1 + getTo() - getFrom();
+ return ( 1 + getTo() ) - getFrom();
}
}
import java.util.TreeSet;
import org.forester.phylogeny.Phylogeny;
+import org.forester.phylogeny.PhylogenyMethods;
import org.forester.phylogeny.PhylogenyNode;
import org.forester.phylogeny.data.Event;
import org.forester.phylogeny.data.Taxonomy;
_mapped_species_tree_nodes = new HashSet<PhylogenyNode>();
_scientific_names_mapped_to_reduced_specificity = new TreeSet<String>();
linkNodesOfG();
- getSpeciesTree().preOrderReId();
+ PhylogenyMethods.preOrderReId( getSpeciesTree() );
geneTreePostOrderTraversal();
}
final String all_j = ORcount.all_species[ j ].trim().toUpperCase();
final String[] a = { all_i };
final String[] b = { all_j };
- for( int k = 0; k < trees.length; ++k ) {
- countSharedAncestralClades( trees[ k ], bootstrap_threshold, a, b );
+ for( final Phylogeny tree : trees ) {
+ countSharedAncestralClades( tree, bootstrap_threshold, a, b );
}
}
}
if ( ( ORcount.group_1 != null ) && ( ORcount.group_2 != null ) && ( ORcount.group_1.length > 0 )
&& ( ORcount.group_2.length > 0 ) ) {
setGroup1Vs2Counter( 0 );
- for( int k = 0; k < trees.length; ++k ) {
- countSharedAncestralClades( trees[ k ], bootstrap_threshold, ORcount.group_1, ORcount.group_2 );
+ for( final Phylogeny tree : trees ) {
+ countSharedAncestralClades( tree, bootstrap_threshold, ORcount.group_1, ORcount.group_2 );
}
System.out.println( "\nCount [(" + ForesterUtil.stringArrayToString( ORcount.group_1 ) + ") vs ("
+ ForesterUtil.stringArrayToString( ORcount.group_2 ) + ")] = " + getGroup1Vs2Counter() );
public void countSuperOrthologousRelations( final int bootstrap_threshold ) {
reset();
- for( int i = 0; i < _trees.length; ++i ) {
- countSuperOrthologousRelations( _trees[ i ], bootstrap_threshold );
+ for( final Phylogeny _tree : _trees ) {
+ countSuperOrthologousRelations( _tree, bootstrap_threshold );
}
}
}
final Object[] species_array = _species.keySet().toArray();
final int s = species_array.length;
- for( int i = 0; i < s - 1; ++i ) {
+ for( int i = 0; i < ( s - 1 ); ++i ) {
final String species = ( String ) species_array[ i ];
System.out.println();
System.out.println( species + ":" );
reset();
}
- public IntMatrix calculateOrthologTable( Phylogeny[] gene_trees ) {
- List<String> labels = new ArrayList<String>();
- Set<String> labels_set = new HashSet<String>();
+ public IntMatrix calculateOrthologTable( final Phylogeny[] gene_trees ) {
+ final List<String> labels = new ArrayList<String>();
+ final Set<String> labels_set = new HashSet<String>();
String label;
- for( PhylogenyNode n : gene_trees[ 0 ].getExternalNodes() ) {
+ for( final PhylogenyNode n : gene_trees[ 0 ].getExternalNodes() ) {
if ( n.getNodeData().isHasSequence() && !ForesterUtil.isEmpty( n.getNodeData().getSequence().getName() ) ) {
label = n.getNodeData().getSequence().getName();
}
labels_set.add( label );
labels.add( label );
}
- IntMatrix m = new IntMatrix( labels );
+ final IntMatrix m = new IntMatrix( labels );
int counter = 0;
- for( Phylogeny gt : gene_trees ) {
+ for( final Phylogeny gt : gene_trees ) {
System.out.println( counter );
counter++;
+ PhylogenyMethods.preOrderReId( gt );
for( int x = 0; x < m.size(); ++x ) {
- PhylogenyNode nx = gt.getNode( m.getLabel( x ) );
+ final PhylogenyNode nx = gt.getNode( m.getLabel( x ) );
for( int y = 0; y < m.size(); ++y ) {
- PhylogenyNode ny = gt.getNode( m.getLabel( y ) );
- if ( PhylogenyMethods.isAreOrthologous( nx, ny ) ) {
+ final PhylogenyNode ny = gt.getNode( m.getLabel( y ) );
+ if ( !PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( nx, ny ).isDuplication() ) {
m.set( x, y, m.get( x, y ) + 1 );
//System.out.println( x + " " + y );
}
return 0.0;
}
final int i = h.get( name );
- return ( i * 100.0 / getBootstraps() );
+ return ( ( i * 100.0 ) / getBootstraps() );
}
/**
_sn_hash_maps.put( query, new HashMap<String, Integer>( _seq_names.size() ) );
// Go through all gene trees in the file.
final Phylogeny[] gene_trees = factory.create( gene_trees_file, p );
- Phylogeny[] assigned_trees = new Phylogeny[ gene_trees.length ];
+ final Phylogeny[] assigned_trees = new Phylogeny[ gene_trees.length ];
int c = 0;
for( final Phylogeny gt : gene_trees ) {
bs++;
assigned_trees[ c++ ] = inferOrthologsHelper( gt, species_tree, query );
// System.out.println( bs );
}
- IntMatrix m = calculateOrthologTable( assigned_trees );
+ final IntMatrix m = calculateOrthologTable( assigned_trees );
System.out.println( m.toString() );
setBootstraps( bs );
if ( RIO.TIME ) {
throw new IllegalArgumentException( "no node containing a sequence named [" + query + "] found" );
}
final PhylogenyNode query_node = nodes.get( 0 );
- final PhylogenyMethods methods = PhylogenyMethods.getInstance();
- orthologs = methods.getOrthologousNodes( assigned_tree, query_node );
+ orthologs = PhylogenyMethods.getOrthologousNodes( assigned_tree, query_node );
updateHash( _o_hash_maps, query, orthologs );
super_orthologs = PhylogenyMethods.getSuperOrthologousNodes( query_node );
updateHash( _so_hash_maps, query, super_orthologs );
nv_array[ j ] = nv.get( j );
}
Arrays.sort( nv_array );
- for( int i = 0; i < nv_array.length; ++i ) {
- name = nv_array[ i ].getKey();
- value1 = nv_array[ i ].getValue1();
- value2 = nv_array[ i ].getValue2();
- value3 = nv_array[ i ].getValue3();
- value4 = nv_array[ i ].getValue4();
+ for( final Tuplet element : nv_array ) {
+ name = element.getKey();
+ value1 = element.getValue1();
+ value2 = element.getValue2();
+ value3 = element.getValue3();
+ value4 = element.getValue4();
orthologs.append( addNameAndValues( name, value1, value2, value3, value4, sort ) );
}
}
else {
sort = 90;
}
- for( int i = 0; i < nv_array.length; ++i ) {
- name = nv_array[ i ].getKey();
- value1 = nv_array[ i ].getValue1();
- value2 = nv_array[ i ].getValue2();
+ for( final Tuplet element : nv_array ) {
+ name = element.getKey();
+ value1 = element.getValue1();
+ value2 = element.getValue2();
ultra_paralogs += addNameAndValues( name, value1, value2, 0.0, 0.0, sort );
}
}
computeMappingCostHelper( g.getChildNode1() );
computeMappingCostHelper( g.getChildNode2() );
if ( ( g.getLink() != g.getChildNode1().getLink() ) && ( g.getLink() != g.getChildNode2().getLink() ) ) {
- _mapping_cost += ( g.getChildNode1().getLink().getId() + g.getChildNode2().getLink().getId()
+ _mapping_cost += ( ( g.getChildNode1().getLink().getId() + g.getChildNode2().getLink().getId() )
- ( 2 * g.getLink().getId() ) - 2 );
}
else if ( ( g.getLink() != g.getChildNode1().getLink() ) && ( g.getLink() == g.getChildNode2().getLink() ) ) {
- _mapping_cost += ( g.getChildNode1().getLink().getId() - g.getLink().getId() + 1 );
+ _mapping_cost += ( ( g.getChildNode1().getLink().getId() - g.getLink().getId() ) + 1 );
}
else if ( ( g.getLink() == g.getChildNode1().getLink() ) && ( g.getLink() != g.getChildNode2().getLink() ) ) {
- _mapping_cost += ( g.getChildNode2().getLink().getId() - g.getLink().getId() + 1 );
+ _mapping_cost += ( ( g.getChildNode2().getLink().getId() - g.getLink().getId() ) + 1 );
}
else {
_mapping_cost++;
package org.forester.sdi;
import org.forester.phylogeny.Phylogeny;
+import org.forester.phylogeny.PhylogenyMethods;
import org.forester.phylogeny.PhylogenyNode;
import org.forester.phylogeny.data.Event;
public SDIse( final Phylogeny gene_tree, final Phylogeny species_tree ) throws SDIException {
super( gene_tree, species_tree );
_duplications_sum = 0;
- getSpeciesTree().preOrderReId();
+ PhylogenyMethods.preOrderReId( getSpeciesTree() );
linkNodesOfG();
geneTreePostOrderTraversal( getGeneTree().getRoot() );
}
if ( sdi1.getDuplicationsSum() != 1 ) {
return false;
}
- if ( !pm.calculateLCA( g1.getNode( "B" ), g1.getNode( "A1" ) ).getNodeData().getEvent().isSpeciation() ) {
+ if ( !PhylogenyMethods.calculateLCA( g1.getNode( "B" ), g1.getNode( "A1" ) ).getNodeData().getEvent()
+ .isSpeciation() ) {
return false;
}
- if ( !pm.calculateLCA( g1.getNode( "C" ), g1.getNode( "A1" ) ).getNodeData().getEvent()
+ if ( !PhylogenyMethods.calculateLCA( g1.getNode( "C" ), g1.getNode( "A1" ) ).getNodeData().getEvent()
.isSpeciationOrDuplication() ) {
return false;
}
- if ( !( pm.calculateLCA( g1.getNode( "A2" ), g1.getNode( "A1" ) ).getNodeData().getEvent().isDuplication() ) ) {
+ if ( !( PhylogenyMethods.calculateLCA( g1.getNode( "A2" ), g1.getNode( "A1" ) ).getNodeData().getEvent()
+ .isDuplication() ) ) {
return false;
}
- if ( !pm.calculateLCA( g1.getNode( "D" ), g1.getNode( "A1" ) ).getNodeData().getEvent().isSpeciation() ) {
+ if ( !PhylogenyMethods.calculateLCA( g1.getNode( "D" ), g1.getNode( "A1" ) ).getNodeData().getEvent()
+ .isSpeciation() ) {
return false;
}
final Phylogeny g2 = TestGSDI
if ( sdi2.getDuplicationsSum() != 0 ) {
return false;
}
- if ( !pm.calculateLCA( g2.getNode( "A1" ), g2.getNode( "A2" ) ).getNodeData().getEvent().isSpeciation() ) {
+ if ( !PhylogenyMethods.calculateLCA( g2.getNode( "A1" ), g2.getNode( "A2" ) ).getNodeData().getEvent()
+ .isSpeciation() ) {
return false;
}
- if ( !pm.calculateLCA( g2.getNode( "A1" ), g2.getNode( "B" ) ).getNodeData().getEvent().isSpeciation() ) {
+ if ( !PhylogenyMethods.calculateLCA( g2.getNode( "A1" ), g2.getNode( "B" ) ).getNodeData().getEvent()
+ .isSpeciation() ) {
return false;
}
- if ( !pm.calculateLCA( g2.getNode( "A1" ), g2.getNode( "C" ) ).getNodeData().getEvent()
+ if ( !PhylogenyMethods.calculateLCA( g2.getNode( "A1" ), g2.getNode( "C" ) ).getNodeData().getEvent()
.isSpeciationOrDuplication() ) {
return false;
}
- if ( !pm.calculateLCA( g2.getNode( "A1" ), g2.getNode( "D" ) ).getNodeData().getEvent().isSpeciation() ) {
+ if ( !PhylogenyMethods.calculateLCA( g2.getNode( "A1" ), g2.getNode( "D" ) ).getNodeData().getEvent()
+ .isSpeciation() ) {
return false;
}
final Phylogeny g3 = TestGSDI
if ( sdi3.getDuplicationsSum() != 0 ) {
return false;
}
- if ( !pm.calculateLCA( g3.getNode( "A1" ), g3.getNode( "A2" ) ).getNodeData().getEvent().isSpeciation() ) {
+ if ( !PhylogenyMethods.calculateLCA( g3.getNode( "A1" ), g3.getNode( "A2" ) ).getNodeData().getEvent()
+ .isSpeciation() ) {
return false;
}
- if ( !pm.calculateLCA( g3.getNode( "A1" ), g3.getNode( "C" ) ).getNodeData().getEvent().isSpeciation() ) {
+ if ( !PhylogenyMethods.calculateLCA( g3.getNode( "A1" ), g3.getNode( "C" ) ).getNodeData().getEvent()
+ .isSpeciation() ) {
return false;
}
- if ( !pm.calculateLCA( g3.getNode( "A1" ), g3.getNode( "B" ) ).getNodeData().getEvent()
+ if ( !PhylogenyMethods.calculateLCA( g3.getNode( "A1" ), g3.getNode( "B" ) ).getNodeData().getEvent()
.isSpeciationOrDuplication() ) {
return false;
}
- if ( !pm.calculateLCA( g3.getNode( "A1" ), g3.getNode( "D" ) ).getNodeData().getEvent().isSpeciation() ) {
+ if ( !PhylogenyMethods.calculateLCA( g3.getNode( "A1" ), g3.getNode( "D" ) ).getNodeData().getEvent()
+ .isSpeciation() ) {
return false;
}
final Phylogeny g4 = TestGSDI
if ( sdi4.getDuplicationsSum() != 1 ) {
return false;
}
- if ( !pm.calculateLCA( g4.getNode( "B" ), g4.getNode( "C1" ) ).getNodeData().getEvent().isSpeciation() ) {
+ if ( !PhylogenyMethods.calculateLCA( g4.getNode( "B" ), g4.getNode( "C1" ) ).getNodeData().getEvent()
+ .isSpeciation() ) {
return false;
}
- if ( !pm.calculateLCA( g4.getNode( "B" ), g4.getNode( "C2" ) ).getNodeData().getEvent().isDuplication() ) {
+ if ( !PhylogenyMethods.calculateLCA( g4.getNode( "B" ), g4.getNode( "C2" ) ).getNodeData().getEvent()
+ .isDuplication() ) {
return false;
}
- if ( !pm.calculateLCA( g4.getNode( "B" ), g4.getNode( "D" ) ).getNodeData().getEvent().isSpeciation() ) {
+ if ( !PhylogenyMethods.calculateLCA( g4.getNode( "B" ), g4.getNode( "D" ) ).getNodeData().getEvent()
+ .isSpeciation() ) {
return false;
}
final Phylogeny g5 = TestGSDI
if ( sdi5.getDuplicationsSum() != 3 ) {
return false;
}
- if ( !pm.calculateLCA( g5.getNode( "D1" ), g5.getNode( "A1" ) ).getNodeData().getEvent().isSpeciation() ) {
+ if ( !PhylogenyMethods.calculateLCA( g5.getNode( "D1" ), g5.getNode( "A1" ) ).getNodeData().getEvent()
+ .isSpeciation() ) {
return false;
}
- if ( !pm.calculateLCA( g5.getNode( "D1" ), g5.getNode( "B" ) ).getNodeData().getEvent().isDuplication() ) {
+ if ( !PhylogenyMethods.calculateLCA( g5.getNode( "D1" ), g5.getNode( "B" ) ).getNodeData().getEvent()
+ .isDuplication() ) {
return false;
}
- if ( !pm.calculateLCA( g5.getNode( "D1" ), g5.getNode( "D2" ) ).getNodeData().getEvent().isDuplication() ) {
+ if ( !PhylogenyMethods.calculateLCA( g5.getNode( "D1" ), g5.getNode( "D2" ) ).getNodeData().getEvent()
+ .isDuplication() ) {
return false;
}
- if ( !pm.calculateLCA( g5.getNode( "D2" ), g5.getNode( "D3" ) ).getNodeData().getEvent().isDuplication() ) {
+ if ( !PhylogenyMethods.calculateLCA( g5.getNode( "D2" ), g5.getNode( "D3" ) ).getNodeData().getEvent()
+ .isDuplication() ) {
return false;
}
- if ( !pm.calculateLCA( g5.getNode( "C" ), g5.getNode( "D3" ) ).getNodeData().getEvent().isSpeciation() ) {
+ if ( !PhylogenyMethods.calculateLCA( g5.getNode( "C" ), g5.getNode( "D3" ) ).getNodeData().getEvent()
+ .isSpeciation() ) {
return false;
}
final Phylogeny species7 = TestGSDI.createPhylogeny( "(((((((([&&NHX:S=a1],[&&NHX:S=a2]),"
if ( sdi2_0.getSpeciationsSum() != 1 ) {
return false;
}
- if ( !pm.calculateLCA( g2_0.getNode( "m1" ), g2_0.getNode( "m3" ) ).getNodeData().getEvent().isSpeciation() ) {
+ if ( !PhylogenyMethods.calculateLCA( g2_0.getNode( "m1" ), g2_0.getNode( "m3" ) ).getNodeData().getEvent()
+ .isSpeciation() ) {
return false;
}
final Phylogeny g2_1 = TestGSDI.createPhylogeny( "(e2[&&NHX:S=e2],h2[&&NHX:S=h2])" );
if ( sdi2_1.getSpeciationsSum() != 1 ) {
return false;
}
- if ( !pm.calculateLCA( g2_1.getNode( "e2" ), g2_1.getNode( "h2" ) ).getNodeData().getEvent().isSpeciation() ) {
+ if ( !PhylogenyMethods.calculateLCA( g2_1.getNode( "e2" ), g2_1.getNode( "h2" ) ).getNodeData().getEvent()
+ .isSpeciation() ) {
return false;
}
final Phylogeny g2_2 = TestGSDI.createPhylogeny( "(e2[&&NHX:S=e2],p4[&&NHX:S=p4])" );
if ( sdi2_2.getSpeciationsSum() != 1 ) {
return false;
}
- if ( !pm.calculateLCA( g2_2.getNode( "e2" ), g2_2.getNode( "p4" ) ).getNodeData().getEvent().isSpeciation() ) {
+ if ( !PhylogenyMethods.calculateLCA( g2_2.getNode( "e2" ), g2_2.getNode( "p4" ) ).getNodeData().getEvent()
+ .isSpeciation() ) {
return false;
}
final Phylogeny g2_3 = TestGSDI.createPhylogeny( "(e2a[&&NHX:S=e2],e2b[&&NHX:S=e2])" );
if ( sdi2_3.getSpeciationsSum() != 0 ) {
return false;
}
- if ( !pm.calculateLCA( g2_3.getNode( "e2a" ), g2_3.getNode( "e2b" ) ).getNodeData().getEvent().isDuplication() ) {
+ if ( !PhylogenyMethods.calculateLCA( g2_3.getNode( "e2a" ), g2_3.getNode( "e2b" ) ).getNodeData()
+ .getEvent().isDuplication() ) {
return false;
}
final Phylogeny g2_4 = TestGSDI.createPhylogeny( "((j1[&&NHX:S=j1],j4[&&NHX:S=j4]),i3[&&NHX:S=i3])" );
if ( sdi2_4.getSpeciationsSum() != 2 ) {
return false;
}
- if ( !pm.calculateLCA( g2_4.getNode( "j1" ), g2_4.getNode( "j4" ) ).getNodeData().getEvent().isSpeciation() ) {
+ if ( !PhylogenyMethods.calculateLCA( g2_4.getNode( "j1" ), g2_4.getNode( "j4" ) ).getNodeData().getEvent()
+ .isSpeciation() ) {
return false;
}
- if ( !pm.calculateLCA( g2_4.getNode( "j1" ), g2_4.getNode( "i3" ) ).getNodeData().getEvent().isSpeciation() ) {
+ if ( !PhylogenyMethods.calculateLCA( g2_4.getNode( "j1" ), g2_4.getNode( "i3" ) ).getNodeData().getEvent()
+ .isSpeciation() ) {
return false;
}
final Phylogeny g2_5 = TestGSDI.createPhylogeny( "((j1[&&NHX:S=j1],j4[&&NHX:S=j4]),f3[&&NHX:S=f3])" );
if ( sdi2_5.getSpeciationsSum() != 2 ) {
return false;
}
- if ( !pm.calculateLCA( g2_5.getNode( "j1" ), g2_5.getNode( "j4" ) ).getNodeData().getEvent().isSpeciation() ) {
+ if ( !PhylogenyMethods.calculateLCA( g2_5.getNode( "j1" ), g2_5.getNode( "j4" ) ).getNodeData().getEvent()
+ .isSpeciation() ) {
return false;
}
- if ( !pm.calculateLCA( g2_5.getNode( "j1" ), g2_5.getNode( "f3" ) ).getNodeData().getEvent().isSpeciation() ) {
+ if ( !PhylogenyMethods.calculateLCA( g2_5.getNode( "j1" ), g2_5.getNode( "f3" ) ).getNodeData().getEvent()
+ .isSpeciation() ) {
return false;
}
final Phylogeny g2_6 = TestGSDI.createPhylogeny( "((j3[&&NHX:S=j3],i4[&&NHX:S=i4]),f3[&&NHX:S=f3])" );
if ( sdi2_6.getSpeciationsSum() != 2 ) {
return false;
}
- if ( !pm.calculateLCA( g2_6.getNode( "j3" ), g2_6.getNode( "i4" ) ).getNodeData().getEvent().isSpeciation() ) {
+ if ( !PhylogenyMethods.calculateLCA( g2_6.getNode( "j3" ), g2_6.getNode( "i4" ) ).getNodeData().getEvent()
+ .isSpeciation() ) {
return false;
}
- if ( !pm.calculateLCA( g2_6.getNode( "j3" ), g2_6.getNode( "f3" ) ).getNodeData().getEvent().isSpeciation() ) {
+ if ( !PhylogenyMethods.calculateLCA( g2_6.getNode( "j3" ), g2_6.getNode( "f3" ) ).getNodeData().getEvent()
+ .isSpeciation() ) {
return false;
}
final Phylogeny g2_7 = TestGSDI.createPhylogeny( "((j1[&&NHX:S=j1],k1[&&NHX:S=k1]),i1[&&NHX:S=i1])" );
if ( sdi2_7.getSpeciationsSum() != 1 ) {
return false;
}
- if ( !pm.calculateLCA( g2_7.getNode( "j1" ), g2_7.getNode( "k1" ) ).getNodeData().getEvent().isSpeciation() ) {
+ if ( !PhylogenyMethods.calculateLCA( g2_7.getNode( "j1" ), g2_7.getNode( "k1" ) ).getNodeData().getEvent()
+ .isSpeciation() ) {
return false;
}
- if ( !pm.calculateLCA( g2_7.getNode( "j1" ), g2_7.getNode( "i1" ) ).getNodeData().getEvent()
+ if ( !PhylogenyMethods.calculateLCA( g2_7.getNode( "j1" ), g2_7.getNode( "i1" ) ).getNodeData().getEvent()
.isSpeciationOrDuplication() ) {
return false;
}
if ( sdi2_8.getSpeciationsSum() != 1 ) {
return false;
}
- if ( !pm.calculateLCA( g2_8.getNode( "j1" ), g2_8.getNode( "k1" ) ).getNodeData().getEvent()
+ if ( !PhylogenyMethods.calculateLCA( g2_8.getNode( "j1" ), g2_8.getNode( "k1" ) ).getNodeData().getEvent()
.isSpeciationOrDuplication() ) {
return false;
}
- if ( !pm.calculateLCA( g2_8.getNode( "k1" ), g2_8.getNode( "i1" ) ).getNodeData().getEvent().isSpeciation() ) {
+ if ( !PhylogenyMethods.calculateLCA( g2_8.getNode( "k1" ), g2_8.getNode( "i1" ) ).getNodeData().getEvent()
+ .isSpeciation() ) {
return false;
}
final Phylogeny g2_9 = TestGSDI.createPhylogeny( "((j1[&&NHX:S=j1],k4[&&NHX:S=k4]),f2[&&NHX:S=f2])" );
@Override
public int getNumberOfGapResidues() {
int gaps = 0;
- for( int i = 0; i < _mol_sequence.length; ++i ) {
- if ( _mol_sequence[ i ] == GAP ) {
+ for( final char element : _mol_sequence ) {
+ if ( element == GAP ) {
++gaps;
}
}
if ( abs_copy_number_difference > counts_sum ) {
throw new IllegalArgumentException( "attempt to use absolute copy number difference larger than copy number sum" );
}
- _score = 1.0 - ( double ) abs_copy_number_difference / counts_sum;
+ _score = 1.0 - ( ( double ) abs_copy_number_difference / counts_sum );
}
/**
for( final BinaryDomainCombination bdc : all_bdcs ) {
if ( ( high_copy_base_values.get( bdc ) > 0 ) && ( high_copy_target_values.get( bdc ) > 0 )
&& ( high_copy_base_values.get( bdc ) >= low_copy_values.get( bdc ) ) ) {
- if ( high_copy_target_values.get( bdc ) >= min_diff + ( factor * low_copy_values.get( bdc ) ) ) {
+ if ( high_copy_target_values.get( bdc ) >= ( min_diff + ( factor * low_copy_values.get( bdc ) ) ) ) {
if ( low_copy_values.get( bdc ) <= 0.0 ) {
++total_absense_counter;
}
for( final DomainId domain_id : all_domains ) {
if ( ( high_copy_base_values.get( domain_id ) > 0 ) && ( high_copy_target_values.get( domain_id ) > 0 )
&& ( high_copy_base_values.get( domain_id ) >= low_copy_values.get( domain_id ) ) ) {
- if ( high_copy_target_values.get( domain_id ) >= min_diff
- + ( factor * low_copy_values.get( domain_id ) ) ) {
+ if ( high_copy_target_values.get( domain_id ) >= ( min_diff + ( factor * low_copy_values
+ .get( domain_id ) ) ) ) {
if ( low_copy_values.get( domain_id ) <= 0.0 ) {
++total_absense_counter;
}
sb.append( ":" );
sb.append( getCombinableDomainIdToCountsMap().get( domain_id ) );
}
- if ( i < ids.size() - 1 ) {
+ if ( i < ( ids.size() - 1 ) ) {
sb.append( "," );
}
}
nodes.add( n );
}
}
- for( int i = 0; i < nodes.size() - 1; ++i ) {
+ for( int i = 0; i < ( nodes.size() - 1 ); ++i ) {
for( int j = i + 1; j < nodes.size(); ++j ) {
final PhylogenyNode lca = PhylogenyMethods.calculateLCA( nodes.get( i ), nodes.get( j ) );
String rank = "unknown";
+ all_pfams_encountered.size() );
ForesterUtil.programMessage( surfacing.PRG_NAME, "Pfams without a mapping : "
+ pfams_without_mappings_counter + " ["
- + ( 100 * pfams_without_mappings_counter / all_pfams_encountered.size() ) + "%]" );
+ + ( ( 100 * pfams_without_mappings_counter ) / all_pfams_encountered.size() ) + "%]" );
ForesterUtil.programMessage( surfacing.PRG_NAME, "Pfams without mapping to proc. or func. : "
+ pfams_without_mappings_to_bp_or_mf_counter + " ["
- + ( 100 * pfams_without_mappings_to_bp_or_mf_counter / all_pfams_encountered.size() ) + "%]" );
- ForesterUtil.programMessage( surfacing.PRG_NAME,
- "Pfams with a mapping : " + pfams_with_mappings_counter
- + " ["
- + ( 100 * pfams_with_mappings_counter / all_pfams_encountered.size() )
- + "%]" );
+ + ( ( 100 * pfams_without_mappings_to_bp_or_mf_counter ) / all_pfams_encountered.size() ) + "%]" );
+ ForesterUtil.programMessage( surfacing.PRG_NAME, "Pfams with a mapping : "
+ + pfams_with_mappings_counter + " ["
+ + ( ( 100 * pfams_with_mappings_counter ) / all_pfams_encountered.size() ) + "%]" );
ForesterUtil.programMessage( surfacing.PRG_NAME, "Pfams with a mapping to proc. or func. : "
+ pfams_with_mappings_to_bp_or_mf_counter + " ["
- + ( 100 * pfams_with_mappings_to_bp_or_mf_counter / all_pfams_encountered.size() ) + "%]" );
- ForesterUtil.programMessage( surfacing.PRG_NAME,
- "Pfams with mapping to biological process: " + biological_process_counter
- + " ["
- + ( 100 * biological_process_counter / all_pfams_encountered.size() )
- + "%]" );
- ForesterUtil.programMessage( surfacing.PRG_NAME,
- "Pfams with mapping to molecular function: " + molecular_function_counter
- + " ["
- + ( 100 * molecular_function_counter / all_pfams_encountered.size() )
- + "%]" );
- ForesterUtil.programMessage( surfacing.PRG_NAME,
- "Pfams with mapping to cellular component: " + cellular_component_counter
- + " ["
- + ( 100 * cellular_component_counter / all_pfams_encountered.size() )
- + "%]" );
+ + ( ( 100 * pfams_with_mappings_to_bp_or_mf_counter ) / all_pfams_encountered.size() ) + "%]" );
+ ForesterUtil.programMessage( surfacing.PRG_NAME, "Pfams with mapping to biological process: "
+ + biological_process_counter + " ["
+ + ( ( 100 * biological_process_counter ) / all_pfams_encountered.size() ) + "%]" );
+ ForesterUtil.programMessage( surfacing.PRG_NAME, "Pfams with mapping to molecular function: "
+ + molecular_function_counter + " ["
+ + ( ( 100 * molecular_function_counter ) / all_pfams_encountered.size() ) + "%]" );
+ ForesterUtil.programMessage( surfacing.PRG_NAME, "Pfams with mapping to cellular component: "
+ + cellular_component_counter + " ["
+ + ( ( 100 * cellular_component_counter ) / all_pfams_encountered.size() ) + "%]" );
summary_writer.write( ForesterUtil.LINE_SEPARATOR );
summary_writer.write( "# Sum of Pfams encountered : " + all_pfams_encountered.size() );
summary_writer.write( ForesterUtil.LINE_SEPARATOR );
summary_writer.write( "# Pfams without a mapping : " + pfams_without_mappings_counter
- + " [" + ( 100 * pfams_without_mappings_counter / all_pfams_encountered.size() ) + "%]" );
+ + " [" + ( ( 100 * pfams_without_mappings_counter ) / all_pfams_encountered.size() ) + "%]" );
summary_writer.write( ForesterUtil.LINE_SEPARATOR );
summary_writer.write( "# Pfams without mapping to proc. or func. : "
+ pfams_without_mappings_to_bp_or_mf_counter + " ["
- + ( 100 * pfams_without_mappings_to_bp_or_mf_counter / all_pfams_encountered.size() ) + "%]" );
+ + ( ( 100 * pfams_without_mappings_to_bp_or_mf_counter ) / all_pfams_encountered.size() ) + "%]" );
summary_writer.write( ForesterUtil.LINE_SEPARATOR );
summary_writer.write( "# Pfams with a mapping : " + pfams_with_mappings_counter + " ["
- + ( 100 * pfams_with_mappings_counter / all_pfams_encountered.size() ) + "%]" );
+ + ( ( 100 * pfams_with_mappings_counter ) / all_pfams_encountered.size() ) + "%]" );
summary_writer.write( ForesterUtil.LINE_SEPARATOR );
summary_writer.write( "# Pfams with a mapping to proc. or func. : "
+ pfams_with_mappings_to_bp_or_mf_counter + " ["
- + ( 100 * pfams_with_mappings_to_bp_or_mf_counter / all_pfams_encountered.size() ) + "%]" );
+ + ( ( 100 * pfams_with_mappings_to_bp_or_mf_counter ) / all_pfams_encountered.size() ) + "%]" );
summary_writer.write( ForesterUtil.LINE_SEPARATOR );
summary_writer.write( "# Pfams with mapping to biological process: " + biological_process_counter + " ["
- + ( 100 * biological_process_counter / all_pfams_encountered.size() ) + "%]" );
+ + ( ( 100 * biological_process_counter ) / all_pfams_encountered.size() ) + "%]" );
summary_writer.write( ForesterUtil.LINE_SEPARATOR );
summary_writer.write( "# Pfams with mapping to molecular function: " + molecular_function_counter + " ["
- + ( 100 * molecular_function_counter / all_pfams_encountered.size() ) + "%]" );
+ + ( ( 100 * molecular_function_counter ) / all_pfams_encountered.size() ) + "%]" );
summary_writer.write( ForesterUtil.LINE_SEPARATOR );
summary_writer.write( "# Pfams with mapping to cellular component: " + cellular_component_counter + " ["
- + ( 100 * cellular_component_counter / all_pfams_encountered.size() ) + "%]" );
+ + ( ( 100 * cellular_component_counter ) / all_pfams_encountered.size() ) + "%]" );
summary_writer.write( ForesterUtil.LINE_SEPARATOR );
summary_writer.close();
}
if ( !sa.getSpecies().contains( new BasicSpecies( "rabbit" ) ) ) {
return false;
}
- if ( !TestSurfacing.isEqual( sa.getMeanSimilarityScore(),
- ( 2.0 / 5 + 0 + 2.0 / 3 + 1.0 / 5 + 1.0 / 2 + 2.0 / 7 ) / 6 ) ) {
+ if ( !TestSurfacing.isEqual( sa.getMeanSimilarityScore(), ( ( 2.0 / 5 ) + 0 + ( 2.0 / 3 ) + ( 1.0 / 5 )
+ + ( 1.0 / 2 ) + ( 2.0 / 7 ) ) / 6 ) ) {
return false;
}
if ( !TestSurfacing.isEqual( sa.getStandardDeviationOfSimilarityScore(), ( 0.23410788192183737 ) ) ) {
if ( !sc.getSpecies().contains( new BasicSpecies( "nemve" ) ) ) {
return false;
}
- if ( !TestSurfacing.isEqual( sc.getMeanSimilarityScore(), ( 2.0 / 5 + 2.0 / 3 + 1.0 / 2 ) / 3 ) ) {
+ if ( !TestSurfacing.isEqual( sc.getMeanSimilarityScore(), ( ( 2.0 / 5 ) + ( 2.0 / 3 ) + ( 1.0 / 2 ) ) / 3 ) ) {
return false;
}
if ( !TestSurfacing.isEqual( sc.getStandardDeviationOfSimilarityScore(), 0.13471506281091264 ) ) {
if ( !sa2.getSpeciesData().keySet().contains( new BasicSpecies( "rabbit" ) ) ) {
return false;
}
- if ( !TestSurfacing.isEqual( sa2.getMeanSimilarityScore(),
- ( 2.0 / 5 + 0 + 2.0 / 3 + 1.0 / 6 + 1.0 / 2 + 2.0 / 8 ) / 6 ) ) {
+ if ( !TestSurfacing.isEqual( sa2.getMeanSimilarityScore(), ( ( 2.0 / 5 ) + 0 + ( 2.0 / 3 ) + ( 1.0 / 6 )
+ + ( 1.0 / 2 ) + ( 2.0 / 8 ) ) / 6 ) ) {
return false;
}
if ( !TestSurfacing.isEqual( sa2.getStandardDeviationOfSimilarityScore(), ( 0.2404663678647683 ) ) ) {
if ( sa4_d.getCombinableDomainIds( new BasicSpecies( "ciona" ) ).size() != 5 ) {
return false;
}
- if ( !TestSurfacing.isEqual( sa4_d.getMeanSimilarityScore(), ( 1 + 1 - 11.0 / 13 + 1 - 11.0 / 13 + 1 + 1
- + 1 - 11.0 / 13 ) / 6.0 ) ) {
+ if ( !TestSurfacing
+ .isEqual( sa4_d.getMeanSimilarityScore(),
+ ( ( ( ( ( ( 1 + 1 ) - ( 11.0 / 13 ) ) + 1 ) - ( 11.0 / 13 ) ) + 1 + 1 + 1 ) - ( 11.0 / 13 ) ) / 6.0 ) ) {
return false;
}
if ( !TestSurfacing.isEqual( sa4_d.getMaximalSimilarityScore(), 1.0 ) ) {
return false;
}
- if ( !TestSurfacing.isEqual( sa4_d.getMinimalSimilarityScore(), ( 1 - 11.0 / 13 ) ) ) {
+ if ( !TestSurfacing.isEqual( sa4_d.getMinimalSimilarityScore(), ( 1 - ( 11.0 / 13 ) ) ) ) {
return false;
}
if ( sa4_d.getN() != 6 ) {
if ( !sa4_p.getCombinableDomainIds( new BasicSpecies( "ciona" ) ).contains( new DomainId( "X" ) ) ) {
return false;
}
- if ( !TestSurfacing.isEqual( sa4_p.getMeanSimilarityScore(),
- ( 1 + 1 - 2.0 / 4 + 1 - 2.0 / 4 + 1 + 1 + 1 - 2.0 / 4 ) / 6.0 ) ) {
+ if ( !TestSurfacing
+ .isEqual( sa4_p.getMeanSimilarityScore(),
+ ( ( ( ( ( ( 1 + 1 ) - ( 2.0 / 4 ) ) + 1 ) - ( 2.0 / 4 ) ) + 1 + 1 + 1 ) - ( 2.0 / 4 ) ) / 6.0 ) ) {
return false;
}
if ( !TestSurfacing.isEqual( sa4_p.getMaximalSimilarityScore(), 1 ) ) {
return false;
}
- if ( !TestSurfacing.isEqual( sa4_p.getMinimalSimilarityScore(), ( 1 - 2.0 / 4 ) ) ) {
+ if ( !TestSurfacing.isEqual( sa4_p.getMinimalSimilarityScore(), ( 1 - ( 2.0 / 4 ) ) ) ) {
return false;
}
if ( sa4_p.getN() != 6 ) {
if ( !sa5_d.getCombinableDomainIds( ciona ).contains( new DomainId( "X" ) ) ) {
return false;
}
- if ( !TestSurfacing.isEqual( sa5_d.getMeanSimilarityScore(), ( 1 + 1 - 11.0 / 13 + 1 - 11.0 / 13 + 1 + 1
- + 1 - 11.0 / 13 ) / 6.0 ) ) {
+ if ( !TestSurfacing
+ .isEqual( sa5_d.getMeanSimilarityScore(),
+ ( ( ( ( ( ( 1 + 1 ) - ( 11.0 / 13 ) ) + 1 ) - ( 11.0 / 13 ) ) + 1 + 1 + 1 ) - ( 11.0 / 13 ) ) / 6.0 ) ) {
return false;
}
if ( !TestSurfacing.isEqual( sa5_d.getMaximalSimilarityScore(), 1.0 ) ) {
return false;
}
- if ( !TestSurfacing.isEqual( sa5_d.getMinimalSimilarityScore(), ( 1 - 11.0 / 13 ) ) ) {
+ if ( !TestSurfacing.isEqual( sa5_d.getMinimalSimilarityScore(), ( 1 - ( 11.0 / 13 ) ) ) ) {
return false;
}
if ( sa5_d.getN() != 6 ) {
if ( !sa5_p.getCombinableDomainIds( ciona ).contains( new DomainId( "X" ) ) ) {
return false;
}
- if ( !TestSurfacing.isEqual( sa5_p.getMeanSimilarityScore(),
- ( 1 + 1 - 2.0 / 4 + 1 - 2.0 / 4 + 1 + 1 + 1 - 2.0 / 4 ) / 6.0 ) ) {
+ if ( !TestSurfacing
+ .isEqual( sa5_p.getMeanSimilarityScore(),
+ ( ( ( ( ( ( 1 + 1 ) - ( 2.0 / 4 ) ) + 1 ) - ( 2.0 / 4 ) ) + 1 + 1 + 1 ) - ( 2.0 / 4 ) ) / 6.0 ) ) {
return false;
}
if ( !TestSurfacing.isEqual( sa5_p.getMaximalSimilarityScore(), 1 ) ) {
return false;
}
- if ( !TestSurfacing.isEqual( sa5_p.getMinimalSimilarityScore(), ( 1 - 2.0 / 4 ) ) ) {
+ if ( !TestSurfacing.isEqual( sa5_p.getMinimalSimilarityScore(), ( 1 - ( 2.0 / 4 ) ) ) ) {
return false;
}
if ( sa5_p.getN() != 6 ) {
if ( !sa6_d.getCombinableDomainIds( ciona6 ).contains( new DomainId( "X" ) ) ) {
return false;
}
- if ( !TestSurfacing.isEqual( sa6_d.getMeanSimilarityScore(), ( 1 + 1 - 11.0 / 13 + 1 - 11.0 / 13 + 1 + 1
- + 1 - 11.0 / 13 ) / 6.0 ) ) {
+ if ( !TestSurfacing
+ .isEqual( sa6_d.getMeanSimilarityScore(),
+ ( ( ( ( ( ( 1 + 1 ) - ( 11.0 / 13 ) ) + 1 ) - ( 11.0 / 13 ) ) + 1 + 1 + 1 ) - ( 11.0 / 13 ) ) / 6.0 ) ) {
return false;
}
if ( !TestSurfacing.isEqual( sa6_d.getMaximalSimilarityScore(), 1.0 ) ) {
return false;
}
- if ( !TestSurfacing.isEqual( sa6_d.getMinimalSimilarityScore(), ( 1 - 11.0 / 13 ) ) ) {
+ if ( !TestSurfacing.isEqual( sa6_d.getMinimalSimilarityScore(), ( 1 - ( 11.0 / 13 ) ) ) ) {
return false;
}
if ( sa6_d.getN() != 6 ) {
if ( !sa6_p.getCombinableDomainIds( ciona ).contains( new DomainId( "X" ) ) ) {
return false;
}
- if ( !TestSurfacing.isEqual( sa6_p.getMeanSimilarityScore(),
- ( 1 + 1 - 2.0 / 4 + 1 - 2.0 / 4 + 1 + 1 + 1 - 2.0 / 4 ) / 6.0 ) ) {
+ if ( !TestSurfacing
+ .isEqual( sa6_p.getMeanSimilarityScore(),
+ ( ( ( ( ( ( 1 + 1 ) - ( 2.0 / 4 ) ) + 1 ) - ( 2.0 / 4 ) ) + 1 + 1 + 1 ) - ( 2.0 / 4 ) ) / 6.0 ) ) {
return false;
}
if ( !TestSurfacing.isEqual( sa6_p.getMaximalSimilarityScore(), 1 ) ) {
return false;
}
- if ( !TestSurfacing.isEqual( sa6_p.getMinimalSimilarityScore(), ( 1 - 2.0 / 4 ) ) ) {
+ if ( !TestSurfacing.isEqual( sa6_p.getMinimalSimilarityScore(), ( 1 - ( 2.0 / 4 ) ) ) ) {
return false;
}
if ( sa6_p.getN() != 6 ) {
two.setKeyDomainCount( 3 );
final PairwiseDomainSimilarityCalculator calc = new DomainCountsBasedPairwiseSimilarityCalculator();
PairwiseDomainSimilarity s1 = calc.calculateSimilarity( one, two );
- if ( !TestSurfacing.isEqual( s1.getSimilarityScore(), 1.0 - ( 3 - 2.0 ) / ( 2 + 3 ) ) ) {
+ if ( !TestSurfacing.isEqual( s1.getSimilarityScore(), 1.0 - ( ( 3 - 2.0 ) / ( 2 + 3 ) ) ) ) {
return false;
}
if ( s1.getDifferenceInCounts() != ( 2 - 3 ) ) {
one.setKeyDomainCount( 1 );
two.setKeyDomainCount( 1000 );
s1 = calc.calculateSimilarity( one, two );
- if ( !TestSurfacing.isEqual( s1.getSimilarityScore(), 1.0 - 999.0 / 1001 ) ) {
+ if ( !TestSurfacing.isEqual( s1.getSimilarityScore(), 1.0 - ( 999.0 / 1001 ) ) ) {
return false;
}
if ( s1.getDifferenceInCounts() != ( 1 - 1000 ) ) {
return false;
}
if ( !isEqual( calc_ni.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
- 1.0 - ( 25.0 - 5.0 ) / 25.0 ) ) {
+ 1.0 - ( ( 25.0 - 5.0 ) / 25.0 ) ) ) {
return false;
}
if ( !isEqual( calc_i.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
- 1.0 - ( 22.0 - 3.0 ) / 22.0 ) ) {
+ 1.0 - ( ( 22.0 - 3.0 ) / 22.0 ) ) ) {
return false;
}
- if ( !isEqual( calc_ni.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( 14.0 - 4.0 ) / 14.0 ) ) {
+ if ( !isEqual( calc_ni.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( ( 14.0 - 4.0 ) / 14.0 ) ) ) {
return false;
}
- if ( !isEqual( calc_i.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( 14.0 - 4.0 ) / 14.0 ) ) {
+ if ( !isEqual( calc_i.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( ( 14.0 - 4.0 ) / 14.0 ) ) ) {
return false;
}
final Domain u = new BasicDomain( "u", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
return false;
}
if ( !isEqual( calc_u.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
- 1.0 - ( 1.0 - 1.0 ) / 1.0 ) ) {
+ 1.0 - ( ( 1.0 - 1.0 ) / 1.0 ) ) ) {
return false;
}
- if ( !isEqual( calc_u.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( 4.0 - 3.0 ) / 4.0 ) ) {
+ if ( !isEqual( calc_u.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( ( 4.0 - 3.0 ) / 4.0 ) ) ) {
return false;
}
calc_u.setAllowDomainsToBeIgnored( false );
if ( !isEqual( calc_u.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
- 1.0 - ( 5.0 - 2.0 ) / 5.0 ) ) {
+ 1.0 - ( ( 5.0 - 2.0 ) / 5.0 ) ) ) {
return false;
}
- if ( !isEqual( calc_u.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( 6.0 - 4.0 ) / 6.0 ) ) {
+ if ( !isEqual( calc_u.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( ( 6.0 - 4.0 ) / 6.0 ) ) ) {
return false;
}
calc_u.setAllowDomainsToBeIgnored( true );
if ( !isEqual( calc_u.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
- 1.0 - ( 1.0 - 1.0 ) / 1.0 ) ) {
+ 1.0 - ( ( 1.0 - 1.0 ) / 1.0 ) ) ) {
return false;
}
- if ( !isEqual( calc_u.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( 4.0 - 3.0 ) / 4.0 ) ) {
+ if ( !isEqual( calc_u.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( ( 4.0 - 3.0 ) / 4.0 ) ) ) {
return false;
}
calc_u.deleteAllDomainIdsToIgnore();
if ( !isEqual( calc_u.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
- 1.0 - ( 5.0 - 2.0 ) / 5.0 ) ) {
+ 1.0 - ( ( 5.0 - 2.0 ) / 5.0 ) ) ) {
return false;
}
- if ( !isEqual( calc_u.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( 6.0 - 4.0 ) / 6.0 ) ) {
+ if ( !isEqual( calc_u.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( ( 6.0 - 4.0 ) / 6.0 ) ) ) {
return false;
}
}
private final static Event getEvent( final Phylogeny p, final String n1, final String n2 ) {
final PhylogenyMethods pm = PhylogenyMethods.getInstance();
- return pm.calculateLCA( p.getNode( n1 ), p.getNode( n2 ) ).getNodeData().getEvent();
+ return PhylogenyMethods.calculateLCA( p.getNode( n1 ), p.getNode( n2 ) ).getNodeData().getEvent();
}
public static boolean isEqual( final double a, final double b ) {
System.out.println( "failed." );
failed++;
}
+ System.out.print( "Finding of LCA 2: " );
+ if ( Test.testGetLCA2() ) {
+ System.out.println( "OK." );
+ succeeded++;
+ }
+ else {
+ System.out.println( "failed." );
+ failed++;
+ }
System.out.print( "Calculation of distance between nodes: " );
if ( Test.testGetDistance() ) {
System.out.println( "OK." );
else {
path = "/home/czmasek/bin/mafft";
}
- if ( !Mafft.isInstalled( path ) ) {
+ if ( !MsaInferrer.isInstalled( path ) ) {
path = "mafft";
}
- if ( !Mafft.isInstalled( path ) ) {
+ if ( !MsaInferrer.isInstalled( path ) ) {
path = "/usr/local/bin/mafft";
}
- if ( Mafft.isInstalled( path ) ) {
+ if ( MsaInferrer.isInstalled( path ) ) {
System.out.print( "MAFFT (external program): " );
if ( Test.testMafft( path ) ) {
System.out.println( "OK." );
return true;
}
+ private static boolean testGetLCA2() {
+ try {
+ final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
+ final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
+ new NHXParser() )[ 0 ];
+ PhylogenyMethods.preOrderReId( p1 );
+ final PhylogenyNode A = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
+ p1.getNode( "A" ) );
+ if ( !A.getName().equals( "A" ) ) {
+ return false;
+ }
+ final PhylogenyNode gh = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "gh" ),
+ p1.getNode( "gh" ) );
+ if ( !gh.getName().equals( "gh" ) ) {
+ return false;
+ }
+ final PhylogenyNode ab = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
+ p1.getNode( "B" ) );
+ if ( !ab.getName().equals( "ab" ) ) {
+ return false;
+ }
+ final PhylogenyNode ab2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
+ p1.getNode( "A" ) );
+ if ( !ab2.getName().equals( "ab" ) ) {
+ return false;
+ }
+ final PhylogenyNode gh2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
+ p1.getNode( "G" ) );
+ if ( !gh2.getName().equals( "gh" ) ) {
+ return false;
+ }
+ final PhylogenyNode gh3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "G" ),
+ p1.getNode( "H" ) );
+ if ( !gh3.getName().equals( "gh" ) ) {
+ return false;
+ }
+ final PhylogenyNode abc = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "C" ),
+ p1.getNode( "A" ) );
+ if ( !abc.getName().equals( "abc" ) ) {
+ return false;
+ }
+ final PhylogenyNode abc2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
+ p1.getNode( "C" ) );
+ if ( !abc2.getName().equals( "abc" ) ) {
+ return false;
+ }
+ final PhylogenyNode abcd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
+ p1.getNode( "D" ) );
+ if ( !abcd.getName().equals( "abcd" ) ) {
+ return false;
+ }
+ final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "D" ),
+ p1.getNode( "A" ) );
+ if ( !abcd2.getName().equals( "abcd" ) ) {
+ return false;
+ }
+ final PhylogenyNode abcdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
+ p1.getNode( "F" ) );
+ if ( !abcdef.getName().equals( "abcdef" ) ) {
+ return false;
+ }
+ final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
+ p1.getNode( "A" ) );
+ if ( !abcdef2.getName().equals( "abcdef" ) ) {
+ return false;
+ }
+ final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
+ p1.getNode( "F" ) );
+ if ( !abcdef3.getName().equals( "abcdef" ) ) {
+ return false;
+ }
+ final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
+ p1.getNode( "ab" ) );
+ if ( !abcdef4.getName().equals( "abcdef" ) ) {
+ return false;
+ }
+ final PhylogenyNode abcde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
+ p1.getNode( "E" ) );
+ if ( !abcde.getName().equals( "abcde" ) ) {
+ return false;
+ }
+ final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
+ p1.getNode( "A" ) );
+ if ( !abcde2.getName().equals( "abcde" ) ) {
+ return false;
+ }
+ final PhylogenyNode r = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcdefgh" ),
+ p1.getNode( "abcdefgh" ) );
+ if ( !r.getName().equals( "abcdefgh" ) ) {
+ return false;
+ }
+ final PhylogenyNode r2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
+ p1.getNode( "H" ) );
+ if ( !r2.getName().equals( "abcdefgh" ) ) {
+ return false;
+ }
+ final PhylogenyNode r3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
+ p1.getNode( "A" ) );
+ if ( !r3.getName().equals( "abcdefgh" ) ) {
+ return false;
+ }
+ final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
+ p1.getNode( "abcde" ) );
+ if ( !abcde3.getName().equals( "abcde" ) ) {
+ return false;
+ }
+ final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcde" ),
+ p1.getNode( "E" ) );
+ if ( !abcde4.getName().equals( "abcde" ) ) {
+ return false;
+ }
+ final PhylogenyNode ab3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
+ p1.getNode( "B" ) );
+ if ( !ab3.getName().equals( "ab" ) ) {
+ return false;
+ }
+ final PhylogenyNode ab4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
+ p1.getNode( "ab" ) );
+ if ( !ab4.getName().equals( "ab" ) ) {
+ return false;
+ }
+ final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
+ PhylogenyMethods.preOrderReId( p2 );
+ final PhylogenyNode cd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
+ p2.getNode( "d" ) );
+ if ( !cd.getName().equals( "cd" ) ) {
+ return false;
+ }
+ final PhylogenyNode cd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
+ p2.getNode( "c" ) );
+ if ( !cd2.getName().equals( "cd" ) ) {
+ return false;
+ }
+ final PhylogenyNode cde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
+ p2.getNode( "e" ) );
+ if ( !cde.getName().equals( "cde" ) ) {
+ return false;
+ }
+ final PhylogenyNode cde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "e" ),
+ p2.getNode( "c" ) );
+ if ( !cde2.getName().equals( "cde" ) ) {
+ return false;
+ }
+ final PhylogenyNode cdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
+ p2.getNode( "f" ) );
+ if ( !cdef.getName().equals( "cdef" ) ) {
+ return false;
+ }
+ final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
+ p2.getNode( "f" ) );
+ if ( !cdef2.getName().equals( "cdef" ) ) {
+ return false;
+ }
+ final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "f" ),
+ p2.getNode( "d" ) );
+ if ( !cdef3.getName().equals( "cdef" ) ) {
+ return false;
+ }
+ final PhylogenyNode rt = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
+ p2.getNode( "a" ) );
+ if ( !rt.getName().equals( "r" ) ) {
+ return false;
+ }
+ final Phylogeny p3 = factory
+ .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
+ new NHXParser() )[ 0 ];
+ PhylogenyMethods.preOrderReId( p3 );
+ final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "b" ),
+ p3.getNode( "c" ) );
+ if ( !bc_3.getName().equals( "bc" ) ) {
+ return false;
+ }
+ final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
+ p3.getNode( "c" ) );
+ if ( !ac_3.getName().equals( "abc" ) ) {
+ return false;
+ }
+ final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
+ p3.getNode( "d" ) );
+ if ( !ad_3.getName().equals( "abcde" ) ) {
+ return false;
+ }
+ final PhylogenyNode af_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
+ p3.getNode( "f" ) );
+ if ( !af_3.getName().equals( "abcdef" ) ) {
+ return false;
+ }
+ final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
+ p3.getNode( "g" ) );
+ if ( !ag_3.getName().equals( "" ) ) {
+ return false;
+ }
+ if ( !ag_3.isRoot() ) {
+ return false;
+ }
+ final PhylogenyNode al_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
+ p3.getNode( "l" ) );
+ if ( !al_3.getName().equals( "" ) ) {
+ return false;
+ }
+ if ( !al_3.isRoot() ) {
+ return false;
+ }
+ final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "k" ),
+ p3.getNode( "l" ) );
+ if ( !kl_3.getName().equals( "" ) ) {
+ return false;
+ }
+ if ( !kl_3.isRoot() ) {
+ return false;
+ }
+ final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "f" ),
+ p3.getNode( "l" ) );
+ if ( !fl_3.getName().equals( "" ) ) {
+ return false;
+ }
+ if ( !fl_3.isRoot() ) {
+ return false;
+ }
+ final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "g" ),
+ p3.getNode( "k" ) );
+ if ( !gk_3.getName().equals( "ghijk" ) ) {
+ return false;
+ }
+ final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
+ PhylogenyMethods.preOrderReId( p4 );
+ final PhylogenyNode r_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p4.getNode( "b" ),
+ p4.getNode( "c" ) );
+ if ( !r_4.getName().equals( "r" ) ) {
+ return false;
+ }
+ final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
+ PhylogenyMethods.preOrderReId( p5 );
+ final PhylogenyNode r_5 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p5.getNode( "a" ),
+ p5.getNode( "c" ) );
+ if ( !r_5.getName().equals( "root" ) ) {
+ return false;
+ }
+ final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
+ PhylogenyMethods.preOrderReId( p6 );
+ final PhylogenyNode r_6 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p6.getNode( "c" ),
+ p6.getNode( "a" ) );
+ if ( !r_6.getName().equals( "rot" ) ) {
+ return false;
+ }
+ final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
+ PhylogenyMethods.preOrderReId( p7 );
+ final PhylogenyNode r_7 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "a" ),
+ p7.getNode( "e" ) );
+ if ( !r_7.getName().equals( "rott" ) ) {
+ return false;
+ }
+ final PhylogenyNode r_71 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
+ p7.getNode( "a" ) );
+ if ( !r_71.getName().equals( "rott" ) ) {
+ return false;
+ }
+ final PhylogenyNode r_72 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
+ p7.getNode( "rott" ) );
+ if ( !r_72.getName().equals( "rott" ) ) {
+ return false;
+ }
+ final PhylogenyNode r_73 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
+ p7.getNode( "a" ) );
+ if ( !r_73.getName().equals( "rott" ) ) {
+ return false;
+ }
+ final PhylogenyNode r_74 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
+ p7.getNode( "rott" ) );
+ if ( !r_74.getName().equals( "rott" ) ) {
+ return false;
+ }
+ final PhylogenyNode r_75 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
+ p7.getNode( "e" ) );
+ if ( !r_75.getName().equals( "e" ) ) {
+ return false;
+ }
+ }
+ catch ( final Exception e ) {
+ e.printStackTrace( System.out );
+ return false;
+ }
+ return true;
+ }
+
private static boolean testHmmscanOutputParser() {
final String test_dir = Test.PATH_TO_TEST_DATA;
try {
if ( p.getNode( "r" ).getId() != count ) {
return false;
}
- if ( p.getNode( "A" ).getId() != count + 1 ) {
+ if ( p.getNode( "A" ).getId() != ( count + 1 ) ) {
return false;
}
- if ( p.getNode( "B" ).getId() != count + 1 ) {
+ if ( p.getNode( "B" ).getId() != ( count + 1 ) ) {
return false;
}
- if ( p.getNode( "C" ).getId() != count + 1 ) {
+ if ( p.getNode( "C" ).getId() != ( count + 1 ) ) {
return false;
}
- if ( p.getNode( "1" ).getId() != count + 2 ) {
+ if ( p.getNode( "1" ).getId() != ( count + 2 ) ) {
return false;
}
- if ( p.getNode( "2" ).getId() != count + 2 ) {
+ if ( p.getNode( "2" ).getId() != ( count + 2 ) ) {
return false;
}
- if ( p.getNode( "3" ).getId() != count + 2 ) {
+ if ( p.getNode( "3" ).getId() != ( count + 2 ) ) {
return false;
}
- if ( p.getNode( "4" ).getId() != count + 2 ) {
+ if ( p.getNode( "4" ).getId() != ( count + 2 ) ) {
return false;
}
- if ( p.getNode( "5" ).getId() != count + 2 ) {
+ if ( p.getNode( "5" ).getId() != ( count + 2 ) ) {
return false;
}
- if ( p.getNode( "6" ).getId() != count + 2 ) {
+ if ( p.getNode( "6" ).getId() != ( count + 2 ) ) {
return false;
}
- if ( p.getNode( "a" ).getId() != count + 3 ) {
+ if ( p.getNode( "a" ).getId() != ( count + 3 ) ) {
return false;
}
- if ( p.getNode( "b" ).getId() != count + 3 ) {
+ if ( p.getNode( "b" ).getId() != ( count + 3 ) ) {
return false;
}
- if ( p.getNode( "X" ).getId() != count + 4 ) {
+ if ( p.getNode( "X" ).getId() != ( count + 4 ) ) {
return false;
}
- if ( p.getNode( "Y" ).getId() != count + 4 ) {
+ if ( p.getNode( "Y" ).getId() != ( count + 4 ) ) {
return false;
}
- if ( p.getNode( "Z" ).getId() != count + 4 ) {
+ if ( p.getNode( "Z" ).getId() != ( count + 4 ) ) {
return false;
}
}
final boolean picky,
final int numbers_of_chars_allowed_to_remove_if_not_found_in_map )
throws IllegalArgumentException, NHXFormatException, PhyloXmlDataFormatException {
- for( int i = 0; i < phylogenies.length; ++i ) {
- PhylogenyDecorator.decorate( phylogenies[ i ],
- map,
- picky,
- numbers_of_chars_allowed_to_remove_if_not_found_in_map );
+ for( final Phylogeny phylogenie : phylogenies ) {
+ PhylogenyDecorator
+ .decorate( phylogenie, map, picky, numbers_of_chars_allowed_to_remove_if_not_found_in_map );
}
}
final int numbers_of_chars_allowed_to_remove_if_not_found_in_map,
final boolean trim_after_tilde ) throws IllegalArgumentException, NHXFormatException,
PhyloXmlDataFormatException {
- for( int i = 0; i < phylogenies.length; ++i ) {
- PhylogenyDecorator.decorate( phylogenies[ i ],
+ for( final Phylogeny phylogenie : phylogenies ) {
+ PhylogenyDecorator.decorate( phylogenie,
map,
field,
extract_bracketed_scientific_name,
final int numbers_of_chars_allowed_to_remove_if_not_found_in_map,
final boolean trim_after_tilde ) throws IllegalArgumentException, NHXFormatException,
PhyloXmlDataFormatException {
- for( int i = 0; i < phylogenies.length; ++i ) {
- PhylogenyDecorator.decorate( phylogenies[ i ],
+ for( final Phylogeny phylogenie : phylogenies ) {
+ PhylogenyDecorator.decorate( phylogenie,
map,
field,
extract_bracketed_scientific_name,
if ( q_counts != counts ) {
positive_matches = false;
}
- if ( q_counts != keySet().size() - counts ) {
+ if ( q_counts != ( keySet().size() - counts ) ) {
negative_matches = false;
}
if ( !positive_matches && !negative_matches ) {
}
for( int i = 0; i < bins.length; ++i ) {
final int count = bins[ i ];
- final double label = ForesterUtil.round( ( min + i * ( 1.0 / binning_factor ) ), digits );
+ final double label = ForesterUtil.round( ( min + ( i * ( 1.0 / binning_factor ) ) ), digits );
if ( !ForesterUtil.isEmpty( indent ) ) {
sb.append( indent );
}
}
public E getValue( final int col, final int row ) throws IllegalArgumentException {
- if ( ( row > getNumberOfRows() - 1 ) || ( row < 0 ) ) {
+ if ( ( row > ( getNumberOfRows() - 1 ) ) || ( row < 0 ) ) {
throw new IllegalArgumentException( "value for row (" + row + ") is out of range [number of rows: "
+ getNumberOfRows() + "]" );
}
if ( ( row < 0 ) || ( col < 0 ) ) {
throw new IllegalArgumentException( "attempt to use negative values for row or column" );
}
- if ( row > getNumberOfRows() - 1 ) {
+ if ( row > ( getNumberOfRows() - 1 ) ) {
setMaxRow( row );
}
- if ( col > getNumberOfColumns() - 1 ) {
+ if ( col > ( getNumberOfColumns() - 1 ) ) {
setMaxCol( col );
}
final String row_key = "" + row;
for( int row = 0; row < getNumberOfRows(); ++row ) {
for( int col = 0; col < getNumberOfColumns(); ++col ) {
sb.append( getValue( col, row ) );
- if ( col < getNumberOfColumns() - 1 ) {
+ if ( col < ( getNumberOfColumns() - 1 ) ) {
sb.append( " " );
}
}
- if ( row < getNumberOfRows() - 1 ) {
+ if ( row < ( getNumberOfRows() - 1 ) ) {
sb.append( ForesterUtil.LINE_SEPARATOR );
}
}
if ( use_last_separator_only ) {
final String e[] = line.split( column_delimiter );
final StringBuffer rest = new StringBuffer();
- for( int i = 0; i < e.length - 1; ++i ) {
+ for( int i = 0; i < ( e.length - 1 ); ++i ) {
rest.append( e[ i ].trim() );
}
table.setValue( 0, row, rest.toString() );
for( int i = 0; i < args.length; ++i ) {
final String arg = args[ i ].trim();
_command_line_str += arg;
- if ( i < args.length - 1 ) {
+ if ( i < ( args.length - 1 ) ) {
_command_line_str += " ";
}
if ( arg.startsWith( CommandLineArguments.EXTENDED_OPTIONS_PREFIX ) ) {
}
final public static boolean isEven( final int n ) {
- return n % 2 == 0;
+ return ( n % 2 ) == 0;
}
/**
if ( ( a.length < 1 ) || ( b.length < 1 ) ) {
return false;
}
- for( int i = 0; i < a.length; ++i ) {
- final String ai = a[ i ];
- for( int j = 0; j < b.length; ++j ) {
- if ( ( ai != null ) && ( b[ j ] != null ) && ai.equals( b[ j ] ) ) {
+ for( final String ai : a ) {
+ for( final String element : b ) {
+ if ( ( ai != null ) && ( element != null ) && ai.equals( element ) ) {
return true;
}
}
*/
final public static String removeWhiteSpace( String s ) {
int i;
- for( i = 0; i <= s.length() - 1; i++ ) {
+ for( i = 0; i <= ( s.length() - 1 ); i++ ) {
if ( ( s.charAt( i ) == ' ' ) || ( s.charAt( i ) == '\t' ) || ( s.charAt( i ) == '\n' )
|| ( s.charAt( i ) == '\r' ) ) {
s = s.substring( 0, i ) + s.substring( i + 1 );
final public static String stringArrayToString( final String[] a, final String separator ) {
final StringBuilder sb = new StringBuilder();
if ( ( a != null ) && ( a.length > 0 ) ) {
- for( int i = 0; i < a.length - 1; ++i ) {
+ for( int i = 0; i < ( a.length - 1 ); ++i ) {
sb.append( a[ i ] + separator );
}
sb.append( a[ a.length - 1 ] );
final public static String stringListToString( final List<String> l, final String separator ) {
final StringBuilder sb = new StringBuilder();
if ( ( l != null ) && ( l.size() > 0 ) ) {
- for( int i = 0; i < l.size() - 1; ++i ) {
+ for( int i = 0; i < ( l.size() - 1 ); ++i ) {
sb.append( l.get( i ) + separator );
}
sb.append( l.get( l.size() - 1 ) );
ls = -1;
start = i + 1;
}
- if ( i > start + width - 1 ) {
+ if ( i > ( ( start + width ) - 1 ) ) {
if ( ls != -1 ) {
sb.setCharAt( ls, '\n' );
start = ls + 1;