Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openstructure
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
schwede
openstructure
Commits
89e5e6e7
Commit
89e5e6e7
authored
1 year ago
by
Studer Gabriel
Browse files
Options
Downloads
Patches
Plain Diff
mmcif writer: Make MMCifWriterEntity available from Python
Right now there is only a static constructor for polymer entities
parent
8f09787b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
modules/io/pymod/export_mmcif_io.cc
+12
-0
12 additions, 0 deletions
modules/io/pymod/export_mmcif_io.cc
modules/io/src/mol/mmcif_writer.cc
+48
-0
48 additions, 0 deletions
modules/io/src/mol/mmcif_writer.cc
modules/io/src/mol/mmcif_writer.hh
+7
-0
7 additions, 0 deletions
modules/io/src/mol/mmcif_writer.hh
with
67 additions
and
0 deletions
modules/io/pymod/export_mmcif_io.cc
+
12
−
0
View file @
89e5e6e7
...
...
@@ -147,6 +147,18 @@ void export_mmcif_io()
.
def
(
"Write"
,
&
WrapStarWriterWrite
,
(
arg
(
"data_name"
),
arg
(
"filename"
)))
;
class_
<
MMCifWriterEntity
>
(
"MMCifWriterEntity"
,
no_init
)
.
def
(
"FromPolymer"
,
&
MMCifWriterEntity
::
FromPolymer
).
staticmethod
(
"FromPolymer"
)
.
add_property
(
"type"
,
&
MMCifWriterEntity
::
type
)
.
add_property
(
"poly_type"
,
&
MMCifWriterEntity
::
poly_type
)
.
add_property
(
"branch_type"
,
&
MMCifWriterEntity
::
branch_type
)
.
add_property
(
"is_poly"
,
&
MMCifWriterEntity
::
is_poly
)
.
add_property
(
"mon_ids"
,
&
MMCifWriterEntity
::
mon_ids
)
.
add_property
(
"seq_olcs"
,
&
MMCifWriterEntity
::
seq_olcs
)
.
add_property
(
"seq_can_olcs"
,
&
MMCifWriterEntity
::
seq_can_olcs
)
.
add_property
(
"asym_ids"
,
&
MMCifWriterEntity
::
asym_ids
)
;
class_
<
MMCifWriter
,
bases
<
StarWriter
>
>
(
"MMCifWriter"
,
init
<>
())
.
def
(
"SetStructure"
,
&
WrapSetStructureHandle
,
(
arg
(
"ent"
),
arg
(
"mmcif_conform"
)
=
true
))
.
def
(
"SetStructure"
,
&
WrapSetStructureView
,
(
arg
(
"ent"
),
arg
(
"mmcif_conform"
)
=
true
))
...
...
This diff is collapsed.
Click to expand it.
modules/io/src/mol/mmcif_writer.cc
+
48
−
0
View file @
89e5e6e7
...
...
@@ -17,6 +17,8 @@
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//------------------------------------------------------------------------------
#include
<unordered_set>
#include
<ost/mol/chem_class.hh>
#include
<ost/io/mol/mmcif_writer.hh>
...
...
@@ -68,6 +70,26 @@ namespace {
std
::
vector
<
int
>
indices
;
};
void
CheckValidEntityPolyType
(
const
String
&
entity_poly_type
)
{
std
::
unordered_set
<
std
::
string
>
s
=
{
"other"
,
"polydeoxyribonucleotide"
,
"polypeptide(D)"
,
"polypeptide(L)"
,
"polyribonucleotide"
,
"polysaccharide(D)"
,
"polysaccharide(L)"
};
if
(
s
.
find
(
entity_poly_type
)
==
s
.
end
())
{
std
::
stringstream
ss
;
ss
<<
"Observed value is no valid entity_poly.type:
\"
"
;
ss
<<
entity_poly_type
<<
"
\"
. Allowed values: "
;
for
(
auto
type
:
s
)
{
ss
<<
type
<<
", "
;
}
String
err
=
ss
.
str
();
throw
ost
::
io
::
IOException
(
err
.
substr
(
0
,
err
.
size
()
-
2
));
}
}
// template to allow ost::mol::ResidueHandleList and ost::mol::ResidueViewList
template
<
class
T
>
String
GuessEntityPolyType
(
const
T
&
res_list
)
{
...
...
@@ -1395,6 +1417,32 @@ namespace {
namespace
ost
{
namespace
io
{
MMCifWriterEntity
MMCifWriterEntity
::
FromPolymer
(
const
String
&
entity_poly_type
,
const
std
::
vector
<
String
>&
mon_ids
,
conop
::
CompoundLibPtr
compound_lib
)
{
CheckValidEntityPolyType
(
entity_poly_type
);
MMCifWriterEntity
ent
;
ent
.
type
=
"polymer"
;
ent
.
is_poly
=
true
;
ent
.
poly_type
=
entity_poly_type
;
ent
.
branch_type
=
""
;
ent
.
mon_ids
=
mon_ids
;
for
(
auto
mon_id
:
mon_ids
)
{
// one letter codes rely on compound library
ost
::
conop
::
CompoundPtr
compound
=
compound_lib
->
FindCompound
(
mon_id
,
ost
::
conop
::
Compound
::
PDB
);
if
(
compound
)
{
char
chem_class
=
compound
->
GetChemClass
();
ent
.
seq_olcs
.
push_back
(
MonIDToOLC
(
chem_class
,
mon_id
));
ent
.
seq_can_olcs
.
push_back
(
String
(
1
,
compound
->
GetOneLetterCode
()));
}
else
{
ent
.
seq_olcs
.
push_back
(
"("
+
mon_id
+
")"
);
ent
.
seq_can_olcs
.
push_back
(
"("
+
mon_id
+
")"
);
}
}
return
ent
;
}
int
MMCifWriterEntity
::
GetAsymIdx
(
const
String
&
asym_id
)
const
{
for
(
size_t
i
=
0
;
i
<
asym_ids
.
size
();
++
i
)
{
if
(
asym_ids
[
i
]
==
asym_id
)
{
...
...
This diff is collapsed.
Click to expand it.
modules/io/src/mol/mmcif_writer.hh
+
7
−
0
View file @
89e5e6e7
...
...
@@ -22,6 +22,7 @@
#include
<fstream>
#include
<ost/mol/entity_handle.hh>
#include
<ost/conop/compound_lib.hh>
#include
<ost/io/mol/mmcif_info.hh>
#include
<ost/io/mol/io_profile.hh>
...
...
@@ -32,6 +33,12 @@ namespace ost { namespace io {
struct
MMCifWriterEntity
{
MMCifWriterEntity
()
{
}
static
MMCifWriterEntity
FromPolymer
(
const
String
&
entity_poly_type
,
const
std
::
vector
<
String
>&
mon_ids
,
conop
::
CompoundLibPtr
compound_lib
);
int
GetAsymIdx
(
const
String
&
asym_id
)
const
;
// _entity.type
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment