+ double ortholog_group_cutoff = ORTHOLOG_GROUPS_CUTOFF_DEFAULT;
+ if ( cla.isOptionSet( ORTHOLOG_GROUPS_CUTOFF_OPTION ) ) {
+ if ( sdir ) {
+ ForesterUtil.fatalError( "ortholog groups cutoff for SDIR algorithm" );
+ }
+ if ( !cla.isOptionHasAValue( ORTHOLOG_GROUPS_CUTOFF_OPTION ) ) {
+ ForesterUtil.fatalError( "no value for -" + ORTHOLOG_GROUPS_CUTOFF_OPTION );
+ }
+ try {
+ ortholog_group_cutoff = cla.getOptionValueAsDouble( ORTHOLOG_GROUPS_CUTOFF_OPTION );
+ }
+ catch ( final IOException e ) {
+ ForesterUtil.fatalError( "could not parse double for -" + ORTHOLOG_GROUPS_CUTOFF_OPTION + " option" );
+ }
+ if ( ortholog_group_cutoff < 0 ) {
+ ForesterUtil.fatalError( "attempt to set ortholog groups cutoff to: " + ortholog_group_cutoff );
+ }
+ if ( ortholog_group_cutoff > 1 ) {
+ ForesterUtil.fatalError( "attempt to set ortholog groups cutoff to: " + ortholog_group_cutoff );
+ }
+ }
+ if ( !use_dir ) {
+ ForesterUtil.fatalErrorIfFileNotReadable( gene_trees_file );
+ }
+ final String gene_trees_suffix;
+ if ( cla.isOptionSet( GENE_TREES_SUFFIX_OPTION ) ) {
+ if ( !use_dir ) {
+ ForesterUtil.fatalError( "no gene tree suffix option when operating on indivual gene trees" );
+ }
+ if ( !cla.isOptionHasAValue( GENE_TREES_SUFFIX_OPTION ) ) {
+ ForesterUtil.fatalError( "no value for -" + GENE_TREES_SUFFIX_OPTION );
+ }
+ gene_trees_suffix = cla.getOptionValueAsCleanString( GENE_TREES_SUFFIX_OPTION );
+ }
+ else {
+ gene_trees_suffix = GENE_TREES_SUFFIX_DEFAULT;
+ }
+ final boolean perform_id_mapping;
+ final File id_mapping_dir;
+ if ( cla.isOptionSet( MAPPINGS_DIR_OPTION ) ) {
+ id_mapping_dir = new File( cla.getOptionValue( MAPPINGS_DIR_OPTION ) );
+ perform_id_mapping = true;
+ if ( !use_dir ) {
+ ForesterUtil.fatalError( "no id mapping when operating on indivual gene trees" );
+ }
+ if ( !id_mapping_dir.exists() ) {
+ ForesterUtil.fatalError( "id mappings directory \"" + id_mapping_dir + "\" does not exist" );
+ }
+ if ( !id_mapping_dir.isDirectory() ) {
+ ForesterUtil.fatalError( "id mappings directory \"" + id_mapping_dir + "\" is not a directory" );
+ }
+ if ( id_mapping_dir.listFiles().length < 1 ) {
+ ForesterUtil.fatalError( "id mappings directory \"" + id_mapping_dir + "\" is empty" );
+ }
+ }
+ else {
+ id_mapping_dir = null;
+ perform_id_mapping = false;
+ }
+ final String id_mapping_suffix;
+ if ( cla.isOptionSet( MAPPINGS_SUFFIX_OPTION ) ) {
+ if ( !use_dir ) {
+ ForesterUtil.fatalError( "no id mapping file suffix option when operating on indivual gene trees" );
+ }
+ if ( !perform_id_mapping ) {
+ ForesterUtil.fatalError( "no id mapping directory given" );
+ }
+ if ( !cla.isOptionHasAValue( MAPPINGS_SUFFIX_OPTION ) ) {
+ ForesterUtil.fatalError( "no value for -" + MAPPINGS_SUFFIX_OPTION );
+ }
+ id_mapping_suffix = cla.getOptionValueAsCleanString( MAPPINGS_SUFFIX_OPTION );
+ }
+ else {
+ id_mapping_suffix = MAPPINGS_SUFFIX_DEFAULT;
+ }
+ boolean perform_gsdir_on_best_tree;
+ final File best_trees_indir;
+ if ( cla.isOptionSet( CONSENSUS_TREES_DIR_OPTION ) ) {
+ best_trees_indir = new File( cla.getOptionValue( CONSENSUS_TREES_DIR_OPTION ) );
+ perform_gsdir_on_best_tree = true;
+ if ( !use_dir ) {
+ ForesterUtil
+ .fatalError( "no consensus (\"best\") gene tree GSDIR analysis when operating on individual gene trees" );
+ }
+ if ( !best_trees_indir.exists() ) {
+ ForesterUtil.fatalError( "consensus (\"best\") gene tree directory \"" + best_trees_indir
+ + "\" does not exist" );