@@ -476,7 +476,7 @@ def setUp(self):
476476 dtype = np .float32 )
477477
478478
479- class TestDCDWriteRandom ( ):
479+ class _TestDCDWriteRandom ( object ):
480480 # should only be supported for Charmm24 format writing (for now)
481481
482482 def setUp (self ):
@@ -489,15 +489,19 @@ def setUp(self):
489489 self .expected_remarks = '''* DIMS ADK SEQUENCE FOR PORE PROGRAM * WRITTEN BY LIZ DENNING (6.2008) * DATE: 6/ 6/ 8 17:23:56 CREATED BY USER: denniej0 '''
490490
491491 np .random .seed (1178083 )
492- self .random_unitcells = np .random .random ((self .expected_frames , 6 )).astype (np .float64 )
492+ if self .charmm :
493+ self .random_unitcells = np .random .random ((self .expected_frames , 6 )).astype (np .float64 )
494+ else :
495+ self .random_unitcells = np .random .uniform (high = 80 ,size = (self .expected_frames , 6 )).astype (np .float64 )
496+
493497 with DCDFile (self .readfile ) as f_in , DCDFile (self .testfile , 'w' ) as f_out :
494498 for index , frame in enumerate (f_in ):
495499 box = frame .unitcell .astype (np .float64 )
496500 f_out .write (xyz = frame .x ,
497501 box = self .random_unitcells [index ],
498502 step = f_in .istart ,
499503 natoms = frame .x .shape [0 ],
500- charmm = 1 , # DCD should be CHARMM
504+ charmm = self . charmm , # DCD should be CHARMM
501505 time_step = f_in .delta ,
502506 ts_between_saves = f_in .nsavc ,
503507 remarks = f_in .remarks )
@@ -521,17 +525,25 @@ def test_written_unit_cell_random(self):
521525 while curr_frame < test .n_frames :
522526 written_unitcell = test .read ()[1 ]
523527 ref_unitcell = self .random_unitcells [curr_frame ]
524- ref_unitcell [1 ] = math .degrees (math .acos (ref_unitcell [1 ]))
525- ref_unitcell [3 ] = math .degrees (math .acos (ref_unitcell [3 ]))
526- ref_unitcell [4 ] = math .degrees (math .acos (ref_unitcell [4 ]))
528+ if self .charmm :
529+ ref_unitcell [1 ] = math .degrees (math .acos (ref_unitcell [1 ]))
530+ ref_unitcell [3 ] = math .degrees (math .acos (ref_unitcell [3 ]))
531+ ref_unitcell [4 ] = math .degrees (math .acos (ref_unitcell [4 ]))
527532
528- _ts_order = [0 , 2 , 5 , 4 , 3 , 1 ]
529- ref_unitcell = np .take (ref_unitcell , _ts_order )
533+ _ts_order = [0 , 2 , 5 , 4 , 3 , 1 ]
534+ ref_unitcell = np .take (ref_unitcell , _ts_order )
530535 curr_frame += 1
531536 assert_allclose (written_unitcell , ref_unitcell ,
532537 rtol = 1e-05 )
533538
534539
540+ class TestRandomUnitCellCHARMM (_TestDCDWriteRandom ):
541+ charmm = 1
542+
543+ class TestRandomUnitCellNAMD (_TestDCDWriteRandom ):
544+ charmm = 0
545+
546+
535547class TestDCDByteArithmetic (object ):
536548
537549 def setUp (self ):
0 commit comments