Ejemplo n.º 1
0
def test_immune():
    resource_folder = 'tests/test_files/'
    pdb_folder = resource_folder + 'pdb/immune/'

    bio_explorer = BioExplorer('localhost:5000')
    bio_explorer.reset()
    print('BioExplorer version ' + bio_explorer.version())

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

    # Proteins
    lactoferrin_path = pdb_folder + '1b0l.pdb'
    defensin_path = pdb_folder + '1ijv.pdb'

    # Scene parameters
    scene_size = 800

    # Lactoferrins
    lactoferrins = Protein(sources=[lactoferrin_path],
                           load_non_polymer_chemicals=True,
                           occurences=150)

    lactoferrins_volume = Volume(name=bio_explorer.NAME_LACTOFERRIN,
                                 size=scene_size,
                                 protein=lactoferrins)

    bio_explorer.add_volume(volume=lactoferrins_volume,
                            representation=bio_explorer.REPRESENTATION_ATOMS,
                            position=Vector3(0.0, scene_size / 2.0 - 200.0,
                                             0.0))

    # Defensins
    defensins = Protein(sources=[defensin_path],
                        load_non_polymer_chemicals=True,
                        occurences=300)

    defensins_volume = Volume(name=bio_explorer.NAME_DEFENSIN,
                              size=scene_size,
                              protein=defensins)

    bio_explorer.add_volume(volume=defensins_volume,
                            representation=bio_explorer.REPRESENTATION_ATOMS,
                            position=Vector3(0.0, scene_size / 2.0 - 200.0,
                                             0.0),
                            random_seed=3)

    # Restore image streaming
    bio_explorer.core_api().set_application_parameters(image_stream_fps=20)
Ejemplo n.º 2
0
def test_layout():
    resource_folder = 'tests/test_files/'
    pdb_folder = resource_folder + 'pdb/'

    bio_explorer = BioExplorer('localhost:5000')
    bio_explorer.reset()
    print('BioExplorer version ' + bio_explorer.version())

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

    # Camera
    brayns = bio_explorer.core_api()
    brayns.set_camera(
        current='orthographic',
        orientation=[0.0, 0.0, 0.0, 1.0],
        position=[23.927943790322814, 24.84577580212592, 260.43975983632527],
        target=[23.927943790322814, 24.84577580212592, 39.93749999999999])
    params = brayns.OrthographicCameraParams()
    params.height = 55
    brayns.set_camera_params(params)

    # ACE2 Receptor
    ace2_receptor = Protein(sources=[pdb_folder + '6m1d.pdb'])
    bio_explorer.add_protein('ACE2 receptor',
                             ace2_receptor,
                             rotation=Quaternion(0.5, 0.5, 1.0, 0.0))

    # Restore image streaming
    bio_explorer.core_api().set_application_parameters(image_stream_fps=20)
Ejemplo n.º 3
0
def test_glucose():
    resource_folder = 'tests/test_files/'
    pdb_folder = resource_folder + 'pdb/'

    bio_explorer = BioExplorer('localhost:5000')
    bio_explorer.reset()
    print('BioExplorer version ' + bio_explorer.version())

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

    # Proteins
    glucose_path = pdb_folder + 'glucose.pdb'

    # Scene parameters
    scene_size = 800.0

    # Glucose
    protein = Protein(sources=[glucose_path],
                      load_non_polymer_chemicals=True,
                      occurences=120000)

    volume = Volume(name=bio_explorer.NAME_GLUCOSE,
                    size=scene_size,
                    protein=protein)

    bio_explorer.add_volume(volume=volume,
                            representation=bio_explorer.REPRESENTATION_ATOMS,
                            position=Vector3(0.0, scene_size / 2.0 - 200.0,
                                             0.0))

    # Restore image streaming
    bio_explorer.core_api().set_application_parameters(image_stream_fps=20)
Ejemplo n.º 4
0
def test_layout():
    resource_folder = 'tests/test_files/'
    pdb_folder = resource_folder + 'pdb/'

    bio_explorer = BioExplorer('localhost:5000')
    bio_explorer.reset()
    print('BioExplorer version ' + bio_explorer.version())

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

    # Resources

    protein_representation = BioExplorer.REPRESENTATION_ATOMS_AND_STICKS
    protein_radius_multiplier = 1.0
    glycan_representation = BioExplorer.REPRESENTATION_ATOMS_AND_STICKS
    glycan_radius_multiplier = 1.0

    # M Protein
    source = pdb_folder + 'QHD43419a.pdb'

    m_protein = Protein(sources=[source],
                        load_hydrogen=False,
                        load_non_polymer_chemicals=False)

    name = bio_explorer.NAME_PROTEIN_M
    bio_explorer.add_protein(name=name,
                             protein=m_protein,
                             atom_radius_multiplier=protein_radius_multiplier,
                             representation=protein_representation)

    # Glycans
    glycan_folder = pdb_folder + 'glycans/'
    high_mannose_paths = [
        glycan_folder + 'high-mannose/1.pdb',
        glycan_folder + 'high-mannose/2.pdb',
        glycan_folder + 'high-mannose/3.pdb',
        glycan_folder + 'high-mannose/4.pdb'
    ]

    # High-mannose glycans on Protein M
    indices = [5]
    high_mannose_glycans = Sugars(
        rotation=Quaternion(0.707, 0.0, 0.0, 0.707),
        assembly_name=name,
        name=bio_explorer.NAME_GLYCAN_HIGH_MANNOSE,
        protein_name=name,
        source=high_mannose_paths[0],
        site_indices=indices,
        representation=glycan_representation,
        atom_radius_multiplier=glycan_radius_multiplier)
    bio_explorer.add_glycans(high_mannose_glycans)

    # Materials
    bio_explorer.apply_default_color_scheme(
        shading_mode=bio_explorer.SHADING_MODE_BASIC)

    # Restore image streaming
    bio_explorer.core_api().set_application_parameters(image_stream_fps=20)
Ejemplo n.º 5
0
def add_glucose(bioexplorer, size, number):
    protein = Protein(sources=[GLUCOSE_PATH],
                      load_non_polymer_chemicals=True,
                      occurences=number)
    volume = Volume(name=bioexplorer.NAME_GLUCOSE, size=size, protein=protein)
    bioexplorer.add_volume(volume=volume,
                           representation=bioexplorer.REPRESENTATION_ATOMS,
                           position=Vector3(0.0, size / 2.0 - 200.0, 0.0))
Ejemplo n.º 6
0
def add_defensins(bioexplorer, size, number):
    defensins = Protein(sources=[DEFENSINS_PATH],
                        load_non_polymer_chemicals=True,
                        occurences=number)
    defensins_volume = Volume(name=bioexplorer.NAME_DEFENSIN,
                              size=size,
                              protein=defensins)
    bioexplorer.add_volume(volume=defensins_volume,
                           representation=bioexplorer.REPRESENTATION_ATOMS,
                           position=Vector3(0.0, size / 2.0 - 200.0, 0.0))
Ejemplo n.º 7
0
def add_lactoferrins(bioexplorer, size, number):
    lactoferrins = Protein(sources=[LACTOFERRINS_PATH],
                           load_non_polymer_chemicals=True,
                           occurences=number)
    lactoferrins_volume = Volume(name=bioexplorer.NAME_LACTOFERRIN,
                                 size=size,
                                 protein=lactoferrins)
    bioexplorer.add_volume(volume=lactoferrins_volume,
                           representation=bioexplorer.REPRESENTATION_ATOMS,
                           position=Vector3(0.0, size / 2.0 - 200.0, 0.0))
Ejemplo n.º 8
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)
Ejemplo n.º 9
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)
 def _add_defensins(self, frame):
     defensin = Protein(
         sources=[defensin_path], load_non_polymer_chemicals=True,
         occurences=nb_defensins)
     defensins_volume = Volume(
         name=BioExplorer.NAME_DEFENSIN, size=scene_size, protein=defensin,
         random_position_seed=frame + 40, random_position_stength=scene_size / 400.0,
         random_rotation_seed=frame + 41, random_rotation_stength=0.3
     )
     status = self._be.add_volume(
         volume=defensins_volume, representation=protein_representation,
         position=Vector3(0.0, scene_size / 2.0 - 200.0, 0.0),
         random_seed=102)
 def _add_lactoferrins(self, frame):
     lactoferrin = Protein(
         sources=[lactoferrin_path], load_non_polymer_chemicals=True,
         occurences=nb_lactoferrins)
     lactoferrins_volume = Volume(
         name=BioExplorer.NAME_LACTOFERRIN, size=scene_size, protein=lactoferrin,
         random_position_seed=frame + 30, random_position_stength=scene_size / 400.0,
         random_rotation_seed=frame + 31, random_rotation_stength=0.3
     )
     status = self._be.add_volume(
         volume=lactoferrins_volume, representation=protein_representation,
         position=Vector3(0.0, scene_size / 2.0 - 200.0, 0.0),
         random_seed=101)
 def _add_glucose(self, frame):
     glucose = Protein(
         sources=[glucose_path], load_non_polymer_chemicals=True,
         occurences=nb_glucoses)
     volume = Volume(
         name=BioExplorer.NAME_GLUCOSE, size=scene_size, protein=glucose,
         random_position_seed=frame + 20, random_position_stength=scene_size / 600.0,
         random_rotation_seed=frame + 21, random_rotation_stength=0.3
     )
     status = self._be.add_volume(
         volume=volume, representation=protein_representation,
         position=Vector3(0.0, scene_size / 2.0 - 200.0, 0.0),
         random_seed=100)
Ejemplo n.º 13
0
def test_virus():
    resource_folder = 'tests/test_files/'
    pdb_folder = resource_folder + 'pdb/'
    rna_folder = resource_folder + 'rna/'
    glycan_folder = pdb_folder + 'glycans/'

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

    # Settings
    virus_radius = 45.0
    add_glycans = True
    protein_radius_multiplier = 1.0
    protein_representation = BioExplorer.REPRESENTATION_ATOMS
    protein_load_hydrogen = False

    # Virus configuration
    nb_protein_s = 62
    nb_protein_s_indices = [1, 27, 43]
    nb_protein_e = 42
    nb_protein_m = 50
    show_rna = True

    # Virus parameters
    show_functional_regions = False
    show_glycosylation_sites = False

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

    # Protein S
    open_conformation_indices = nb_protein_s_indices
    closed_conformation_indices = list()
    for i in range(nb_protein_s):
        if i not in open_conformation_indices:
            closed_conformation_indices.append(i)

    params = [11.5, 0, 0.0, 0, 0.0, 0.0]
    virus_protein_s = Protein(
        sources=[pdb_folder + '6vyb.pdb', pdb_folder + 'sars-cov-2-v1.pdb'],
        load_hydrogen=protein_load_hydrogen, occurences=nb_protein_s,
        assembly_params=params, rotation=Quaternion(0.087, 0.0, 0.996, 0.0),
        instance_indices=[open_conformation_indices, closed_conformation_indices])

    # Protein M (QHD43419)
    params = [2.5, 0, 0.0, 0, 0.0, 0.0]
    virus_protein_m = Protein(
        sources=[pdb_folder + 'QHD43419a.pdb'],
        load_hydrogen=protein_load_hydrogen, occurences=nb_protein_m,
        assembly_params=params, rotation=Quaternion(0.99, 0.0, 0.0, 0.135))

    # Protein E (QHD43418 P0DTC4)
    params = [2.5, 0, 0.0, 0, 0.0, 0.0]
    virus_protein_e = Protein(
        sources=[pdb_folder + 'QHD43418a.pdb'], load_hydrogen=protein_load_hydrogen,
        occurences=nb_protein_e, assembly_params=params,
        rotation=Quaternion(0.705, 0.705, -0.04, -0.04))

    # Virus membrane
    virus_membrane = ParametricMembrane(
        sources=[pdb_folder + 'membrane/popc.pdb'],
        occurences=15000)

    # RNA Sequence
    clip_planes = list()
    rna_sequence = None
    if show_rna:
        clip_planes.append([0.0, 0.0, -1.0, 15.0])
        rna_sequence = RNASequence(
            source=rna_folder + 'sars-cov-2.rna', assembly_params=[11.0, 0.5],
            t_range=Vector2(0, 30.5 * math.pi), shape=bio_explorer.RNA_SHAPE_TREFOIL_KNOT,
            shape_params=Vector3(1.51, 1.12, 1.93))

    # Coronavirus
    name = 'Coronavirus'
    coronavirus = Virus(
        name=name, protein_s=virus_protein_s, protein_e=virus_protein_e, protein_m=virus_protein_m,
        membrane=virus_membrane, rna_sequence=rna_sequence,
        assembly_params=[virus_radius, 1, 0.025, 2, 0.4, 0.0])

    bio_explorer.add_virus(
        virus=coronavirus, position=Vector3(-70.0, -100.0, 230.0),
        representation=protein_representation, atom_radius_multiplier=protein_radius_multiplier,
        clipping_planes=clip_planes)

    # Glycans
    if add_glycans:
        complex_paths = [glycan_folder + 'complex/5.pdb', glycan_folder + 'complex/15.pdb',
                         glycan_folder + 'complex/25.pdb', glycan_folder + 'complex/35.pdb']
        high_mannose_paths = [
            glycan_folder + 'high-mannose/1.pdb', glycan_folder + 'high-mannose/2.pdb',
            glycan_folder + 'high-mannose/3.pdb', glycan_folder + 'high-mannose/4.pdb']
        o_glycan_paths = [glycan_folder + 'o-glycan/12.pdb']

        # High-mannose
        indices_closed = [61, 122, 234, 603, 709, 717, 801, 1074]
        indices_open = [61, 122, 234, 709, 717, 801, 1074]
        bio_explorer.add_multiple_glycans(
            assembly_name=name, glycan_type=bio_explorer.NAME_GLYCAN_HIGH_MANNOSE,
            protein_name=bio_explorer.NAME_PROTEIN_S_CLOSED, paths=high_mannose_paths,
            indices=indices_closed, representation=protein_representation,
            atom_radius_multiplier=protein_radius_multiplier)
        bio_explorer.add_multiple_glycans(
            assembly_name=name, glycan_type=bio_explorer.NAME_GLYCAN_HIGH_MANNOSE,
            protein_name=bio_explorer.NAME_PROTEIN_S_OPEN, paths=high_mannose_paths,
            indices=indices_open, representation=protein_representation,
            atom_radius_multiplier=protein_radius_multiplier)

        # Complex
        indices1 = [17, 74, 149, 165, 282, 331, 343, 616, 657, 1098, 1134, 1158, 1173, 1194]
        indices2 = [17, 74, 149, 165, 282, 331, 343, 1098, 657, 1134, 1158, 1173, 1194]
        bio_explorer.add_multiple_glycans(
            assembly_name=name, glycan_type=bio_explorer.NAME_GLYCAN_COMPLEX,
            protein_name=bio_explorer.NAME_PROTEIN_S_CLOSED, paths=complex_paths, indices=indices1,
            representation=protein_representation, atom_radius_multiplier=protein_radius_multiplier)
        bio_explorer.add_multiple_glycans(
            assembly_name=name, glycan_type=bio_explorer.NAME_GLYCAN_COMPLEX,
            protein_name=bio_explorer.NAME_PROTEIN_S_OPEN, paths=complex_paths, indices=indices2,
            representation=protein_representation, atom_radius_multiplier=protein_radius_multiplier)

        # O-Glycans
        for index in [323, 325]:
            o_glycan_name = name + '_' + bio_explorer.NAME_GLYCAN_O_GLYCAN + '_' + str(index)
            o_glycan = Sugars(
                assembly_name=name, name=o_glycan_name, source=o_glycan_paths[0],
                protein_name=name + '_' + bio_explorer.NAME_PROTEIN_S_CLOSED,
                representation=protein_representation, site_indices=[index],
                atom_radius_multiplier=protein_radius_multiplier)
            bio_explorer.add_sugars(o_glycan)

        # High-mannose glycans on Protein M
        indices = [5]
        protein_name = name + '_' + bio_explorer.NAME_PROTEIN_M
        high_mannose_glycans = Sugars(
            rotation=Quaternion(0.707, 0.0, 0.0, 0.707),
            assembly_name=name, name=protein_name + '_' + bio_explorer.NAME_GLYCAN_HIGH_MANNOSE,
            protein_name=protein_name, source=high_mannose_paths[0],
            site_indices=indices,
            representation=protein_representation
        )
        bio_explorer.add_glycans(high_mannose_glycans)

        # Complex glycans on Protein E
        indices = [48, 66]
        protein_name = name + '_' + bio_explorer.NAME_PROTEIN_E
        complex_glycans = Sugars(
            rotation=Quaternion(0.707, 0.0, 0.0, 0.707),
            assembly_name=name, name=protein_name + '_' + bio_explorer.NAME_GLYCAN_COMPLEX,
            protein_name=protein_name, source=complex_paths[0],
            site_indices=indices,
            representation=protein_representation
        )
        bio_explorer.add_glycans(complex_glycans)

    # Apply default materials
    bio_explorer.apply_default_color_scheme(shading_mode=bio_explorer.SHADING_MODE_BASIC)

    # Functional regions on open spike
    if show_functional_regions:
        indices = [1, 16, 306, 330, 438, 507, 522, 816, 835, 908, 986, 1076, 1274, 2000]
        region_colors = [
            [1.0, 1.0, 1.0], [0.0, 0.0, 1.0], [1.0, 1.0, 1.0], [0.0, 1.0, 0.0], [0.4, 0.1, 0.1],
            [0.0, 1.0, 0.0], [1.0, 1.0, 1.0], [1.0, 0.0, 0.0], [1.0, 1.0, 1.0], [1.0, 1.0, 0.0],
            [1.0, 1.0, 1.0], [1.0, 0.0, 1.0], [1.0, 1.0, 1.0], [1.0, 1.0, 1.0]]
        palette = list()
        for index in range(len(indices) - 1):
            for i in range(0, indices[index + 1] - indices[index]):
                color = list()
                for j in range(3):
                    color.append(region_colors[index][j] * 1)
                palette.append(color)
        bio_explorer.set_protein_color_scheme(
            assembly_name=name, name=name + '_' + bio_explorer.NAME_PROTEIN_S_OPEN,
            color_scheme=bio_explorer.COLOR_SCHEME_REGION, palette=palette)

    # Display glycosylation sites
    if show_glycosylation_sites:
        palette = sns.color_palette('Set2', 2)
        bio_explorer.set_protein_color_scheme(
            assembly_name=name, name=name + '_' + bio_explorer.NAME_PROTEIN_S_OPEN,
            color_scheme=bio_explorer.COLOR_SCHEME_GLYCOSYLATION_SITE, palette=palette)
        bio_explorer.set_protein_color_scheme(
            assembly_name=name, name=name + '_' + bio_explorer.NAME_PROTEIN_S_CLOSED,
            color_scheme=bio_explorer.COLOR_SCHEME_GLYCOSYLATION_SITE, palette=palette)

    # 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)
Ejemplo n.º 14
0
def add_virus(bioexplorer, name, position, open_conformation_indices=list()):
    closed_conformation_indices = list()
    for i in range(NB_PROTEIN_S):
        if i not in open_conformation_indices:
            closed_conformation_indices.append(i)

    params = [11.5, 0, 0.0, 0, 0.0, 0.0]
    virus_protein_s = Protein(
        sources=[
            PDB_FOLDER + '6vyb.pdb',  # Open conformation
            PDB_FOLDER + 'sars-cov-2-v1.pdb'  # Closed conformation
        ],
        load_hydrogen=PROTEIN_LOAD_HYDROGEN,
        occurences=NB_PROTEIN_S,
        assembly_params=params,
        rotation=Quaternion(0.0, 1.0, 0.0, 0.0),
        instance_indices=[
            open_conformation_indices, closed_conformation_indices
        ])

    params = [2.5, 0, 0.0, 0, 0.0, 0.0]
    virus_protein_m = Protein(sources=[PDB_FOLDER + 'QHD43419a.pdb'],
                              load_hydrogen=PROTEIN_LOAD_HYDROGEN,
                              occurences=NB_PROTEIN_M,
                              assembly_params=params,
                              rotation=Quaternion(0.99, 0.0, 0.0, 0.135))

    params = [2.5, 0, 0.0, 0, 0.0, 0.0]
    virus_protein_e = Protein(sources=[PDB_FOLDER + 'QHD43418a.pdb'],
                              load_hydrogen=PROTEIN_LOAD_HYDROGEN,
                              occurences=NB_PROTEIN_E,
                              assembly_params=params,
                              rotation=Quaternion(0.705, 0.705, -0.04, -0.04))

    virus_membrane = Membrane(sources=[PDB_FOLDER + 'membrane/popc.pdb'],
                              occurences=15000)

    rna_sequence = None
    if ADD_RNA:
        rna_sequence = RNASequence(source=RNA_FOLDER + 'sars-cov-2.rna',
                                   assembly_params=[11.0, 0.5],
                                   t_range=Vector2(0, 30.5 * math.pi),
                                   shape=bioexplorer.RNA_SHAPE_TREFOIL_KNOT,
                                   shape_params=Vector3(1.51, 1.12, 1.93))

    coronavirus = Virus(name=name,
                        protein_s=virus_protein_s,
                        protein_e=virus_protein_e,
                        protein_m=virus_protein_m,
                        membrane=virus_membrane,
                        rna_sequence=rna_sequence,
                        assembly_params=[45.0, 1, 0.025, 2, 0.4, 0.0])

    clip_planes = list()
    if ADD_RNA:
        clip_planes.append([0, 0, -1, 15])
    bioexplorer.add_virus(virus=coronavirus,
                          position=position,
                          representation=PROTEIN_REPRESENTATION,
                          atom_radius_multiplier=PROTEIN_RADIUS_MULTIPLIER,
                          clipping_planes=clip_planes)

    if ADD_GLYCANS:
        # High-mannose
        indices_closed = [61, 122, 234, 603, 709, 717, 801, 1074]
        indices_open = [61, 122, 234, 709, 717, 801, 1074]
        bioexplorer.add_multiple_glycans(
            assembly_name=name,
            glycan_type=bioexplorer.NAME_GLYCAN_HIGH_MANNOSE,
            protein_name=bioexplorer.NAME_PROTEIN_S_CLOSED,
            paths=HIGH_MANNOSE_PATHS,
            indices=indices_closed,
            representation=PROTEIN_REPRESENTATION)
        if open_conformation_indices:
            bioexplorer.add_multiple_glycans(
                assembly_name=name,
                glycan_type=bioexplorer.NAME_GLYCAN_HIGH_MANNOSE,
                protein_name=bioexplorer.NAME_PROTEIN_S_OPEN,
                paths=HIGH_MANNOSE_PATHS,
                indices=indices_open,
                representation=PROTEIN_REPRESENTATION)

        # Complex
        indices_closed = [
            17, 74, 149, 165, 282, 331, 343, 616, 657, 1098, 1134, 1158, 1173,
            1194
        ]
        indices_open = [
            17, 74, 149, 165, 282, 331, 343, 657, 1098, 1134, 1158, 1173, 1194
        ]
        bioexplorer.add_multiple_glycans(
            assembly_name=name,
            glycan_type=bioexplorer.NAME_GLYCAN_COMPLEX,
            protein_name=bioexplorer.NAME_PROTEIN_S_CLOSED,
            paths=COMPLEX_PATHS,
            indices=indices_closed,
            representation=PROTEIN_REPRESENTATION)
        if open_conformation_indices:
            bioexplorer.add_multiple_glycans(
                assembly_name=name,
                glycan_type=bioexplorer.NAME_GLYCAN_COMPLEX,
                protein_name=bioexplorer.NAME_PROTEIN_S_OPEN,
                paths=COMPLEX_PATHS,
                indices=indices_open,
                representation=PROTEIN_REPRESENTATION)

        # O-Glycans
        for index in [323, 325]:
            o_glycan_name = name + '_' + bioexplorer.NAME_GLYCAN_O_GLYCAN + '_' + str(
                index)
            o_glycan = Sugars(assembly_name=name,
                              name=o_glycan_name,
                              source=O_GLYCAN_PATHS[0],
                              protein_name=name + '_' +
                              bioexplorer.NAME_PROTEIN_S_CLOSED,
                              representation=PROTEIN_REPRESENTATION,
                              site_indices=[index])
            bioexplorer.add_sugars(o_glycan)

        # High-mannose glycans on Protein M
        indices = [5]
        high_mannose_glycans = Sugars(
            rotation=Quaternion(0.707, 0.0, 0.0, 0.707),
            assembly_name=name,
            name=bioexplorer.NAME_GLYCAN_HIGH_MANNOSE,
            protein_name=name + '_' + bioexplorer.NAME_PROTEIN_M,
            source=HIGH_MANNOSE_PATHS[0],
            site_indices=indices,
            representation=PROTEIN_REPRESENTATION)
        bioexplorer.add_glycans(high_mannose_glycans)

        # Complex glycans on Protein E
        indices = [48, 66]
        complex_glycans = Sugars(rotation=Quaternion(0.707, 0.0, 0.0, 0.707),
                                 assembly_name=name,
                                 name=bioexplorer.NAME_GLYCAN_COMPLEX,
                                 protein_name=name + '_' +
                                 bioexplorer.NAME_PROTEIN_E,
                                 source=COMPLEX_PATHS[0],
                                 site_indices=indices,
                                 representation=PROTEIN_REPRESENTATION)
        bioexplorer.add_glycans(complex_glycans)

    for i in range(NB_DEFENSINS):
        defensin = AssemblyProtein(
            assembly_name=name,
            name=name + '_' + bioexplorer.NAME_DEFENSIN + '_' + str(i),
            source=DEFENSINS_PATH,
            assembly_params=[2.0, 0, 0.0, 0, 0.0, 0.0],
            shape=bioexplorer.ASSEMBLY_SHAPE_SPHERICAL,
            atom_radius_multiplier=PROTEIN_RADIUS_MULTIPLIER,
            representation=PROTEIN_REPRESENTATION,
            random_seed=100 + i + 1)
        bioexplorer.add_assembly_protein(defensin)
Ejemplo n.º 15
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
Ejemplo n.º 16
0
def test_layout():
    resource_folder = 'tests/test_files/'
    pdb_folder = resource_folder + 'pdb/'

    bio_explorer = BioExplorer('localhost:5000')
    bio_explorer.reset()
    print('BioExplorer version ' + bio_explorer.version())

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

    line_surfactant = 5
    line_virus = 25
    line_defense = 45

    # Camera
    brayns = bio_explorer.core_api()
    brayns.set_camera(
        current='orthographic',
        orientation=[0.0, 0.0, 0.0, 1.0],
        position=[23.927943790322814, 24.84577580212592, 260.43975983632527],
        target=[23.927943790322814, 24.84577580212592, 39.93749999999999])
    params = brayns.OrthographicCameraParams()
    params.height = 55
    brayns.set_camera_params(params)

    # Grid
    bio_explorer.add_grid(min_value=0,
                          max_value=100,
                          interval=1,
                          radius=0.005,
                          colored=False,
                          position=Vector3(-10.0, -10.0, -10.0))

    # Layout
    virus_protein_s = Protein(sources=[
        pdb_folder + '6vyb.pdb',  # Open conformation
        pdb_folder + 'sars-cov-2-v1.pdb'  # Closed conformation
    ])

    bio_explorer.add_protein(name='Protein S (open)',
                             protein=virus_protein_s,
                             conformation_index=0,
                             position=Vector3(5.0, line_virus, 0.0),
                             rotation=Quaternion(0.0, 0.0, 1.0, 0.0))
    bio_explorer.add_protein(name='Protein S (closed)',
                             protein=virus_protein_s,
                             conformation_index=1,
                             position=Vector3(20.0, line_virus, 0.0),
                             rotation=Quaternion(0.0, 0.0, 1.0, 0.0))

    # Protein M (QHD43419)
    virus_protein_m = Protein(sources=[pdb_folder + 'QHD43419a.pdb'])
    bio_explorer.add_protein(name='Protein M',
                             protein=virus_protein_m,
                             position=Vector3(35.0, line_virus, 0.0))

    # Protein E (QHD43418 P0DTC4)
    virus_protein_e = Protein(sources=[pdb_folder + 'QHD43418a.pdb'])
    bio_explorer.add_protein(name='Protein E',
                             protein=virus_protein_e,
                             position=Vector3(45.0, line_virus, 0.0))

    # Lactoferrin
    lactoferrin = Protein(sources=[pdb_folder + 'immune/1b0l.pdb'])
    bio_explorer.add_protein(name='Lactoferrin',
                             protein=lactoferrin,
                             position=Vector3(5.0, line_defense, 0.0))

    # Defensin
    defensin = Protein(sources=[pdb_folder + 'immune/1ijv.pdb'])
    bio_explorer.add_protein(name='Defensin',
                             protein=defensin,
                             position=Vector3(20.0, line_defense, 0.0))

    # Glucose
    glucose = Protein(sources=[pdb_folder + 'glucose.pdb'],
                      load_non_polymer_chemicals=True)
    bio_explorer.add_protein(name='Glucose',
                             protein=glucose,
                             position=Vector3(30.0, line_defense, 0.0),
                             rotation=Quaternion(0.0, 0.0, 0.707, 0.707))

    # ACE2 Receptor
    ace2_receptor = Protein(sources=[pdb_folder + '6m18.pdb'])
    bio_explorer.add_protein(name='ACE2 receptor',
                             protein=ace2_receptor,
                             position=Vector3(45.0, line_defense - 2.5, 0.0),
                             rotation=Quaternion(0.5, 0.5, 1.0, 0.0))

    # Surfactant
    head_source = pdb_folder + 'surfactant/1pw9.pdb'
    branch_source = pdb_folder + 'surfactant/1k6f.pdb'
    surfactant_d = Surfactant(
        name='Surfactant',
        surfactant_protein=bio_explorer.SURFACTANT_BRANCH,
        head_source=head_source,
        branch_source=branch_source)

    bio_explorer.add_surfactant(surfactant=surfactant_d,
                                position=Vector3(5.0, line_surfactant, 0.0))

    # Restore image streaming
    bio_explorer.core_api().set_application_parameters(image_stream_fps=20)