+ String outgroup = null;
+ if ( cla.isOptionSet( OUTGROUP ) ) {
+ if ( sdir ) {
+ ForesterUtil.fatalError( "no outgroup option for SDIR algorithm" );
+ }
+ if ( use_dir ) {
+ ForesterUtil.fatalError( "no outgroup option for operating on gene trees directory" );
+ }
+ if ( !cla.isOptionHasAValue( OUTGROUP ) ) {
+ ForesterUtil.fatalError( "no value for -" + OUTGROUP );
+ }
+ outgroup = cla.getOptionValueAsCleanString( OUTGROUP );
+ }
+ REROOTING rerooting = REROOTING.BY_ALGORITHM;
+ if ( cla.isOptionSet( REROOTING_OPT ) ) {
+ if ( !cla.isOptionHasAValue( REROOTING_OPT ) ) {
+ ForesterUtil.fatalError( "no value for -" + REROOTING_OPT );
+ }
+ if ( sdir ) {
+ ForesterUtil.fatalError( "no re-rooting option for SDIR algorithm" );
+ }
+ final String rerooting_str = cla.getOptionValueAsCleanString( REROOTING_OPT ).toLowerCase();
+ if ( rerooting_str.equals( "none" ) ) {
+ rerooting = REROOTING.NONE;
+ }
+ else if ( rerooting_str.equals( "midpoint" ) ) {
+ rerooting = REROOTING.MIDPOINT;
+ }
+ else if ( rerooting_str.equals( "outgroup" ) ) {
+ if ( use_dir ) {
+ ForesterUtil.fatalError( "no outgroup option for operating on gene trees directory" );
+ }
+ rerooting = REROOTING.OUTGROUP;
+ }
+ else {
+ ForesterUtil
+ .fatalError( "values for re-rooting are: 'none', 'midpoint', or 'outgroup' (minizming duplications is default)" );
+ }
+ }
+ if ( ForesterUtil.isEmpty( outgroup ) && ( rerooting == REROOTING.OUTGROUP ) ) {
+ ForesterUtil.fatalError( "selected re-rooting by outgroup, but outgroup not set" );
+ }
+ if ( !ForesterUtil.isEmpty( outgroup ) && ( rerooting != REROOTING.OUTGROUP ) ) {
+ ForesterUtil.fatalError( "outgroup set, but selected re-rooting by other approach" );
+ }
+ int gt_first = RIO.DEFAULT_RANGE;
+ int gt_last = RIO.DEFAULT_RANGE;
+ if ( cla.isOptionSet( GT_FIRST ) ) {
+ if ( sdir ) {
+ ForesterUtil.fatalError( "no gene tree range option for SDIR algorithm" );
+ }
+ if ( !cla.isOptionHasAValue( GT_FIRST ) ) {
+ ForesterUtil.fatalError( "no value for -" + GT_FIRST );
+ }
+ try {
+ gt_first = cla.getOptionValueAsInt( GT_FIRST );
+ }
+ catch ( final IOException e ) {
+ ForesterUtil.fatalError( "could not parse integer for -" + GT_FIRST + " option" );
+ }
+ if ( gt_first < 0 ) {
+ ForesterUtil.fatalError( "attempt to set index of first tree to analyze to: " + gt_first );
+ }
+ }
+ if ( cla.isOptionSet( GT_LAST ) ) {
+ if ( sdir ) {
+ ForesterUtil.fatalError( "no gene tree range option for SDIR algorithm" );
+ }
+ if ( !cla.isOptionHasAValue( GT_LAST ) ) {
+ ForesterUtil.fatalError( "no value for -" + GT_LAST );
+ }
+ try {
+ gt_last = cla.getOptionValueAsInt( GT_LAST );
+ }
+ catch ( final IOException e ) {
+ ForesterUtil.fatalError( "could not parse integer for -" + GT_LAST + " option" );
+ }
+ if ( gt_last < 0 ) {
+ ForesterUtil.fatalError( "attempt to set index of last tree to analyze to: " + gt_last );