OpenStructure
Loading...
Searching...
No Matches
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
26
27#include <ost/io/mol/omf.hh>
31
32namespace ost { namespace io {
33
34// generates as many chain names as you want (potentially multiple characters)
46
48
50
51 static MMCifWriterEntity FromPolymer(const String& entity_poly_type,
52 const std::vector<String>& mon_ids,
53 conop::CompoundLibPtr compound_lib);
54
55 int GetAsymIdx(const String& asym_id) const;
56
57 void AddHet(int rnum, const String& mon_id) {
58 het[rnum].push_back(mon_id);
59 }
60
61 bool operator==(const MMCifWriterEntity& rhs) const {
62 return (type == rhs.type)
63 && (poly_type == rhs.poly_type)
64 && (branch_type == rhs.branch_type)
65 && (asym_ids == rhs.asym_ids)
66 && (is_poly == rhs.is_poly)
67 && (mon_ids == rhs.mon_ids)
68 && (seq_olcs == rhs.seq_olcs)
69 && (seq_can_olcs == rhs.seq_can_olcs)
70 && (asym_alns == rhs.asym_alns);
71 }
72
73 bool operator!=(const MMCifWriterEntity& rhs) const {
74 return !(*this == rhs);
75 }
76
77 // _entity.type
79
80 // _entity_poly.type
82
83 // __pdbx_entity_branch.type
85
86 // Names of chains in AU that are assigned to this entity
87 std::vector<String> asym_ids;
88
89 // in principle type == "polymer"
90 bool is_poly;
91
92 // SEQRES... kind of... internally we're not working on one letter codes
93 // etc. but on full compound names. Only one element if is_poly is false.
94 std::vector<String> mon_ids;
95
96 // The respective strings for pdbx_seq_one_letter_code
97 // Irrelevant if is_poly is false.
98 std::vector<String> seq_olcs;
99
100 // same for pdbx_seq_one_letter_code_can
101 // Irrelevant if is_poly is false.
102 std::vector<String> seq_can_olcs;
103
104 // One alignment to mon_ids for each element in asym_ids, i.e. SEQRES-ATOMSEQ
105 // alignment. Contains "-" for residues that are missing in ATOMSEQ.
106 // irrelevant if is_poly is false. The assumption is that aligned residues
107 // exactly match with the respective position in mon_ids.
108 std::map<String, std::vector<String> > asym_alns;
109
110 // heterogeneities
111 std::map<int, std::vector<String> > het;
112};
113
115public:
116
117 MMCifWriter(): structure_set_(false) { }
118
119 virtual ~MMCifWriter() { }
120
122 bool mmcif_conform=true,
123 const std::vector<MMCifWriterEntity>& entity_info=std::vector<MMCifWriterEntity>());
124
126 bool mmcif_conform=true,
127 const std::vector<MMCifWriterEntity>& entity_info=std::vector<MMCifWriterEntity>());
128
129 void SetStructure(const ost::io::OMF& ent, conop::CompoundLibPtr compound_lib,
130 bool mmcif_conform=true,
131 const std::vector<MMCifWriterEntity>& entity_info=std::vector<MMCifWriterEntity>());
132
133 const std::vector<MMCifWriterEntity>& GetEntities() const { return entity_info_; }
134
135private:
136
137 void Setup();
138
139 void Finalize(ost::conop::CompoundLibPtr compound_lib);
140
141 std::vector<MMCifWriterEntity> entity_info_;
142 StarWriterLoopPtr atom_type_;
143 StarWriterLoopPtr atom_site_;
144 StarWriterLoopPtr pdbx_poly_seq_scheme_;
145 StarWriterLoopPtr entity_;
146 StarWriterLoopPtr struct_asym_;
147 StarWriterLoopPtr entity_poly_;
148 StarWriterLoopPtr entity_poly_seq_;
149 StarWriterLoopPtr chem_comp_;
150 StarWriterLoopPtr pdbx_entity_branch_;
151 bool structure_set_;
152};
153
154}} // ns
155
156#endif
void SetStructure(const ost::mol::EntityHandle &ent, conop::CompoundLibPtr compound_lib, bool mmcif_conform=true, const std::vector< MMCifWriterEntity > &entity_info=std::vector< MMCifWriterEntity >())
void SetStructure(const ost::io::OMF &ent, conop::CompoundLibPtr compound_lib, bool mmcif_conform=true, const std::vector< MMCifWriterEntity > &entity_info=std::vector< MMCifWriterEntity >())
void SetStructure(const ost::mol::EntityView &ent, conop::CompoundLibPtr compound_lib, bool mmcif_conform=true, const std::vector< MMCifWriterEntity > &entity_info=std::vector< MMCifWriterEntity >())
const std::vector< MMCifWriterEntity > & GetEntities() const
Protein or molecule.
definition of EntityView
#define DLLEXPORT_OST_IO
std::string String
Definition base.hh:54
boost::shared_ptr< CompoundLib > CompoundLibPtr
boost::shared_ptr< StarWriterLoop > StarWriterLoopPtr
Definition base.dox:1
std::vector< int > indices
std::vector< String > asym_ids
void AddHet(int rnum, const String &mon_id)
std::vector< String > seq_olcs
int GetAsymIdx(const String &asym_id) const
std::map< int, std::vector< String > > het
std::map< String, std::vector< String > > asym_alns
bool operator==(const MMCifWriterEntity &rhs) const
static MMCifWriterEntity FromPolymer(const String &entity_poly_type, const std::vector< String > &mon_ids, conop::CompoundLibPtr compound_lib)
bool operator!=(const MMCifWriterEntity &rhs) const
std::vector< String > mon_ids
std::vector< String > seq_can_olcs