@@ -318,6 +318,57 @@ def testExplicitBondLengthRestraints(self):
318318
319319 return
320320
321+ def test_show_explicit_molecule_restraints (self , capturestdout ):
322+ # C1: A bond length, a bond angle and a dihedral angle restraint are
323+ # added through the ObjCrystMoleculeParSet.
324+ # Expected: The Restraints section lists each restraint by its atom
325+ # names with its target value, sigma, delta and scaling.
326+ cryst = ObjCrystCrystalParSet ("bucky" , self .occryst )
327+ molecule = cryst .c60
328+ atoms = molecule .atoms
329+ molecule .restrainBondLength (atoms [0 ], atoms [5 ], 3.3 , 0.1 , 0.2 )
330+ molecule .restrainBondAngle (atoms [0 ], atoms [5 ], atoms [7 ], 1.0 , 0.1 , 0.2 )
331+ molecule .restrainDihedralAngle (
332+ atoms [0 ], atoms [5 ], atoms [7 ], atoms [8 ], 2.0 , 0.1 , 0.2
333+ )
334+ lines = capturestdout (cryst .show , textwidth = 0 ).splitlines ()
335+ actual_restraint_lines = set (lines [lines .index ("Restraints" ) + 2 :])
336+ expected_restraint_lines = {
337+ "C0-C5: length = 3.300000, sigma = 0.100000, delta = 0.200000, "
338+ "scaled = False" ,
339+ "C0-C5-C7: angle = 1.000000, sigma = 0.100000, delta = 0.200000, "
340+ "scaled = False" ,
341+ "C0-C5-C7-C8: angle = 2.000000, sigma = 0.100000, "
342+ "delta = 0.200000, scaled = False" ,
343+ }
344+ assert actual_restraint_lines == expected_restraint_lines
345+
346+ def test_show_implicit_molecule_restraints (self , capturestdout ):
347+ # C1: A bond length, a bond angle and a dihedral angle restraint are
348+ # defined on the pyobjcryst Molecule and wrapped with
349+ # wrapRestraints.
350+ # Expected: The Restraints section lists each restraint by its atom
351+ # names with its target value, sigma, delta and scaling.
352+ ocmol = self .ocmol
353+ ocmol .AddBond (ocmol [0 ], ocmol [5 ], 3.3 , 0.1 , 0.2 )
354+ ocmol .AddBondAngle (ocmol [0 ], ocmol [5 ], ocmol [7 ], 1.0 , 0.1 , 0.2 )
355+ ocmol .AddDihedralAngle (
356+ ocmol [0 ], ocmol [5 ], ocmol [7 ], ocmol [8 ], 2.0 , 0.1 , 0.2
357+ )
358+ cryst = ObjCrystCrystalParSet ("bucky" , self .occryst )
359+ cryst .c60 .wrapRestraints ()
360+ lines = capturestdout (cryst .show , textwidth = 0 ).splitlines ()
361+ actual_restraint_lines = set (lines [lines .index ("Restraints" ) + 2 :])
362+ expected_restraint_lines = {
363+ "C0-C5: length = 3.300000, sigma = 0.100000, delta = 0.200000, "
364+ "scaled = False" ,
365+ "C0-C5-C7: angle = 1.000000, sigma = 0.100000, delta = 0.200000, "
366+ "scaled = False" ,
367+ "C0-C5-C7-C8: angle = 2.000000, sigma = 0.100000, "
368+ "delta = 0.200000, scaled = False" ,
369+ }
370+ assert actual_restraint_lines == expected_restraint_lines
371+
321372 def testExplicitBondAngleRestraints (self ):
322373 """Test the structure with explicit bond angles.
323374
0 commit comments