Skip to content

Commit e29c49b

Browse files
committed
Add int_ptr property to RefinableObj, Mol{Atom, Bond, DihedralAngle}, RigidGroup to be able to test the identity between python objects.
Crystal: add _display_list() function to generate a list of atoms and bonds for display. Update the 3D view accordingly, so bonds are not broken anymore. Fixes vincefn#2. MonteCarlo: add basic widget to display the current LLK, run and trial number. Allow to disable UpdateDisplay (useful if not in the main process when using multiprocessing). RefinableObj.XMLInput() : allow input directly from an XML string, without requiring the initial tag. Add an example notebook using multiprocessing to automatically test multiple spacegroups (while adapting to the multiplicity).
1 parent 4052d4c commit e29c49b

13 files changed

+3614
-1118
lines changed

examples/cimetidine-structure-solution-powder.ipynb

Lines changed: 512 additions & 1032 deletions
Large diffs are not rendered by default.

examples/crystal_3d_widget.ipynb

Lines changed: 191 additions & 40 deletions
Large diffs are not rendered by default.

examples/structure-solution-multiprocessing.ipynb

Lines changed: 2560 additions & 0 deletions
Large diffs are not rendered by default.

src/extensions/molatom_ext.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,5 +90,6 @@ void wrap_molatom()
9090
.add_property("Occupancy", &MolAtom::GetOccupancy,
9191
&MolAtom::SetOccupancy)
9292
.def("__str__", &__str__)
93+
.def("int_ptr", &MolAtom::int_ptr)
9394
;
9495
}

src/extensions/molbond_ext.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,6 @@ void wrap_molbond()
103103
&MolBond::SetBondOrder)
104104
.def("__getitem__", &_GetAtom,
105105
return_internal_reference<>())
106+
.def("int_ptr", &MolBond::int_ptr)
106107
;
107108
}

src/extensions/molbondangle_ext.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,5 +110,6 @@ void wrap_molbondangle()
110110
// Iterate other the atoms involved
111111
.def("__iter__", range<return_value_policy<reference_existing_object> >
112112
(&MolBondAngle::begin, &MolBondAngle::end))
113+
.def("int_ptr", &MolBondAngle::int_ptr)
113114
;
114115
}

src/extensions/moldihedralangle_ext.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,5 +113,6 @@ void wrap_moldihedralangle()
113113
// Iterate other the atoms involved
114114
.def("__iter__", range<return_value_policy<reference_existing_object> >
115115
(&MolDihedralAngle::begin, &MolDihedralAngle::end))
116+
.def("int_ptr", &MolDihedralAngle::int_ptr)
116117
;
117118
}

src/extensions/refinableobj_ext.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <boost/python/copy_const_reference.hpp>
3838

3939
#include <string>
40+
#include <sstream>
4041
#include <map>
4142

4243
#include <ObjCryst/RefinableObj/RefinableObj.h>
@@ -404,6 +405,15 @@ void _XMLInput(
404405
in.sync();
405406
}
406407

408+
void _XMLInputString(RefinableObj& r, const string& s)
409+
{
410+
stringstream ss(s);
411+
ss.imbue(std::locale::classic());
412+
XMLCrystTag tag;
413+
ss>>tag;
414+
r.XMLInput(ss, tag);
415+
}
416+
407417
} // anonymous namespace
408418

409419

@@ -555,6 +565,7 @@ void wrap_refinableobj()
555565
.def("XMLInput", &_XMLInput, (bp::arg("file"), bp::arg("tag")))
556566
.def("XMLInput", &RefinableObj::XMLInput,
557567
&RefinableObjWrap::default_XMLInput)
568+
.def("XMLInput", &_XMLInputString, (bp::arg("xml")))
558569
.def("GetGeneGroup", &RefinableObj::GetGeneGroup,
559570
&RefinableObjWrap::default_GetGeneGroup)
560571
.def("UpdateDisplay", &RefinableObj::UpdateDisplay,
@@ -563,6 +574,7 @@ void wrap_refinableobj()
563574
&RefinableObjWrap::default_GetRestraintCost)
564575
.def("TagNewBestConfig", &RefinableObj::TagNewBestConfig,
565576
&RefinableObjWrap::default_TagNewBestConfig)
577+
.def("int_ptr", &RefinableObj::int_ptr)
566578
// Additional methods for python only
567579
.def("__str__", &__str__<RefinableObj>)
568580
;

src/extensions/rigidgroup_ext.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,6 @@ void wrap_rigidgroup()
4444
class_<RigidGroup, bases<MolAtomSet> >("RigidGroup")
4545
.def(init<const RigidGroup&>())
4646
.def("GetName", &RigidGroup::GetName)
47+
.def("int_ptr", &RigidGroup::int_ptr)
4748
;
4849
}

src/pyobjcryst/crystal.py

Lines changed: 262 additions & 31 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)