OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
mmcif_writer.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2024 by the OpenStructure authors
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 3.0 of the License, or (at your option)
9 // any later version.
10 // This library is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //------------------------------------------------------------------------------
19 #ifndef OST_IO_MMCIF_WRITER_HH
20 #define OST_IO_MMCIF_WRITER_HH
21 
22 #include <fstream>
23 
24 #include <ost/mol/entity_handle.hh>
26 
27 #include <ost/io/mol/mmcif_info.hh>
28 #include <ost/io/mol/io_profile.hh>
30 
31 namespace ost { namespace io {
32 
33 
35 
37 
38  static MMCifWriterEntity FromPolymer(const String& entity_poly_type,
39  const std::vector<String>& mon_ids,
41 
42  int GetAsymIdx(const String& asym_id) const;
43 
44  void AddHet(int rnum, const String& mon_id) {
45  het[rnum].push_back(mon_id);
46  }
47 
48  bool operator==(const MMCifWriterEntity& rhs) const {
49  return (type == rhs.type)
50  && (poly_type == rhs.poly_type)
51  && (branch_type == rhs.branch_type)
52  && (asym_ids == rhs.asym_ids)
53  && (is_poly == rhs.is_poly)
54  && (mon_ids == rhs.mon_ids)
55  && (seq_olcs == rhs.seq_olcs)
56  && (seq_can_olcs == rhs.seq_can_olcs)
57  && (asym_alns == rhs.asym_alns);
58  }
59 
60  bool operator!=(const MMCifWriterEntity& rhs) const {
61  return !(*this == rhs);
62  }
63 
64  // _entity.type
66 
67  // _entity_poly.type
69 
70  // __pdbx_entity_branch.type
72 
73  // Names of chains in AU that are assigned to this entity
74  std::vector<String> asym_ids;
75 
76  // in principle type == "polymer"
77  bool is_poly;
78 
79  // SEQRES... kind of... internally we're not working on one letter codes
80  // etc. but on full compound names. Only one element if is_poly is false.
81  std::vector<String> mon_ids;
82 
83  // The respective strings for pdbx_seq_one_letter_code
84  // Irrelevant if is_poly is false.
85  std::vector<String> seq_olcs;
86 
87  // same for pdbx_seq_one_letter_code_can
88  // Irrelevant if is_poly is false.
89  std::vector<String> seq_can_olcs;
90 
91  // One alignment to mon_ids for each element in asym_ids, i.e. SEQRES-ATOMSEQ
92  // alignment. Contains "-" for residues that are missing in ATOMSEQ.
93  // irrelevant if is_poly is false. The assumption is that aligned residues
94  // exactly match with the respective position in mon_ids.
95  std::map<String, std::vector<String> > asym_alns;
96 
97  // heterogeneities
98  std::map<int, std::vector<String> > het;
99 };
100 
102 public:
103 
104  MMCifWriter(): structure_set_(false) { }
105 
106  virtual ~MMCifWriter() { }
107 
108  void SetStructure(const ost::mol::EntityHandle& ent, conop::CompoundLibPtr compound_lib,
109  bool mmcif_conform=true,
110  const std::vector<MMCifWriterEntity>& entity_info=std::vector<MMCifWriterEntity>());
111 
112  void SetStructure(const ost::mol::EntityView& ent, conop::CompoundLibPtr compound_lib,
113  bool mmcif_conform=true,
114  const std::vector<MMCifWriterEntity>& entity_info=std::vector<MMCifWriterEntity>());
115 
116  const std::vector<MMCifWriterEntity>& GetEntities() const { return entity_info_; }
117 
118 private:
119 
120  void Setup();
121 
122  void Finalize(ost::conop::CompoundLibPtr compound_lib);
123 
124  std::vector<MMCifWriterEntity> entity_info_;
125  StarWriterLoopPtr atom_type_;
126  StarWriterLoopPtr atom_site_;
127  StarWriterLoopPtr pdbx_poly_seq_scheme_;
128  StarWriterLoopPtr entity_;
129  StarWriterLoopPtr struct_asym_;
130  StarWriterLoopPtr entity_poly_;
131  StarWriterLoopPtr entity_poly_seq_;
132  StarWriterLoopPtr chem_comp_;
133  StarWriterLoopPtr pdbx_entity_branch_;
134  bool structure_set_;
135 };
136 
137 }} // ns
138 
139 #endif
std::vector< String > asym_ids
Definition: mmcif_writer.hh:74
std::map< String, std::vector< String > > asym_alns
Definition: mmcif_writer.hh:95
std::string String
Definition: base.hh:54
bool operator!=(const MMCifWriterEntity &rhs) const
Definition: mmcif_writer.hh:60
Protein or molecule.
std::map< int, std::vector< String > > het
Definition: mmcif_writer.hh:98
tuple compound_lib
Definition: init.py:184
boost::shared_ptr< StarWriterLoop > StarWriterLoopPtr
Definition: star_writer.hh:79
void AddHet(int rnum, const String &mon_id)
Definition: mmcif_writer.hh:44
boost::shared_ptr< CompoundLib > CompoundLibPtr
Definition: compound_lib.hh:32
static MMCifWriterEntity FromPolymer(const String &entity_poly_type, const std::vector< String > &mon_ids, conop::CompoundLibPtr compound_lib)
std::vector< String > seq_can_olcs
Definition: mmcif_writer.hh:89
bool operator==(const MMCifWriterEntity &rhs) const
Definition: mmcif_writer.hh:48
#define DLLEXPORT_OST_IO
std::vector< String > mon_ids
Definition: mmcif_writer.hh:81
const std::vector< MMCifWriterEntity > & GetEntities() const
definition of EntityView
Definition: entity_view.hh:86
std::vector< String > seq_olcs
Definition: mmcif_writer.hh:85
int GetAsymIdx(const String &asym_id) const