5#ifndef GEMMI_PDB_ID_HPP_
6#define GEMMI_PDB_ID_HPP_
17 return (str.length() == 4 && std::isdigit(str[0]) && std::isalnum(str[1])
18 && std::isalnum(str[2]) && std::isalnum(str[3]))
19 || (str.length() == 12 && str.compare(0, 4,
"pdb_") == 0
20 && std::isdigit(str[4]));
29 if (
const char*
pdb_dir = std::getenv(
"PDB_DIR")) {
30 if (
code.size() == 12)
31 fail(
"extended PDB codes are not supported yet: " +
code);
39 path +=
"/structures/divided/";
40 const char*
dir[] = {
"pdb/",
"mmCIF/",
"structure_factors/"};
42 path +=
lc.substr(1, 2);
43 const char*
prefix[] = {
"/pdb",
"/",
"/r"};
46 const char*
suffix[] = {
".ent.gz",
".cif.gz",
"sf.ent.gz"};
49 fail(
code +
" is a PDB code, but $PDB_DIR is not set.");
bool is_pdb_code(const std::string &str)
std::string expand_pdb_code_to_path(const std::string &code, char type, bool throw_if_unset=false)
Call it after checking the code with gemmi::is_pdb_code(code).
std::string to_lower(std::string str)
void fail(const std::string &msg)
std::string expand_if_pdb_code(const std::string &input, char type='M')