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
eaa33ff4
Commit
eaa33ff4
authored
7 years ago
by
Rafal Gumienny
Browse files
Options
Downloads
Patches
Plain Diff
feat: SCHWED-3126 Expose Molck and MolckSettings to python
parent
70d09c52
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/mol/alg/pymod/export_molck.cc
+98
-3
98 additions, 3 deletions
modules/mol/alg/pymod/export_molck.cc
modules/mol/alg/src/molck.hh
+42
-0
42 additions, 0 deletions
modules/mol/alg/src/molck.hh
with
140 additions
and
3 deletions
modules/mol/alg/pymod/export_molck.cc
+
98
−
3
View file @
eaa33ff4
...
...
@@ -16,14 +16,109 @@
// along with this library; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//------------------------------------------------------------------------------
#include
<stdexcept>
#include
<boost/python.hpp>
#include
<boost/python/raw_function.hpp>
using
namespace
boost
::
python
;
#include
<ost/mol/alg/molck.hh>
using
namespace
ost
::
mol
::
alg
;
namespace
{
object
MolckSettingsInitWrapper
(
tuple
args
,
dict
kwargs
){
object
self
=
args
[
0
];
args
=
tuple
(
args
.
slice
(
1
,
_
));
bool
rm_unk_atoms
=
false
;
if
(
kwargs
.
contains
(
"rm_unk_atoms"
)){
rm_unk_atoms
=
extract
<
bool
>
(
kwargs
[
"rm_unk_atoms"
]);
kwargs
[
"rm_unk_atoms"
].
del
();
}
bool
rm_non_std
=
false
;
if
(
kwargs
.
contains
(
"rm_non_std"
)){
rm_non_std
=
extract
<
bool
>
(
kwargs
[
"rm_non_std"
]);
kwargs
[
"rm_non_std"
].
del
();
}
bool
rm_hyd_atoms
=
true
;
if
(
kwargs
.
contains
(
"rm_hyd_atoms"
)){
rm_hyd_atoms
=
extract
<
bool
>
(
kwargs
[
"rm_hyd_atoms"
]);
kwargs
[
"rm_hyd_atoms"
].
del
();
}
bool
rm_oxt_atoms
=
false
;
if
(
kwargs
.
contains
(
"rm_oxt_atoms"
)){
rm_oxt_atoms
=
extract
<
bool
>
(
kwargs
[
"rm_oxt_atoms"
]);
kwargs
[
"rm_oxt_atoms"
].
del
();
}
bool
rm_zero_occ_atoms
=
false
;
if
(
kwargs
.
contains
(
"rm_zero_occ_atoms"
)){
rm_zero_occ_atoms
=
extract
<
bool
>
(
kwargs
[
"rm_zero_occ_atoms"
]);
kwargs
[
"rm_zero_occ_atoms"
].
del
();
}
bool
colored
=
false
;
if
(
kwargs
.
contains
(
"colored"
)){
colored
=
extract
<
bool
>
(
kwargs
[
"colored"
]);
kwargs
[
"colored"
].
del
();
}
bool
map_nonstd_res
=
true
;
if
(
kwargs
.
contains
(
"map_nonstd_res"
)){
map_nonstd_res
=
extract
<
bool
>
(
kwargs
[
"map_nonstd_res"
]);
kwargs
[
"map_nonstd_res"
].
del
();
}
bool
assign_elem
=
true
;
if
(
kwargs
.
contains
(
"assign_elem"
)){
assign_elem
=
extract
<
bool
>
(
kwargs
[
"assign_elem"
]);
kwargs
[
"assign_elem"
].
del
();
}
if
(
len
(
kwargs
)
>
0
){
std
::
stringstream
ss
;
ss
<<
"Invalid keywords observed when setting up MolckSettings! "
;
ss
<<
"Or did you pass the same keyword twice? "
;
ss
<<
"Valid keywords are: rm_unk_atoms, rm_non_std, rm_hyd_atoms, "
;
ss
<<
"rm_oxt_atoms, rm_zero_occ_atoms, colored, map_nonstd_res, "
;
ss
<<
"assign_elem!"
;
throw
std
::
invalid_argument
(
ss
.
str
());
}
return
self
.
attr
(
"__init__"
)(
rm_unk_atoms
,
rm_non_std
,
rm_hyd_atoms
,
rm_oxt_atoms
,
rm_zero_occ_atoms
,
colored
,
map_nonstd_res
,
assign_elem
);
}}
void
export_Molck
()
{
// def("load_compound_lib", &ost::mol::alg::load_compound_lib,
// (arg("custom_path")));
}
class_
<
MolckSettings
>
(
"MolckSettings"
,
no_init
)
.
def
(
"__init__"
,
raw_function
(
MolckSettingsInitWrapper
))
.
def
(
init
<
bool
,
bool
,
bool
,
bool
,
bool
,
bool
,
bool
,
bool
>
())
.
def
(
"ToString"
,
&
MolckSettings
::
ToString
)
.
def
(
"__repr__"
,
&
MolckSettings
::
ToString
)
.
def
(
"__str__"
,
&
MolckSettings
::
ToString
)
.
def_readwrite
(
"rm_unk_atoms"
,
&
MolckSettings
::
rm_unk_atoms
)
.
def_readwrite
(
"rm_non_std"
,
&
MolckSettings
::
rm_non_std
)
.
def_readwrite
(
"rm_hyd_atoms"
,
&
MolckSettings
::
rm_hyd_atoms
)
.
def_readwrite
(
"rm_oxt_atoms"
,
&
MolckSettings
::
rm_oxt_atoms
)
.
def_readwrite
(
"rm_zero_occ_atoms"
,
&
MolckSettings
::
rm_zero_occ_atoms
)
.
def_readwrite
(
"colored"
,
&
MolckSettings
::
colored
)
.
def_readwrite
(
"map_nonstd_res"
,
&
MolckSettings
::
map_nonstd_res
)
.
def_readwrite
(
"assign_elem"
,
&
MolckSettings
::
assign_elem
)
;
def
(
"Molck"
,
&
Molck
,
(
arg
(
"ent"
),
arg
(
"lib"
),
arg
(
"settings"
)));
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
modules/mol/alg/src/molck.hh
+
42
−
0
View file @
eaa33ff4
#include
<string>
#include
<ost/mol/entity_handle.hh>
#include
<ost/conop/compound_lib.hh>
namespace
{
inline
std
::
string
BoolToString
(
bool
b
)
{
return
b
?
"True"
:
"False"
;
}
}
namespace
ost
{
namespace
mol
{
namespace
alg
{
struct
MolckSettings
;
...
...
@@ -25,6 +34,39 @@ struct MolckSettings{
map_nonstd_res
(
true
),
// Map non standard residues back to standard ones (e.g.: MSE->MET,SEP->SER,etc.)
assign_elem
(
true
){}
// Clean up element column
MolckSettings
(
bool
init_rm_unk_atoms
,
bool
init_rm_non_std
,
bool
init_rm_hyd_atoms
,
bool
init_rm_oxt_atoms
,
bool
init_rm_zero_occ_atoms
,
bool
init_colored
,
bool
init_map_nonstd_res
,
bool
init_assign_elem
){
rm_unk_atoms
=
init_rm_unk_atoms
;
rm_non_std
=
init_rm_non_std
;
rm_hyd_atoms
=
init_rm_hyd_atoms
;
rm_oxt_atoms
=
init_rm_oxt_atoms
;
rm_zero_occ_atoms
=
init_rm_zero_occ_atoms
;
colored
=
init_colored
;
map_nonstd_res
=
init_map_nonstd_res
;
assign_elem
=
init_assign_elem
;
}
public
:
std
::
string
ToString
(){
std
::
string
rep
=
"MolckSettings(rm_unk_atoms="
+
BoolToString
(
rm_unk_atoms
)
+
", rm_unk_atoms="
+
BoolToString
(
rm_unk_atoms
)
+
", rm_non_std="
+
BoolToString
(
rm_non_std
)
+
", rm_hyd_atoms="
+
BoolToString
(
rm_hyd_atoms
)
+
", rm_oxt_atoms="
+
BoolToString
(
rm_oxt_atoms
)
+
", rm_zero_occ_atoms="
+
BoolToString
(
rm_zero_occ_atoms
)
+
", colored="
+
BoolToString
(
colored
)
+
", map_nonstd_res="
+
BoolToString
(
map_nonstd_res
)
+
", assign_elem="
+
BoolToString
(
assign_elem
)
+
")"
;
return
rep
;
}
};
ost
::
mol
::
EntityHandle
MapNonStandardResidues
(
ost
::
mol
::
EntityHandle
&
ent
,
...
...
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