Gemmi C++ API
Loading...
Searching...
No Matches
pdb.hpp
Go to the documentation of this file.
1// Copyright 2017 Global Phasing Ltd.
2//
3// Read the PDB file format and store it in Structure.
4//
5// Based on the format spec:
6// https://www.wwpdb.org/documentation/file-format-content/format33/v3.3.html
7// + support for two-character chain IDs (columns 21 and 22)
8// + read segment ID (columns 73-76)
9// + read hybrid-36 serial numbers (http://cci.lbl.gov/hybrid_36/)
10// + hybrid-36 sequence id for sequences longer than 9999 (no such examples)
11// + allow for longer REMARK lines (up to 120 characters)
12
13#ifndef GEMMI_PDB_HPP_
14#define GEMMI_PDB_HPP_
15
16#include "input.hpp" // for FileStream
17#include "model.hpp" // for Structure, ...
18
19namespace gemmi {
20
23inline bool is_record_type4(const char* s, const char* record) {
24 return ialpha4_id(s) == ialpha4_id(record);
25}
27inline bool is_record_type3(const char* s, const char* record) {
28 return (ialpha4_id(s) & ~0xf) == ialpha4_id(record);
29}
30
32GEMMI_DLL std::vector<Op> read_remark_290(const std::vector<std::string>& raw_remarks);
33
35 const std::string& source,
37
38inline Structure read_pdb_file(const std::string& path,
40 FileStream stream(path.c_str(), "rb");
41 return read_pdb_from_stream(stream, path, options);
42}
43
44inline Structure read_pdb_from_memory(const char* data, size_t size,
45 const std::string& name,
47 MemoryStream stream{data, size};
48 return read_pdb_from_stream(stream, name, options);
49}
50
51inline Structure read_pdb_string(const std::string& str,
52 const std::string& name,
54 return read_pdb_from_memory(str.c_str(), str.length(), name, options);
55}
56
57template<typename T>
59 return read_pdb_from_stream(*input.create_stream(), input.path(), options);
60}
61
62} // namespace gemmi
63#endif
#define GEMMI_DLL
Definition fail.hpp:53
Input abstraction. Used to decouple file reading and decompression.
Data structures to store macromolecular structure models.
GEMMI_DLL Structure read_pdb_from_stream(AnyStream &line_reader, const std::string &source, PdbReadOptions options)
Structure read_pdb(T &&input, PdbReadOptions options={})
Definition pdb.hpp:58
GEMMI_DLL std::vector< Op > read_remark_290(const std::vector< std::string > &raw_remarks)
Returns operations corresponding to 1555, 2555, ... N555.
Structure read_pdb_string(const std::string &str, const std::string &name, PdbReadOptions options={})
Definition pdb.hpp:51
Structure read_pdb_from_memory(const char *data, size_t size, const std::string &name, PdbReadOptions options={})
Definition pdb.hpp:44
bool is_record_type3(const char *s, const char *record)
for record "TER": "TER ", TER , TER\r, TER\t match, TERE, TER1 don't
Definition pdb.hpp:27
Structure read_pdb_file(const std::string &path, PdbReadOptions options={})
Definition pdb.hpp:38
bool is_record_type4(const char *s, const char *record)
Compare the first 4 letters of s, ignoring case, with uppercase record.
Definition pdb.hpp:23
constexpr int ialpha4_id(const char *s)
Definition util.hpp:306
options affecting how pdb file is read
Definition model.hpp:101