options_description get_section_options(const string section_name, const string group_caption, const options_description &original_options_descriptions)
{

    const std::vector< shared_ptr<option_description> >&original_options = original_options_descriptions.options();

    options_description new_options(group_caption.c_str());

    std::vector< shared_ptr<option_description> >::const_iterator options_it;
    for(options_it = original_options.begin(); options_it != original_options.end(); ++options_it)
    {

        const option_description &t_option = *(*options_it);
        string new_name(section_name + ".");
        new_name += t_option.long_name();


        // IMPORTANT: in order for this line not to crash the original_options_descriptions needs to be a static declaration
        // otherwise t_option.semantic().get() will point to an invalid memory direction and
        // the application will raise a segmentation fault
        new_options.add_options()
                (new_name.c_str(), t_option.semantic().get(), t_option.description().c_str());

    }

    return new_options;
}
Beispiel #2
0
    basic_parsed_options<charT>
    parse_config_file(std::basic_istream<charT>& is, 
                      const options_description& desc,
                      bool allow_unregistered)
    {    
        set<string> allowed_options;

        const vector<shared_ptr<option_description> >& options = desc.options();
        for (unsigned i = 0; i < options.size(); ++i)
        {
            const option_description& d = *options[i];

            if (d.long_name().empty())
                pdalboost::throw_exception(
                    error("long name required for config file"));

            allowed_options.insert(d.long_name());
        }

        // Parser return char strings
        parsed_options result(&desc);        
        copy(detail::basic_config_file_iterator<charT>(
                 is, allowed_options, allow_unregistered), 
             detail::basic_config_file_iterator<charT>(), 
             back_inserter(result.options));
        // Convert char strings into desired type.
        return basic_parsed_options<charT>(result);
    }
/// \brief Add the block's non-hidden options to the provided options_description
///
/// This is a concrete definition of a virtual method that's pure in options_block
void old_ssap_options_block::do_add_visible_options_to_description(options_description &arg_desc ///< The options_description to which the options are added
                                                                   ) {
	const string dir_varname  { "<dir>"   };
	const string file_varname { "<file>"  };
	const string score_varname{ "<score>" };
	const string set_varname  { "<set>"   };

	const string protein_file_combns_str = join( get_all_protein_file_combn_strings(), ", " );
	arg_desc.add_options()
		( PO_DEBUG.c_str(),                bool_switch              ( &debug                        )                           ->default_value(DEF_BOOL      ),   "Output debugging information"                                                                                          )
		((PO_OUT_FILE+",o").c_str(),       value<path>              ( &output_filename              )->value_name(file_varname ),                                ( "[DEPRECATED] Output scores to " + file_varname + " rather than to stdout" ).c_str()                                    )

		( PO_CLIQUE_FILE.c_str(),          value<path>              ( &clique_file                  )->value_name(file_varname ),                                ( "Read clique from " + file_varname ).c_str()                                                                            )
		( PO_DOMIN_FILE.c_str(),           value<path>              ( &domin_file                   )->value_name(file_varname ),                                ( "Read domin from "  + file_varname ).c_str()                                                                            )

		( PO_MAX_SCORE_TO_REFAST.c_str(),  value<double>            ( &max_score_to_fast_ssap_rerun )->value_name(score_varname)->default_value(DEF_REFAST    ), ( "Run a second fast SSAP with looser cutoffs if the first fast SSAP's score falls below " + score_varname ).c_str()      )
		( PO_MAX_SCORE_TO_RESLOW.c_str(),  value<double>            ( &max_score_to_slow_ssap_rerun )->value_name(score_varname)->default_value(DEF_RESLOW    ), ( "Perform a slow SSAP if the (best) fast SSAP score falls below " + score_varname ).c_str()                              )
		( PO_SLOW_SSAP_ONLY.c_str(),       bool_switch              ( &slow_ssap_only               )                           ->default_value(DEF_BOOL      ),   "Don't try any fast SSAPs; only use slow SSAP"                                                                          )

		( PO_LOC_SSAP_SCORE.c_str(),       bool_switch              ( &use_local_ssap_score         )                           ->default_value(DEF_BOOL      ),   "[DEPRECATED] Normalise the SSAP score over the length of the smallest domain rather than the largest"                  )
		( PO_ALL_SCORES.c_str(),           bool_switch              ( &write_all_scores             )                           ->default_value(DEF_BOOL      ),   "[DEPRECATED] Output all SSAP scores from fast and slow runs, not just the highest"                                     )
		( PO_PROTEIN_SOURCE_FILES.c_str(), value<protein_file_combn>( &protein_source_files         )->value_name( set_varname )->default_value(DEF_PROT_SRCS ), ( "Read the protein data from the set of files "+set_varname+", of available sets:\n" + protein_file_combns_str ).c_str() )

		( PO_SUPN_DIR.c_str(),             value<path>              ( &superposition_dir            )->value_name( dir_varname ),                                ( "[DEPRECATED] Output a superposition to directory " + dir_varname ).c_str()                                             )
		( PO_ALIGN_DIR.c_str(),            value<path>              ( &alignment_dir                )->value_name( dir_varname )->default_value( path(".")    ), ( "Write alignment to directory " + dir_varname ).c_str()                                                                 )
		( PO_MIN_OUT_SCORE.c_str(),        value<double>            ( &min_score_for_writing_files  )->value_name(score_varname)->default_value(DEF_FILE_SC   ), ( "Only output alignment/superposition files if the SSAP score exceeds " + score_varname ).c_str()                        )
		( PO_MIN_SUP_SCORE.c_str(),        value<double>            ( &min_score_for_superposition  )->value_name(score_varname)->default_value(DEF_SUP       ), ( "[DEPRECATED] Calculate superposition based on the residue-pairs with scores greater than " + score_varname ).c_str()   )
		( PO_RASMOL_SCRIPT.c_str(),        bool_switch              ( &write_rasmol_script          )                           ->default_value(DEF_BOOL      ),   "[DEPRECATED] Write a rasmol superposition script to load and colour the superposed structures"                         )
		( PO_XML_SUP.c_str(),              bool_switch              ( &write_xml_sup                )                           ->default_value(DEF_BOOL      ),   "[DEPRECATED] Write a small xml superposition file, from which a larger superposition file can be reconstructed"        );
}
Beispiel #4
0
void http_client_plugin::set_program_options(options_description&, options_description& cfg) {
   cfg.add_options()
      ("https-client-root-cert", boost::program_options::value<vector<string>>()->composing()->multitoken(),
       "PEM encoded trusted root certificate (or path to file containing one) used to validate any TLS connections made.  (may specify multiple times)\n")
      ("https-client-validate-peers", boost::program_options::value<bool>()->default_value(true),
       "true: validate that the peer certificates are valid and trusted, false: ignore cert errors")
      ;

}
/// \brief Add this block's options to the provided options_description
void superposition_output_options_block::do_add_visible_options_to_description(options_description &arg_desc ///< The options_description to which the options are added
                                                                               ) {
	arg_desc.add_options()
		(PO_SUP_FILE.c_str(),          value<path>(&sup_to_pdb_file),                                     "Write the superposed structures to a single PDB file arg, separated using faked chain codes"  )
		(PO_SUP_FILES_DIR.c_str(),     value<path>(&sup_to_pdb_files_dir),                                "Write the superposed structures to separate PDB files in directory arg"                       )
		(PO_SUP_TO_STDOUT.c_str(),     bool_switch(&sup_to_stdout)->default_value(false),                 "Print the superposed structures to stdout, separated using faked chain codes"                 )
		(PO_SUP_TO_PYMOL.c_str(),      bool_switch(&sup_to_pymol )->default_value(false),                 "Start up PyMOL for viewing the superposition"                                                 )
		(PO_PYMOL_PROGRAM.c_str(),     value<path>(&pymol_program)->default_value(DEFAULT_PYMOL_PROGRAM), "Use arg as the PyMOL executable for viewing; may optionally include the full path"            )
		(PO_SUP_TO_PYMOL_FILE.c_str(), value<path>(&sup_to_pymol_file),                                   "Write the superposition to a PyMOL script arg\n(Recommended filename extension: .pml)"        )
		(PO_SUP_TO_JSON_FILE.c_str(),  value<path>(&json_file),                                           "Write the superposition to JSON superposition file\n(Recommended filename extension: .sup_json)"        );
}
    basic_parsed_options<charT>
    parse_config_file(std::basic_istream<charT>& is, 
                      const options_description& desc)
    {    
        set<string> allowed_options;
        set<string> pm = desc.primary_keys();
        for (set<string>::iterator i = pm.begin(); i != pm.end(); ++i) {
            const option_description& d = desc.find(*i);

            if (d.long_name().empty())
                throw error("long name required for config file");

            allowed_options.insert(d.long_name());
        }

        // Parser return char strings
        parsed_options result(&desc);        
        copy(detail::basic_config_file_iterator<charT>(is, allowed_options), 
             detail::basic_config_file_iterator<charT>(), 
             back_inserter(result.options));
        // Convert char strings into desired type.
        return basic_parsed_options<charT>(result);
    }
/// \brief Add this block's options to the provided options_description
void alignment_input_options_block::do_add_visible_options_to_description(options_description &arg_desc ///< The options_description to which the options are added
                                                                  ) {
	const string file_varname { "<file>" };

	const auto residue_name_align_notifier   = [&] (const bool &x) { the_alignment_input_spec.set_residue_name_align  ( x ); };
	const auto fasta_alignment_file_notifier = [&] (const path &x) { the_alignment_input_spec.set_fasta_alignment_file( x ); };
	const auto ssap_alignment_file_notifier  = [&] (const path &x) { the_alignment_input_spec.set_ssap_alignment_file ( x ); };
	const auto cora_alignment_file_notifier  = [&] (const path &x) { the_alignment_input_spec.set_cora_alignment_file ( x ); };
	const auto ssap_scores_file_notifier     = [&] (const path &x) { the_alignment_input_spec.set_ssap_scores_file    ( x ); };

	arg_desc.add_options()
		(
			PO_RES_NAME_ALIGN.c_str(),
			bool_switch()
				->notifier     ( residue_name_align_notifier                      )
				->default_value( alignment_input_spec::DEFAULT_RESIDUE_NAME_ALIGN ),
			"Align residues by simply matching their names (numbers+insert)\n(for multiple models of the same structure)"
		)
		(
			PO_FASTA_ALIGN_INFILE.c_str(),
			value<path>()
				->value_name( file_varname                  )
				->notifier  ( fasta_alignment_file_notifier ),
			( "Read FASTA alignment from file " + file_varname ).c_str()
		)
		(
			PO_SSAP_ALIGN_INFILE.c_str(),
			value<path>()
				->value_name( file_varname                 )
				->notifier  ( ssap_alignment_file_notifier ),
			( "Read SSAP alignment from file " + file_varname ).c_str()
		)
		(
			PO_CORA_ALIGN_INFILE.c_str(),
			value<path>()
				->value_name( file_varname                 )
				->notifier  ( cora_alignment_file_notifier ),
			( "Read CORA alignment from file " + file_varname ).c_str()
		)
		(
			PO_SSAP_SCORE_INFILE.c_str(),
			value<path>()
				->value_name( file_varname              )
				->notifier  ( ssap_scores_file_notifier ),
			( "Read SSAP scores from file " + file_varname + "\nAssumes all .list alignment files in same directory" ).c_str()
		);

	static_assert( ! alignment_input_spec::DEFAULT_RESIDUE_NAME_ALIGN,
		"If alignment_input_spec::DEFAULT_RESIDUE_NAME_ALIGN isn't false, it might mess up the bool switch in here" );
}
/// \brief Add this block's options to the provided options_description
void display_options_block::do_add_visible_options_to_description(options_description &arg_desc ///< The options_description to which the options are added
                                                                  ) {
	const string colrs_varname{ "<colrs>" };

	const auto display_colours_string_notifier    = [&] (const string &x) { the_display_spec.set_display_colours_string   ( x ); };
	const auto gradient_colour_alignment_notifier = [&] (const bool   &x) { the_display_spec.set_gradient_colour_alignment( x ); };
	const auto show_scores_if_present_notifier    = [&] (const bool   &x) { the_display_spec.set_show_scores_if_present   ( x ); };
	const auto scores_to_equivs_notifier          = [&] (const bool   &x) { the_display_spec.set_scores_to_equivs         ( x ); };
	const auto normalise_scores_notifier          = [&] (const bool   &x) { the_display_spec.set_normalise_scores         ( x ); };
	arg_desc.add_options()
		(
			PO_VIEWER_COLOURS.c_str(),
			value<string>()
				->value_name( colrs_varname                   )
				->notifier  ( display_colours_string_notifier ),
			( "Use " + colrs_varname + " to colour successive entries in the viewer\n"
			  "(format: colon-separated list of comma-separated triples of RGB values between 0 and 1)\n"
			  "(will wrap-around when it runs out of colours)" ).c_str()
		)
		(
			PO_GRADIENT_COLOUR_ALIGNMENT.c_str(),
			bool_switch()
				->notifier     ( gradient_colour_alignment_notifier )
				->default_value( false                              ),
			"Colour the length of the alignment with a rainbow gradient (blue -> red)"
		)
		(
			PO_SHOW_SCORES_IF_PRESENT.c_str(),
			bool_switch()
				->notifier     ( show_scores_if_present_notifier )
				->default_value( false                           ),
			( "Show the alignment scores\n(use with " + PO_GRADIENT_COLOUR_ALIGNMENT + ")" ).c_str()
		)
		(
			PO_SCORES_TO_EQUIVS.c_str(),
			bool_switch()
				->notifier     ( scores_to_equivs_notifier )
				->default_value( false                     ),
			( "Show the alignment scores to equivalent positions, which increases relative scores where few entries are aligned\n"
				"(use with --" + PO_GRADIENT_COLOUR_ALIGNMENT + " and --" + PO_SHOW_SCORES_IF_PRESENT + ")" ).c_str()
		)
		(
			PO_NORMALISE_SCORES.c_str(),
			bool_switch()
				->notifier     ( normalise_scores_notifier )
				->default_value( false                     ),
			( "When showing scores, normalise them to the highest score in the alignment\n"
				"(use with --" + PO_GRADIENT_COLOUR_ALIGNMENT + " and --" + PO_SHOW_SCORES_IF_PRESENT + ")" ).c_str() 
		);
}
    basic_parsed_options<charT>
    parse_xml(const options_description& desc) {
        using boost::shared_ptr;
        set<string> allowed_options;

        const vector<shared_ptr<option_description> >& options = desc.options();
        for (unsigned i = 0; i < options.size(); ++i) {
            const option_description& d = *options[i];

            if (d.long_name().empty())
                boost::throw_exception(
                    error("long name required for config file"));

            allowed_options.insert(d.long_name());
        }

        // Parser return char strings
        parsed_options result(&desc);
        result.options.push_back(basic_option<charT>("my_double", vector<string>(1, "10.1214")));
        //result.options.push_back(basic_option<charT>("my_string", vector<string>(1, "hello world")));
        return basic_parsed_options<charT>(result);
    }
Beispiel #10
0
 explicit AddOption(options_description& desc) : AddOptionBase(desc.add_options()) {}
Beispiel #11
0
inline AddOptionBase add(options_description& desc) {
  return desc.add_options();
}
Beispiel #12
0
 void history_plugin::set_program_options(options_description& cli, options_description& cfg) {
    cfg.add_options()
          ("filter_on_accounts,f", bpo::value<vector<string>>()->composing(),
           "Track only transactions whose scopes involve the listed accounts. Default is to track all transactions.")
          ;
 }
/// \brief Add this block's hidden options to the provided options_description
void check_pdb_options_block::do_add_hidden_options_to_description(options_description &arg_desc ///< The options_description to which the options are added
                                                                   ) {
	arg_desc.add_options()
		( PO_PDB_FILE.c_str(), value<path>( &pdb_file ), "PDB file to check" );
}
/// \brief Add this block's options to the provided options_description
///
/// This is a concrete definition of a virtual method that's pure in options_block
void check_pdb_options_block::do_add_visible_options_to_description(options_description &arg_desc ///< The options_description to which the options are added
                                                                    ) {
	arg_desc.add_options()
		( PO_PERMIT.c_str(), bool_switch( &permit_no_atoms )->default_value( false ), "Permit success for a file that has no ATOM records" );
}
void prepareParseMotorId(options_description& desc) {
  using namespace boost::program_options;
  desc.add_options()
    ("motor_id,i", value<int>()->default_value(1)->implicit_value(false)->required(), "the CAN id of the motor to test");
}
/// \brief Add any hidden options to the provided options_description
void old_ssap_options_block::do_add_hidden_options_to_description(options_description &arg_desc ///< The options_description to which the options are added
                                                                  ) {
	arg_desc.add_options()
		( PO_NAME.c_str(), value<str_vec>( &names ), "Structure names" );
}