+ if ( sdir ) {
+ ForesterUtil.fatalError( "no outgroup option for SDIR algorithm" );
+ }
+ 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" ) ) {
+ 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 ( !cla.isOptionHasAValue( GT_FIRST ) ) {
+ ForesterUtil.fatalError( "no value for -" + GT_FIRST );
+ }
+ if ( sdir ) {
+ ForesterUtil.fatalError( "no gene tree range option for SDIR algorithm" );
+ }
+ 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 ( !cla.isOptionHasAValue( GT_LAST ) ) {
+ ForesterUtil.fatalError( "no value for -" + GT_LAST );
+ }
+ if ( sdir ) {
+ ForesterUtil.fatalError( "no gene tree range option for SDIR algorithm" );
+ }
+ 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 );
+ }
+ }
+ if ( ( ( gt_last != RIO.DEFAULT_RANGE ) && ( gt_first != RIO.DEFAULT_RANGE ) ) && ( ( gt_last < gt_first ) ) ) {
+ ForesterUtil.fatalError( "attempt to set range (0-based) of gene to analyze to: from " + gt_first + " to "
+ + gt_last );
+ }
+ File return_species_tree = null;
+ if ( !sdir && cla.isOptionSet( RETURN_SPECIES_TREE ) ) {
+ if ( !cla.isOptionHasAValue( RETURN_SPECIES_TREE ) ) {
+ ForesterUtil.fatalError( "no value for -" + RETURN_SPECIES_TREE );
+ }
+ final String s = cla.getOptionValueAsCleanString( RETURN_SPECIES_TREE );
+ return_species_tree = new File( s );
+ if ( return_species_tree.exists() ) {
+ ForesterUtil.fatalError( "\"" + return_species_tree + "\" already exists" );
+ }
+ }
+ File return_gene_tree = null;
+ if ( !sdir && cla.isOptionSet( RETURN_BEST_GENE_TREE ) ) {
+ if ( !cla.isOptionHasAValue( RETURN_BEST_GENE_TREE ) ) {
+ ForesterUtil.fatalError( "no value for -" + RETURN_BEST_GENE_TREE );
+ }
+ final String s = cla.getOptionValueAsCleanString( RETURN_BEST_GENE_TREE );
+ return_gene_tree = new File( s );
+ if ( return_gene_tree.exists() ) {
+ ForesterUtil.fatalError( "\"" + return_gene_tree + "\" already exists" );
+ }
+ }
+ boolean transfer_taxonomy = false;
+ if ( !sdir && cla.isOptionSet( TRANSFER_TAXONOMY_OPTION ) ) {
+ if ( return_gene_tree == null ) {
+ ForesterUtil.fatalError( "no point in transferring taxonomy data without returning best gene tree" );
+ }
+ transfer_taxonomy = true;
+ }
+ ForesterUtil.fatalErrorIfFileNotReadable( gene_trees_file );
+ ForesterUtil.fatalErrorIfFileNotReadable( species_tree_file );
+ if ( orthology_outtable.exists() ) {
+ ForesterUtil.fatalError( "\"" + orthology_outtable + "\" already exists" );