예제 #1
0
def add_cell(bioexplorer, name, size, height, position=Vector3()):
    ace2_receptor = Protein(sources=[PDB_FOLDER + '6m18.pdb'],
                            occurences=20,
                            position=Vector3(0.0, 6.0, 0.0))
    membrane = ParametricMembrane(sources=[
        MEMBRANE_FOLDER + 'segA.pdb', MEMBRANE_FOLDER + 'segB.pdb',
        MEMBRANE_FOLDER + 'segC.pdb', MEMBRANE_FOLDER + 'segD.pdb'
    ],
                                  occurences=1200000)
    cell = Cell(name=name,
                size=size,
                shape=bioexplorer.ASSEMBLY_SHAPE_SINUSOIDAL,
                membrane=membrane,
                receptor=ace2_receptor,
                extra_parameters=[height],
                random_position_seed=1,
                random_position_strength=0.025,
                random_rotation_seed=2,
                random_rotation_strength=2.0)
    bioexplorer.add_cell(cell=cell,
                         position=position,
                         representation=PROTEIN_REPRESENTATION)

    if ADD_GLYCANS:
        bioexplorer.add_multiple_glycans(
            representation=PROTEIN_REPRESENTATION,
            assembly_name=name,
            glycan_type=bioexplorer.NAME_GLYCAN_COMPLEX,
            protein_name=bioexplorer.NAME_RECEPTOR,
            paths=COMPLEX_PATHS,
            indices=[53, 90, 103, 322, 432, 690])
        bioexplorer.add_multiple_glycans(
            representation=PROTEIN_REPRESENTATION,
            assembly_name=name,
            glycan_type=bioexplorer.NAME_GLYCAN_HYBRID,
            protein_name=bioexplorer.NAME_RECEPTOR,
            paths=HYBRID_PATHS,
            indices=[546])

        indices = [[155, Quaternion(0.707, 0.0, 0.707, 0.0)],
                   [730, Quaternion(0.707, 0.0, 0.707, 0.0)]]
        for index in indices:
            o_glycan_name = name + '_' + bioexplorer.NAME_GLYCAN_O_GLYCAN + '_' + str(
                index[0])
            o_glycan = Sugars(assembly_name=name,
                              name=o_glycan_name,
                              source=O_GLYCAN_PATHS[0],
                              protein_name=name + '_' +
                              bioexplorer.NAME_RECEPTOR,
                              representation=PROTEIN_REPRESENTATION,
                              chain_ids=[2, 4],
                              site_indices=[index[0]],
                              rotation=index[1])
            bioexplorer.add_sugars(o_glycan)
예제 #2
0
def test_cell():
    resource_folder = 'tests/test_files/'
    pdb_folder = resource_folder + 'pdb/'

    bio_explorer = BioExplorer('localhost:5000')
    bio_explorer.reset()

    # Suspend image streaming
    bio_explorer.core_api().set_application_parameters(image_stream_fps=0)

    # Proteins
    protein_representation = bio_explorer.REPRESENTATION_ATOMS

    # Membrane parameters
    membrane_size = 800.0
    membrane_height = 80
    membrane_nb_receptors = 20
    membrane_nb_lipids = 1200000

    # ACE2 Receptor
    ace2_receptor = Protein(sources=[pdb_folder + '6m1d.pdb'],
                            occurences=membrane_nb_receptors,
                            position=Vector3(0.0, 6.0, 0.0))

    membrane = Membrane(sources=[pdb_folder + 'membrane/popc.pdb'],
                        occurences=membrane_nb_lipids)

    cell = Cell(name='Cell',
                size=membrane_size,
                shape=bio_explorer.ASSEMBLY_SHAPE_SINUSOIDAL,
                membrane=membrane,
                receptor=ace2_receptor,
                extra_parameters=[membrane_height])

    bio_explorer.add_cell(cell=cell,
                          position=Vector3(4.5, -186, 7.0),
                          representation=protein_representation,
                          random_seed=1)

    # Set rendering settings
    bio_explorer.core_api().set_renderer(
        background_color=[96 / 255, 125 / 255, 139 / 255],
        current='bio_explorer',
        samples_per_pixel=1,
        subsampling=4,
        max_accum_frames=64)
    params = bio_explorer.core_api().BioExplorerRendererParams()
    params.shadows = 0.75
    params.soft_shadows = 1.0
    bio_explorer.core_api().set_renderer_params(params)

    # Restore image streaming
    bio_explorer.core_api().set_application_parameters(image_stream_fps=20)
예제 #3
0
    def _add_cell(self, frame):

        name = 'Cell'
        nb_receptors = cell_nb_receptors
        size = scene_size * 2.0
        height = scene_size / 10.0
        position = Vector3(4.5, -186.0, 7.0)
        random_seed = 10

        nb_lipids = cell_nb_lipids
        ace2_receptor = Protein(sources=[pdb_folder + '6m18.pdb'],
                                occurences=nb_receptors,
                                position=Vector3(0.0, 6.0, 0.0))

        membrane = ParametricMembrane(sources=[
            membrane_folder + 'segA.pdb', membrane_folder + 'segB.pdb',
            membrane_folder + 'segC.pdb', membrane_folder + 'segD.pdb'
        ],
                                      occurences=cell_nb_lipids)

        cell = Cell(name=name,
                    size=size,
                    extra_parameters=[height],
                    shape=BioExplorer.ASSEMBLY_SHAPE_SINUSOIDAL,
                    membrane=membrane,
                    receptor=ace2_receptor,
                    random_position_seed=frame + 1,
                    random_position_strength=0.025,
                    random_rotation_seed=frame + 2,
                    random_rotation_strength=0.2)

        self._be.add_cell(cell=cell,
                          position=position,
                          representation=protein_representation,
                          random_seed=random_seed)
        '''Modify receptor position when attached virus enters the cell'''
        receptors_instances = [90, 23, 24, 98, 37, 44]
        receptors_sequences = [[2500, 2599], [2200, 2299], [2550, 2649],
                               [2600, 2699], [2650, 2749], [-1, -1]]

        for i in range(len(receptors_instances)):
            instance_index = receptors_instances[i]
            sequence = receptors_sequences[i]
            start_frame = sequence[0]
            end_frame = sequence[1]
            if frame >= start_frame:
                if frame > end_frame:
                    '''Send receptor to outter space'''
                    status = self._be.set_protein_instance_transformation(
                        assembly_name=name,
                        name=name + '_' + BioExplorer.NAME_RECEPTOR,
                        instance_index=instance_index,
                        position=Vector3(0.0, 1e6, 0.0))
                else:
                    '''Current receptor transformation'''
                    transformation = self._be.get_protein_instance_transformation(
                        assembly_name=name,
                        name=name + '_' + BioExplorer.NAME_RECEPTOR,
                        instance_index=instance_index)
                    p = transformation['position'].split(',')
                    q = transformation['rotation'].split(',')
                    pos = Vector3(float(p[0]), float(p[1]), float(p[2]))
                    q2 = Quaternion(float(q[0]), float(q[1]), float(q[2]),
                                    float(q[3]))
                    '''Bend receptor'''
                    progress = (frame - start_frame) * 1.0 / (end_frame -
                                                              start_frame)
                    q1 = Quaternion(axis=[0, 1, 0], angle=math.pi * progress)
                    rot = q2 * q1

                    pos.x += landing_distance * progress * 0.3
                    pos.y -= landing_distance * progress * 0.3

                    status = self._be.set_protein_instance_transformation(
                        assembly_name=name,
                        name=name + '_' + BioExplorer.NAME_RECEPTOR,
                        instance_index=instance_index,
                        position=pos,
                        rotation=rot)
        '''Glycans'''
        if nb_receptors != 0 and add_glycans:
            self._be.add_multiple_glycans(
                representation=glycan_representation,
                assembly_name=name,
                glycan_type=BioExplorer.NAME_GLYCAN_COMPLEX,
                protein_name=BioExplorer.NAME_RECEPTOR,
                paths=complex_paths,
                indices=[53, 90, 103, 322, 432, 690],
                assembly_params=[0, 0, 0.0, frame + 3, 0.2])
            self._be.add_multiple_glycans(
                representation=glycan_representation,
                assembly_name=name,
                glycan_type=BioExplorer.NAME_GLYCAN_HYBRID,
                protein_name=BioExplorer.NAME_RECEPTOR,
                paths=hybrid_paths,
                indices=[546],
                assembly_params=[0, 0, 0.0, frame + 4, 0.2])

            indices = [[155, Quaternion(0.707, 0.0, 0.707, 0.0)],
                       [730, Quaternion(0.707, 0.0, 0.707, 0.0)]]
            count = 0
            for index in indices:
                o_glycan_name = name + '_' + BioExplorer.NAME_GLYCAN_O_GLYCAN + '_' + str(
                    index[0])
                o_glycan = Sugars(
                    assembly_name=name,
                    name=o_glycan_name,
                    source=o_glycan_paths[0],
                    protein_name=name + '_' + BioExplorer.NAME_RECEPTOR,
                    representation=glycan_representation,
                    chain_ids=[2, 4],
                    site_indices=[index[0]],
                    rotation=index[1],
                    assembly_params=[0, 0, 0.0, frame + count + 5, 0.2])
                self._be.add_sugars(o_glycan)
                count += 1