| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| #ifndef ALPHAFOLD3_SRC_ALPHAFOLD3_STRUCTURE_PYTHON_MMCIF_LAYOUT_H_ |
| #define ALPHAFOLD3_SRC_ALPHAFOLD3_STRUCTURE_PYTHON_MMCIF_LAYOUT_H_ |
|
|
| #include <cstddef> |
| #include <cstdint> |
| #include <string> |
| #include <utility> |
| #include <vector> |
|
|
| #include "absl/status/statusor.h" |
| #include "absl/strings/string_view.h" |
| #include "absl/types/span.h" |
| #include "alphafold3/parsers/cpp/cif_dict_lib.h" |
|
|
| namespace alphafold3 { |
|
|
| |
| class MmcifLayout { |
| public: |
| MmcifLayout(std::vector<std::size_t> chain_ends, |
| std::vector<std::size_t> residues, std::size_t model_offset, |
| std::size_t num_models) |
| : chain_ends_(std::move(chain_ends)), |
| residue_ends_(std::move(residues)), |
| model_offset_(model_offset), |
| num_models_(num_models) {} |
|
|
| |
| |
| |
| |
| |
| static absl::StatusOr<MmcifLayout> Create(const CifDict& mmcif, |
| absl::string_view model_id = ""); |
|
|
| std::string ToDebugString() const; |
|
|
| |
| |
| |
| |
| std::pair<std::size_t, std::size_t> residue_range( |
| std::size_t chain_index) const { |
| if (chain_index > 0) { |
| return {chain_ends_[chain_index - 1], chain_ends_[chain_index]}; |
| } else { |
| return {0, chain_ends_[0]}; |
| } |
| } |
|
|
| |
| |
| |
| std::pair<std::size_t, std::size_t> atom_range( |
| std::size_t residue_index) const { |
| if (residue_index > 0) { |
| return {residue_ends_[residue_index - 1], residue_ends_[residue_index]}; |
| } else { |
| return {model_offset_, residue_ends_[residue_index]}; |
| } |
| } |
|
|
| |
| |
| std::size_t num_models() const { return num_models_; } |
| |
| std::size_t num_atoms() const { |
| return residue_ends_.empty() ? 0 : residue_ends_.back() - model_offset_; |
| } |
| |
| std::size_t num_chains() const { return chain_ends_.size(); } |
| |
| |
| std::size_t num_residues() const { return residue_ends_.size(); } |
|
|
| |
| |
| |
| std::size_t atom_site_from_chain_index(std::size_t chain_index) const { |
| if (chain_index == 0) { |
| return model_offset_; |
| } |
| return atom_site_from_residue_index(chain_ends_[chain_index - 1]); |
| } |
|
|
| |
| |
| |
| std::size_t atom_site_from_residue_index(std::size_t residues_index) const { |
| if (residues_index == 0) { |
| return model_offset_; |
| } |
| return residue_ends_[residues_index - 1]; |
| } |
|
|
| |
| |
| |
| const std::vector<std::size_t>& chains() const { return chain_ends_; } |
|
|
| |
| |
| std::vector<std::size_t> chain_starts() const; |
|
|
| |
| const std::vector<std::size_t>& residues() const { return residue_ends_; } |
|
|
| |
| std::vector<std::size_t> residue_starts() const { |
| std::vector<std::size_t> residue_starts; |
| if (!residue_ends_.empty()) { |
| residue_starts.reserve(residue_ends_.size()); |
| residue_starts.push_back(model_offset_); |
| residue_starts.insert(residue_starts.end(), residue_ends_.begin(), |
| residue_ends_.end() - 1); |
| } |
| return residue_starts; |
| } |
|
|
| |
| std::size_t model_offset() const { return model_offset_; } |
|
|
| void Filter(absl::Span<const std::uint64_t> keep_indices); |
|
|
| private: |
| std::vector<std::size_t> chain_ends_; |
| std::vector<std::size_t> residue_ends_; |
| std::size_t model_offset_; |
| std::size_t num_models_; |
| }; |
|
|
| } |
|
|
| #endif |
|
|