Skip to content

Commit

Permalink
Depythonize fetch_pdb_ligand_description_action()
Browse files Browse the repository at this point in the history
  • Loading branch information
pemsley committed Jul 6, 2024
1 parent f882ff9 commit 3b52a71
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/create-menu-item-actions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,8 @@ fetch_map_from_emdb_action(G_GNUC_UNUSED GSimpleAction *simple_action,
}


#include "curl-utils.hh"

void
fetch_pdbe_ligand_description_action(G_GNUC_UNUSED GSimpleAction *simple_action,
G_GNUC_UNUSED GVariant *parameter,
Expand All @@ -506,14 +508,19 @@ fetch_pdbe_ligand_description_action(G_GNUC_UNUSED GSimpleAction *simple_action,
coot::residue_spec_t res_spec(pp.second.second);
const auto &m = graphics_info_t::molecules[imol];
std::string comp_id = m.get_residue_name(res_spec);
// python-function: coot_utils.get_SMILES_for_comp_id_from_pdbe arg: comp_id
std::cout << "run python function coot_utils.get_SMILES_for_comp_id_from_pdbe " << comp_id << std::endl;
short int lang = coot::STATE_PYTHON;
std::vector<coot::command_arg_t> args = { coot::command_arg_t(comp_id) };
std::string sc = g.state_command("coot_utils", "get_SMILES_for_comp_id_from_pdbe", args, lang);
std::cout << ":::::::::::::::::::::: python command: " << sc << std::endl;
safe_python_command("import coot_utils"); // Hack. This has already happened, but python has forgotten.
safe_python_command(sc);

// 20240706-PE old python function was get_SMILES_for_comp_id_from_pdbe()
// and that calls get_pdbe_cif_for_comp_id()
xdg_t xdg;
std::string file_name = comp_id + ".cif";
std::filesystem::path data_home = xdg.get_data_home();
std::filesystem::path file_path = data_home / file_name;
// maybe check that the file exists first?
std::string url = std::string("https://www.ebi.ac.uk/pdbe/static/files/pdbechem_v2/") + file_name;
int status = coot_get_url(url, file_path.string());
if (status == 0) {
read_cif_dictionary(file_name.c_str()); // remove above include and put this function into cc-interface.hh
}
}
}

Expand Down

0 comments on commit 3b52a71

Please sign in to comment.