5#ifndef GEMMI_PDB_ID_HPP_
6#define GEMMI_PDB_ID_HPP_
18 if (!std::isalnum(*
p))
24 return (str.length() == 4 && std::isdigit(str[0]) &&
all_alnums(&str[1]))
25 || (str.length() == 12 && str.compare(0, 4,
"pdb_") == 0
26 && std::isdigit(str[4]) &&
all_alnums(&str[5]));
29 if (
code.size() == 12)
30 fail(
"extended PDB codes are not supported yet: " +
code);
37 std::string path =
"/structures/divided/";
38 const char*
dir[] = {
"pdb/",
"mmCIF/",
"structure_factors/"};
40 path +=
lc.substr(1, 2);
41 const char*
prefix[] = {
"/pdb",
"/",
"/r"};
44 const char*
suffix[] = {
".ent.gz",
".cif.gz",
"sf.ent.gz"};
55 if (
const char*
pdb_dir = std::getenv(
"PDB_DIR")) {
58 fail(
code +
" is a PDB code, but $PDB_DIR is not set.");
fail(), unreachable() and __declspec/__attribute__ macros
bool is_pdb_code(const std::string &str)
bool all_alnums(const char *p)
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)
std::string path_in_pdb_dir(const std::string &code, char type)
void fail(const std::string &msg)
std::string expand_if_pdb_code(const std::string &input, char type='M')
Utilities. Mostly for working with strings and vectors.