Rosetta
Namespaces | Functions | Variables
basic::database Namespace Reference

Namespaces

 insert_statement_generator
 
 schema_generator
 

Functions

bool open (utility::io::izstream &db_stream, std::string const &db_file, bool warn)
 Open a database file on a provided stream. More...
 
std::string full_name (std::string const &db_file, bool warn)
 Full-path database file name. More...
 
std::string find_database_path (std::string const &dir, std::string const &filename, bool const mute_error_if_failure)
 Find a path to a file. More...
 
std::string find_database_path (std::string const &dir, std::string const &filename, std::string const &ext)
 Find a path to a file. More...
 
bool find_cache_file (std::string const &cache_file, bool dir_only)
 Does cache file (absolute path) exist? if dir_only is true, will return true if the cache file could be created. More...
 
std::string full_cache_name (std::string const &short_name, std::string const &source_file, bool for_writing)
 Get the (absolute) path to a given cached file. If source_file is given, it's the full path to the source database file that's being cached. If for_writing is true, will only check that the given file would be creatable. Will return an empty string if it can't find a cache file. More...
 
sessionOP get_db_session ()
 Aquire a database session using the command line options transaction type is set to standard. More...
 
sessionOP get_db_session (std::string const &db_name, std::string const &pq_schema="")
 Aquire a database session using the command line parameters For postgres databases, the pq_schema acts like a namespace in the database. Transaction type set to standard. More...
 
sessionOP get_db_session (string const &db_name, TransactionMode::e transaction_mode, Size chunk_size, string const &pq_schema)
 
utility::sql_database::sessionOP get_db_session (utility::sql_database::DatabaseMode::e db_mode, std::string const &db_name, std::string const &pq_schema)
 
sessionOP get_db_session (DatabaseMode::e db_mode, TransactionMode::e transaction_mode, Size chunk_size, string const &db_name, string const &pq_schema)
 
platform::SSize db_partition_from_options (DatabaseMode::e db_mode)
 @ More...
 
platform::SSize resolve_db_partition (bool partition_by_mpi_process, platform::SSize manual_partition=-1)
 Returns partition identifer from mpi rank if in partitioned database mode, or valid manual partition, otherwise -1. More...
 
statement safely_prepare_statement (string const &statement_string, sessionOP db_session)
 
statement prepare_statement_no_catch (std::string const &statement_string, utility::sql_database::sessionOP db_session)
 Do not catch the error - leave the catch for the code using it. Do not use this unless YOU are catching any erorrs (cppdb::error). More...
 
void safely_write_to_database (statement &statement)
 
result safely_read_from_database (statement &statement)
 
bool table_exists (sessionOP db_session, string const &table_name)
 
void check_statement_sanity (string sql)
 
void insert_or_ignore (string table_name, std::vector< string > column_names, std::vector< string > values, sessionOP db_session)
 
void write_schema_to_database (string schema_str, sessionOP db_session)
 
void set_cache_size (sessionOP db_session, Size cache_size)
 
std::string make_compound_statement (std::string const &table_name, std::vector< std::string > const &column_names, platform::Size const &row_count)
 
utility::sql_database::sessionOP parse_database_connection (utility::tag::TagCOP tag)
 
void attributes_for_parse_database_connection (utility::tag::AttributeList &attlist, utility::tag::XMLSchemaDefinition &xsd)
 
utility::sql_database::sessionOP get_db_session (std::string const &db_name, utility::sql_database::TransactionMode::e transaction_mode, platform::Size chunk_size, std::string const &pq_schema="")
 Aquire a database session using the command line parameters For postgres databases, the pq_schema acts like a namespace in the database. More...
 
utility::sql_database::sessionOP get_db_session (utility::sql_database::DatabaseMode::e db_mode, utility::sql_database::TransactionMode::e transaction_mode, platform::Size chunk_size, std::string const &db_name, std::string const &pq_schema="")
 Aquire a database session using the command line parameters For postgres databases, the pq_schema acts like a namespace in the database. More...
 
void safely_write_to_database (cppdb::statement &statement)
 
cppdb::result safely_read_from_database (cppdb::statement &statement)
 
void set_cache_size (utility::sql_database::sessionOP db_session, platform::Size cache_size)
 set the number of 1kb pages to use for cache More...
 

Variables

static basic::Tracer TR ("basic.io.database")
 
static basic::Tracer TR ("basic.database.sql_utils")
 

Function Documentation

◆ attributes_for_parse_database_connection()

void basic::database::attributes_for_parse_database_connection ( utility::tag::AttributeList attlist,
utility::tag::XMLSchemaDefinition xsd 
)

◆ check_statement_sanity()

void basic::database::check_statement_sanity ( string  sql)

◆ db_partition_from_options()

platform::SSize basic::database::db_partition_from_options ( DatabaseMode::e  db_mode)

◆ find_cache_file()

bool basic::database::find_cache_file ( std::string const &  cache_file,
bool  dir_only 
)

◆ find_database_path() [1/2]

std::string basic::database::find_database_path ( std::string const &  dir,
std::string const &  filename,
bool const  mute_error_if_failure 
)

Find a path to a file.

Try various combinations to locate the specific file being requested by the user. (inspired by core::scoring::ScoreFunction::find_weights_file())

@athor Labonte JWLab.nosp@m.onte.nosp@m.@jhu..nosp@m.edu

Try various combinations to locate the specific file being requested by the user. (inspired by core::scoring::ScoreFunction::find_weights_file())

mute_error_if_failure returns "" if the file does not exist instead of throwing a loud exception

dir like chemical/carbohydrates/linkage_conformers/

References lactamize::filename, full_name(), utility::io::izstream::good(), closure_error::path, PB_potential::potential_file, and utility_exit_with_message.

◆ find_database_path() [2/2]

std::string basic::database::find_database_path ( std::string const &  dir,
std::string const &  filename,
std::string const &  ext 
)

Find a path to a file.

Try various combinations to locate the specific file being requested by the user. (inspired by core::scoring::ScoreFunction::find_weights_file())

@athor Labonte JWLab.nosp@m.onte.nosp@m.@jhu..nosp@m.edu

Try various combinations to locate the specific file being requested by the user. (inspired by core::scoring::ScoreFunction::find_weights_file())

dir like chemical/carbohydrates/linkage_conformers/

References val2thr::ext, lactamize::filename, full_name(), utility::io::izstream::good(), closure_error::path, PB_potential::potential_file, and utility_exit_with_message.

◆ full_cache_name()

std::string basic::database::full_cache_name ( std::string const &  short_name,
std::string const &  source_file,
bool  for_writing 
)

Get the (absolute) path to a given cached file. If source_file is given, it's the full path to the source database file that's being cached. If for_writing is true, will only check that the given file would be creatable. Will return an empty string if it can't find a cache file.

References utility::file::FileName::bare_name(), in::path::database_cache_dir(), find_cache_file(), utility::file::get_home_dir(), option, closure_error::path, utility::file::FileName::path(), and basic::options::OptionKeys::inout::dbms::user.

◆ full_name()

std::string basic::database::full_name ( std::string const &  db_file,
bool  warn 
)

◆ get_db_session() [1/7]

utility::sql_database::sessionOP basic::database::get_db_session ( )

◆ get_db_session() [2/7]

sessionOP basic::database::get_db_session ( DatabaseMode::e  db_mode,
TransactionMode::e  transaction_mode,
Size  chunk_size,
string const &  db_name,
string const &  pq_schema 
)

◆ get_db_session() [3/7]

utility::sql_database::sessionOP basic::database::get_db_session ( string const &  db_name,
string const &  pq_schema 
)

Aquire a database session using the command line parameters For postgres databases, the pq_schema acts like a namespace in the database. Transaction type set to standard.

References utility::sql_database::database_mode_from_name(), get_db_session(), inout::dbms::mode(), option, basic::options::OptionKeys::inout::dbms::pq_schema, and utility::sql_database::TransactionMode::standard.

◆ get_db_session() [4/7]

utility::sql_database::sessionOP basic::database::get_db_session ( std::string const &  db_name,
utility::sql_database::TransactionMode::e  transaction_mode,
platform::Size  chunk_size,
std::string const &  pq_schema = "" 
)

Aquire a database session using the command line parameters For postgres databases, the pq_schema acts like a namespace in the database.

◆ get_db_session() [5/7]

sessionOP basic::database::get_db_session ( string const &  db_name,
TransactionMode::e  transaction_mode,
Size  chunk_size,
string const &  pq_schema 
)

◆ get_db_session() [6/7]

utility::sql_database::sessionOP basic::database::get_db_session ( utility::sql_database::DatabaseMode::e  db_mode,
std::string const &  db_name,
std::string const &  pq_schema 
)

◆ get_db_session() [7/7]

utility::sql_database::sessionOP basic::database::get_db_session ( utility::sql_database::DatabaseMode::e  db_mode,
utility::sql_database::TransactionMode::e  transaction_mode,
platform::Size  chunk_size,
std::string const &  db_name,
std::string const &  pq_schema = "" 
)

Aquire a database session using the command line parameters For postgres databases, the pq_schema acts like a namespace in the database.

◆ insert_or_ignore()

void basic::database::insert_or_ignore ( string  table_name,
std::vector< string >  column_names,
std::vector< string >  values,
sessionOP  db_session 
)

◆ make_compound_statement()

std::string basic::database::make_compound_statement ( std::string const &  table_name,
std::vector< std::string > const &  column_names,
platform::Size const &  row_count 
)

◆ open()

bool basic::database::open ( utility::io::izstream db_stream,
std::string const &  db_file,
bool  warn = true 
)

Open a database file on a provided stream.

Does a database file exist?

Open a database file on a provided stream

References utility::io::izstream::clear(), utility::io::izstream::close(), CREATE_EXCEPTION, full_name(), utility::io::izstream::good(), utility::io::izstream::open(), and TR.

Referenced by pyrosetta.distributed.cluster.io.IO::_save_results(), pyrosetta.distributed.cluster.io.IO::_write_environment_file(), pyrosetta.toolbox.load_ligand::add_cid_to_database(), add_xyz_to_pose::append_to_pdb(), auto-DRRAFTER_setup::auto_setup_helices(), DRRAFTER_util::better_reorder_pdb(), calc_blosum_scores(), calculate_total_hASA_within_distance_avg_values(), calculate_total_hASA_within_distance_avgresiduevalues_allnbs_conditionalonnumnbs(), DRRAFTER_util::cat_outfiles(), pyrosetta.toolbox.cleaning::cleanATOM(), options.KeepSameFile::close(), get_junctions_from_legos::collect_junctions(), add_xyz_to_pose::collect_xyz(), combine_pdbs::combine_pdbs(), compare_times::compare_times(), make_bindings_via_cmake::compile_sources(), ez_setup::download_file_insecure(), pyrosetta.toolbox.rcsb::download_from_web(), pyrosetta.toolbox.atom_pair_energy::dump_atom_pair_energy_table(), pyrosetta.toolbox.atom_pair_energy::dump_residue_pair_energies(), DRRAFTER_util::easy_cat(), enumerate_junctions::enumerate_tranform_db(), erraser_wrapper::erraser(), erraser_wrapper::erraser_minimize(), erraser_wrapper::erraser_single_res(), erraser_single_res_analysis::extract_info(), DRRAFTER_util::extract_lowscore_decoys(), erraser_util::extract_pdb(), auto-DRRAFTER_setup_next_round::figure_out_next_round(), mutant_modeler::figure_out_WT_seq(), finalize_models::finalize(), erraser_util::find_chi_angle(), erraser_analysis::find_chi_angle_std_pdb(), erraser_single_res_analysis::find_chi_angle_std_pdb(), bin_torsions::find_pivots(), kic_runner::find_rosetta_installation(), helpers::find_rosetta_root(), bin_torsions::find_title(), bin_torsions::find_y_limits(), update_ui_project::generate_app_list(), update_ui_project::generate_app_shell_scripts(), build::generate_bindings(), build::generate_cmake_file(), enumerate_junctions::generate_dhrs_txt_file(), build::generate_documentation(), bin_torsions::generate_histograms(), enumerate_junctions::generate_junctions_txt_file(), pyrosetta.toolbox.generate_resfile::generate_resfile_from_pose(), demo.D050_Packer_task::generate_resfile_from_pose(), build::generate_rosetta_cmake_files(), build::generate_rosetta_external_cmake_files(), update_ui_project::generate_rosetta_external_project_files(), update_ui_project::generate_rosetta_libraries_project_files(), sphinx-doc-generator::generate_rst_sphinx_files(), enumerate_junctions::get_all_dhrs(), enumerate_junctions::get_all_junctions(), DRRAFTER::get_coord_csts(), build::get_defines(), drrafter_rna::get_density_per_residue(), erraser_util::get_fasta(), get_frags_map(), mutant_modeler.MutantModeler::get_high_res_command_lines(), pyrosetta.distributed.cluster.tools::get_instance_kwargs(), mutant_modeler.MutantModeler::get_med_res_command_lines(), setup::get_package_version(), cal_vdw_radius_pool::get_pair_counts(), pyrosetta.distributed.cluster.converter_tasks::get_protocols_list_of_str(), auto-DRRAFTER_setup_next_round::get_results(), get_final_ddG_scores::get_scores(), pyrosetta.distributed.cluster.converter_tasks::get_scores_dict(), DRRAFTER_util::get_sequences(), auto-DRRAFTER_setup_next_round::get_silent_file_subset(), setup_for_complex_scoring_general::get_ss(), mutant_modeler::get_ss(), auto-DRRAFTER_setup_next_round::get_top_ten_models_from_silent_files(), erraser_util::get_total_res(), erraser_util::grep(), ez_setup::has_curl(), ez_setup::has_powershell(), ez_setup::has_wget(), pyrosetta.distributed.viewer.core::init(), build::install_llvm_tool(), subloop_histogram::key_from_pivots(), enumerate_junctions::listener(), dbscan_cluster_rotamer::load_centroid(), kmeans_adaptive_kernel_density_bb_dependent_rotlib::load_centroid(), kmeans_bb_dependent_rotlib::load_centroid(), kmeans_common::load_centroid(), spectral_cluster_kmeans_adaptive_kernel_density_bb_dependent_rotlib::load_centroid(), kmeans_adaptive_kernel_density_bb_dependent_rotlib::load_centroid_xyz(), kmeans_common::load_centroid_xyz(), dbscan_adaptive_kernel_density_bb_dependent_rotlib::load_data(), pyrosetta.toolbox.rcsb::load_fasta_from_rcsb(), compare_times::load_files(), pyrosetta.toolbox.load_ligand::load_from_pubchem(), pyrosetta.toolbox.rcsb::load_from_rcsb(), bin_torsions::load_histograms_from_npz(), erraser_util::load_pdb_coord(), erraser_util::load_pdb_coord_old(), bin_torsions::load_torsions_from_dat(), progress_bar::main(), setup_for_complex_scoring_general::main(), dbscan_cluster_rotamer::main(), find_lowest_scoring_relaxed_struct::main(), general_RNP_setup_script::main(), get_final_ddG_scores::main(), relax_starting_structure::main(), get_lowest_scoring_relaxed_models::main(), sphinx-doc-generator::main(), self-test::main(), combine_ContactMaps::main(), arls_impl::main(), best_ifaceE::main(), get_scores::main(), prune_atdiff_top5pct::main(), sidechain_cst_3::main(), main(), dbscan_cluster_rotamer::main_old_kmeans(), make_bindings_via_cmake::make_all_includes(), make_bindings_via_cmake::make_bindings_code(), mutant_modeler.MutantModeler::make_high_res_subsets_and_cmd_lines(), submit_jobs::make_job_files_and_submit(), pyrosetta.io.silent_file_map::open_compressed(), utility::sql_database::session::open_mysql_session(), utility::sql_database::session::open_postgres_session(), utility::sql_database::session::open_sqlite3_session(), pyrosetta.toolbox.py_jobdistributor::output_scorefile(), percent_subangstrom::parse_benchmark(), DRRAFTER::parse_fasta(), bin_torsions::parse_iterations(), percent_subangstrom::parse_job(), score_vs_rmsd::parse_new_source(), score_vs_rmsd::parse_old_source(), DRRAFTER::parse_secstruct(), erraser_util::pdb2fasta(), erraser_util::pdb2rosetta(), erraser_util::pdb_slice(), DRRAFTER_util::pdbslice(), histogram::plot_ideal_torsions(), histogram::plot_rama_kic(), bin_torsions::plot_score_function(), histogram::plot_uniform_kic(), ObjexxFCL::process_file(), DRRAFTER_util::read_pdb(), util::read_pdb(), DRRAFTER_util::read_pdb_with_segid(), read_rama_map_file(), read_sphere(), SphereSample::read_sphere_data(), erraser_wrapper::rebuild_completed(), pyrosetta.distributed.cluster.tools::recreate_environment(), erraser_util::regularize_OP1_OP2(), erraser_util::regularize_pdb(), self-test::remover_absolute_paths(), DRRAFTER_util::renumber_pdb(), basic::sampling::orientations::QuaternionGridManager::request_by_name(), erraser_util::rosetta2phenix_merge_back(), erraser_util::rosetta2std_pdb(), self-test::run_test(), demo.D090_Ala_scan::scanning(), demo.D090_Ala_scan::scanning_analysis(), erraser_wrapper::seq_rebuild(), erraser_wrapper::seq_rebuild_new(), pyrosetta.tests.distributed.test_viewer.TestViewer::setUp(), kic_runner::setup_hook(), DRRAFTER::setup_job(), drrafter_rna::setup_next_round(), erraser_util::sliced2orig_merge_back(), sphere_coverage(), SphereSampler::SphereSampler(), submit_jobs::submit_jobs(), erraser_util::subprocess_call(), erraser_util::subprocess_out(), erraser_wrapper::SWA_rebuild_erraser(), pyrosetta.tests.distributed.cluster.test_logging.LoggingTest::test_logging(), pyrosetta.tests.distributed.cluster.test_reproducibility.TestReproducibilityMulti::test_reproducibility_from_reproduce(), pyrosetta.tests.distributed.cluster.test_reproducibility.TestReproducibility::test_reproducibility_minimizer_nstruct(), pyrosetta.tests.distributed.cluster.test_reproducibility.TestReproducibility::test_reproducibility_packer_nstruct(), pyrosetta.tests.distributed.cluster.test_reproducibility.TestReproducibilityMulti::test_reproducibility_packer_nstruct_multi(), pyrosetta.tests.distributed.cluster.test_reproducibility.TestReproducibilityMulti::test_reproducibility_packer_nstruct_multi_decoy_ids(), pyrosetta.tests.distributed.cluster.test_reproducibility.TestReproducibility::test_reproducibility_packer_separate(), pyrosetta.tests.distributed.cluster.test_smoke.SaveAllTest::test_save_all(), pyrosetta.tests.distributed.test_dask_worker.TestDaskArgs::test_worker_extra(), build::update_source_file(), update_ui_project::update_source_file(), drrafter_rna::write_command_file(), drrafter_rna::write_flags_extend_last_round(), DRRAFTER::write_flags_file(), arls_impl::write_if_not_exists(), and mutant_modeler.MutantModeler::write_mutfile().

◆ parse_database_connection()

utility::sql_database::sessionOP basic::database::parse_database_connection ( utility::tag::TagCOP  tag)

@detail build database connection from options in a tag, this is useful make sure the fields for constructing a database connection are consistent across different tags.

References out::path::all(), utility::sql_database::TransactionMode::chunk, utility::sql_database::database_mode_from_name(), basic::options::OptionKeys::inout::dbms::database_name, basic::options::OptionKeys::inout::dbms::database_partition, inout::dbms::database_partition(), out::path::db(), enumerate_junctions::default, utility::sql_database::DatabaseSessionManager::get_db_session(), utility::SingletonBase< DatabaseSessionManager >::get_instance(), basic::options::OptionKeys::cloud::host, SmotifHasher::mode, utility::sql_database::DatabaseMode::mysql, utility::sql_database::name_from_database_mode(), utility::sql_database::name_from_transaction_mode(), utility::sql_database::TransactionMode::none, option, basic::options::OptionKeys::inout::dbms::password, closure_error::path, inout::dbms::path(), basic::options::OptionKeys::cloud::port, utility::sql_database::DatabaseMode::postgres, basic::options::OptionKeys::inout::dbms::pq_schema, resolve_db_partition(), inout::dbms::separate_db_per_mpi_process(), utility::sql_database::DatabaseMode::sqlite3, utility::sql_database::TransactionMode::standard, tag, TR, utility::sql_database::transaction_mode_from_name(), basic::options::OptionKeys::inout::dbms::user, utility_exit_with_message, and basic::Tracer::Warning.

Referenced by basic::resource_manager::locator::DatabaseResourceLocator::parse_my_tag().

◆ prepare_statement_no_catch()

cppdb::statement basic::database::prepare_statement_no_catch ( string const &  statement_string,
sessionOP  db_session 
)

Do not catch the error - leave the catch for the code using it. Do not use this unless YOU are catching any erorrs (cppdb::error).

◆ resolve_db_partition()

platform::SSize basic::database::resolve_db_partition ( bool  partition_by_mpi_process,
platform::SSize  manual_partition 
)

Returns partition identifer from mpi rank if in partitioned database mode, or valid manual partition, otherwise -1.

References utility::mpi_rank().

Referenced by db_partition_from_options(), and parse_database_connection().

◆ safely_prepare_statement()

cppdb::statement basic::database::safely_prepare_statement ( string const &  statement_string,
sessionOP  db_session 
)

◆ safely_read_from_database() [1/2]

cppdb::result basic::database::safely_read_from_database ( cppdb::statement &  statement)

◆ safely_read_from_database() [2/2]

result basic::database::safely_read_from_database ( statement &  statement)

◆ safely_write_to_database() [1/2]

void basic::database::safely_write_to_database ( cppdb::statement &  statement)

◆ safely_write_to_database() [2/2]

void basic::database::safely_write_to_database ( statement &  statement)

◆ set_cache_size() [1/2]

void basic::database::set_cache_size ( sessionOP  db_session,
Size  cache_size 
)

◆ set_cache_size() [2/2]

void basic::database::set_cache_size ( utility::sql_database::sessionOP  db_session,
platform::Size  cache_size 
)

set the number of 1kb pages to use for cache

◆ table_exists()

bool basic::database::table_exists ( sessionOP  db_session,
string const &  table_name 
)

◆ write_schema_to_database()

void basic::database::write_schema_to_database ( string  schema_str,
sessionOP  db_session 
)

Variable Documentation

◆ TR [1/2]

basic::Tracer basic::database::TR("basic.database.sql_utils") ( "basic.database.sql_utils"  )
static

◆ TR [2/2]

basic::Tracer basic::database::TR("basic.io.database") ( "basic.io.database"  )
static

Referenced by find_cache_file(), full_name(), and open().