Skip to content
Snippets Groups Projects
Commit 636b6945 authored by Studer Gabriel's avatar Studer Gabriel
Browse files

Implement deep copy function in BackboneList

The reason for that is a bug we observed when Python uses
reference assignments of BackboneLists.
parent 93eef9bf
Branches
Tags
No related merge requests found
...@@ -299,6 +299,12 @@ The BackboneList class ...@@ -299,6 +299,12 @@ The BackboneList class
Remove all residues from this list. Remove all residues from this list.
.. method:: Copy()
Creates and returns a deep copy of this :class:`BackboneList`. This can be
useful, since Python uses reference assignments.
:rtype: :class:`BackboneList`
.. method:: ReconstructCBetaPositions() .. method:: ReconstructCBetaPositions()
... ...
......
...@@ -66,6 +66,11 @@ BackboneListPtr FullInitWrapperRHList(const String& sequence, ...@@ -66,6 +66,11 @@ BackboneListPtr FullInitWrapperRHList(const String& sequence,
return p; return p;
} }
BackboneListPtr WrapCopy(BackboneListPtr p){
BackboneListPtr return_p(new BackboneList(*p));
return return_p;
}
void InsertInto_int(BackboneListPtr p, ost::mol::ChainHandle& chain, void InsertInto_int(BackboneListPtr p, ost::mol::ChainHandle& chain,
uint start_resnum) { uint start_resnum) {
p->InsertInto(chain, start_resnum); p->InsertInto(chain, start_resnum);
...@@ -156,6 +161,7 @@ void export_Backbone() { ...@@ -156,6 +161,7 @@ void export_Backbone() {
.def(init<const String&>()) .def(init<const String&>())
.def("__init__", make_constructor(&FullInitWrapper)) .def("__init__", make_constructor(&FullInitWrapper))
.def("__init__", make_constructor(&FullInitWrapperRHList)) .def("__init__", make_constructor(&FullInitWrapperRHList))
.def("Copy", &WrapCopy)
.def("ToDensity", &BackboneList::ToDensity, .def("ToDensity", &BackboneList::ToDensity,
(arg("padding")=10.0, arg("sampling")=geom::Vec3(1.0,1.0,1.0), (arg("padding")=10.0, arg("sampling")=geom::Vec3(1.0,1.0,1.0),
... ...
......
...@@ -160,7 +160,7 @@ def _CloseLoopFrame(mhandle, gap_orig, actual_candidates, actual_extended_gaps, ...@@ -160,7 +160,7 @@ def _CloseLoopFrame(mhandle, gap_orig, actual_candidates, actual_extended_gaps,
start_index = actual_extended_gaps[i].before.GetNumber().GetNum()\ start_index = actual_extended_gaps[i].before.GetNumber().GetNum()\
- min_before_resnum - min_before_resnum
for j, loop_candidate in enumerate(loop_candidates): for j, loop_candidate in enumerate(loop_candidates):
actual_frame_backbone_list = frame_backbone_list actual_frame_backbone_list = frame_backbone_list.Copy()
actual_frame_backbone_list.ReplaceFragment( actual_frame_backbone_list.ReplaceFragment(
loop_candidate, start_index, False) loop_candidate, start_index, False)
final_loop_candidates.Add(actual_frame_backbone_list) final_loop_candidates.Add(actual_frame_backbone_list)
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment