simulariumio/mcell/mcell_converter.py
def _count_agents_in_binary_cellblender_viz_frame(file_name: str) -> int:
        """
        Count the number of agents in the frame of cellblender data
        """
        total_mols = 0
        with open(file_name, "rb") as mol_file:
            # first 4 bytes must contain value '1'
            b = array.array("I")
            b.fromfile(mol_file, 1)
            assert b[0] == 1
            while True:
                try:
                    # advance through file to get
                    # number of instances of each molecule type
                    n_chars_type_name = array.array("B")
                    n_chars_type_name.fromfile(mol_file, 1)
                    mol_file.seek(n_chars_type_name[0], os.SEEK_CUR)
                    is_surface_mol = array.array("B")
                    is_surface_mol.fromfile(mol_file, 1)
                    is_surface_mol = is_surface_mol[0] == 1
                    n_data = array.array("I")
                    n_data.fromfile(mol_file, 1)
                    n_data = n_data[0]
                    data = array.array("f")
                    data.fromfile(mol_file, n_data)
                    if is_surface_mol:
                        data.fromfile(mol_file, n_data)
                    total_mols += int(n_data / 3.0)
                except EOFError:
                    mol_file.close()
                    break
        return total_mols

        Count the number of agents in the frame of cellblender data
        
Count the number of agents in the frame of cellblender data
Count the number of agents in the frame of cellblender data
def _count_agents_in_binary_cellblender_viz_frame(file_name: str) -> int:
        total_mols = 0
        with open(file_name, "rb") as mol_file:
            b = array.array("I")
            b.fromfile(mol_file, 1)
            assert b[0] == 1
            while True:
                try:
                    n_chars_type_name = array.array("B")
                    n_chars_type_name.fromfile(mol_file, 1)
                    mol_file.seek(n_chars_type_name[0], os.SEEK_CUR)
                    is_surface_mol = array.array("B")
                    is_surface_mol.fromfile(mol_file, 1)
                    is_surface_mol = is_surface_mol[0] == 1
                    n_data = array.array("I")
                    n_data.fromfile(mol_file, 1)
                    n_data = n_data[0]
                    data = array.array("f")
                    data.fromfile(mol_file, n_data)
                    if is_surface_mol:
                        data.fromfile(mol_file, n_data)
                    total_mols += int(n_data / 3.0)
                except EOFError:
                    mol_file.close()
                    break
        return total_mols
def _count_agents_in_binary_cellblender_viz_frame ( file_name : str ) -> int : total_mols = 0 with open ( file_name , "rb" ) as mol_file : b = array . array ( "I" ) b . fromfile ( mol_file , 1 ) assert b [ 0 ] == 1 while True : try : n_chars_type_name = array . array ( "B" ) n_chars_type_name . fromfile ( mol_file , 1 ) mol_file . seek ( n_chars_type_name [ 0 ] , os . SEEK_CUR ) is_surface_mol = array . array ( "B" ) is_surface_mol . fromfile ( mol_file , 1 ) is_surface_mol = is_surface_mol [ 0 ] == 1 n_data = array . array ( "I" ) n_data . fromfile ( mol_file , 1 ) n_data = n_data [ 0 ] data = array . array ( "f" ) data . fromfile ( mol_file , n_data ) if is_surface_mol : data . fromfile ( mol_file , n_data ) total_mols += int ( n_data / 3.0 ) except EOFError : mol_file . close ( ) break return total_mols
Count the number of agents in the frame of cellblender data
Count the number of agents in the frame of cellblender data
"""
        Count the number of agents in the frame of cellblender data
        """ # first 4 bytes must contain value '1' # advance through file to get # number of instances of each molecule type
file_name
str