1010import freud
1111import gsd .hoomd
1212import numpy as np
13- from cmeutils .gsd_utils import identify_snapshot_connections
13+ from cmeutils .gsd_utils import get_molecule_cluster , identify_snapshot_connections
1414from ele import element_from_symbol
1515from mbuild import Compound , clone
1616from mbuild .utils .io import run_from_ipython
2424 get_quaternion ,
2525 has_common_member ,
2626 has_number ,
27- snap_molecules ,
2827)
2928
3029__all__ = ["CG_Compound" , "CG_System" , "Bead" ]
@@ -362,7 +361,7 @@ def visualize(
362361 if atom_names :
363362 atomistic .save (
364363 os .path .join (tmp_dir , "atomistic_tmp.mol2" ),
365- show_ports = show_ports ,
364+ include_ports = show_ports ,
366365 overwrite = True ,
367366 )
368367
@@ -397,7 +396,7 @@ def visualize(
397396 simplefilter ("ignore" )
398397 coarse .save (
399398 os .path .join (tmp_dir , "coarse_tmp.mol2" ),
400- show_ports = show_ports ,
399+ include_ports = show_ports ,
401400 overwrite = True ,
402401 )
403402 with open (os .path .join (tmp_dir , "coarse_tmp.mol2" ), "r" ) as f :
@@ -574,7 +573,7 @@ def _get_compounds(
574573 conversion_dict [i ].symbol for i in snap .particles .types
575574 ]
576575 # Break apart the snapshot into separate molecules
577- molecules = snap_molecules ( snap )
576+ molecules = get_molecule_cluster ( snap = snap )
578577 mol_inds = []
579578 for i in range (max (molecules ) + 1 ):
580579 mol_inds .append (np .where (molecules == i )[0 ])
@@ -667,7 +666,7 @@ def save_mapping(self, filename):
667666 json .dump (self .mapping , f , cls = NumpyEncoder )
668667 print (f"Mapping saved to { filename } " )
669668
670- def save (self , cg_gsdfile , start = 0 , stop = None ):
669+ def save (self , cg_gsdfile , start = 0 , stop = None , stride = 1 ):
671670 """Save the coarse-grain system to a gsd file.
672671
673672 Does not calculate the image of the coarse-grain bead.
@@ -688,6 +687,8 @@ def save(self, cg_gsdfile, start=0, stop=None):
688687 stop : int, default None
689688 Where to stop reading the gsd trajectory the system was created
690689 with. If None, will stop at the last frame.
690+ stride : int, default 1
691+ The step size to use when iterating through start:stop
691692 """
692693 typeid = []
693694 types = [i .split ("..." )[0 ] for i in self .mapping ]
@@ -722,7 +723,7 @@ def save(self, cg_gsdfile, start=0, stop=None):
722723 ) as old :
723724 # stop being None is fine; slicing [0:None] gives whole array,
724725 # even in edge case where there's only one or two frames
725- for s in old [start :stop ]:
726+ for s in old [start :stop : stride ]:
726727 new_snap = gsd .hoomd .Frame ()
727728 position = []
728729 mass = []
0 commit comments