Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if not self.structure_file:
raise ValueError("Structure file not loaded")
only_chains = ssbio.utils.force_list(only_chains)
to_show_chains = '( '
for c in only_chains:
to_show_chains += ':{} or'.format(c)
to_show_chains = to_show_chains.strip(' or ')
to_show_chains += ' )'
if self.file_type == 'mmtf' or self.file_type == 'mmtf.gz':
view = nv.NGLWidget()
view.add_component(self.structure_path)
else:
view = nv.show_structure_file(self.structure_path, gui=gui)
if recolor:
view.clear_representations()
if only_chains:
view.add_cartoon(selection='{} and (not hydrogen)'.format(to_show_chains), color='silver', opacity=opacity)
else:
view.add_cartoon(selection='protein', color='silver', opacity=opacity)
elif only_chains:
view.clear_representations()
view.add_cartoon(selection='{} and (not hydrogen)'.format(to_show_chains), color='silver', opacity=opacity)
return view
"""
atoms, coordinates, group_numbers = arrange_molecules(molecules, arrange=arrange, nx=nx, distance=distance)
# nglview require atom names in all caps to color them properly
if caps:
atoms = [name.upper() for name in atoms]
if save is None:
temp_pdb_file = tempfile.NamedTemporaryFile(mode='w+', suffix='.pdb')
write_pdb(temp_pdb_file, atoms, coordinates, group=group_numbers)
view = nglview.show_structure_file(temp_pdb_file.name)
temp_pdb_file.close()
else:
with open(save, 'w') as save_file:
write_pdb(save_file, atoms, coordinates, group=group_numbers)
view = nglview.show_structure_file(save)
view.camera = camera
return view
Returns
-------
view
nglview "view" object.
"""
atoms, coordinates, group_numbers = arrange_molecules(molecules, arrange=arrange, nx=nx, distance=distance)
# nglview require atom names in all caps to color them properly
if caps:
atoms = [name.upper() for name in atoms]
if save is None:
temp_pdb_file = tempfile.NamedTemporaryFile(mode='w+', suffix='.pdb')
write_pdb(temp_pdb_file, atoms, coordinates, group=group_numbers)
view = nglview.show_structure_file(temp_pdb_file.name)
temp_pdb_file.close()
else:
with open(save, 'w') as save_file:
write_pdb(save_file, atoms, coordinates, group=group_numbers)
view = nglview.show_structure_file(save)
view.camera = camera
return view