def raster3d_render_tls_graph_path(self, chain, cpartition): """Render TLS visualizations using Raster3D. """ basename = "%s_CHAIN%s_NTLS%d" % (self.struct_id, chain.chain_id, cpartition.num_tls_segments()) png_path = "%s.png" % (basename) console.stdoutln("Raster3D: rendering %s..." % (basename)) struct_id = self.struct_id driver = R3DDriver.Raster3DDriver() ## XXX: Size hack: some structures have too many chains, ## or are just too large show_chain = {} for chx in self.struct.iter_chains(): if chx.chain_id == chain.chain_id: show_chain[chx.chain_id] = True continue if chx.count_amino_acids() >= 100: show_chain[chx.chain_id] = False continue show_chain[chx.chain_id] = True ## end size hack ## got target chain? if self.tlsmd_analysis.target_chain != None: for atm in self.tlsmd_analysis.target_chain.iter_all_atoms(): atm.orig_position = atm.position atm.position = chain.target_chain_sresult.transform( atm.position) viewer = Viewer.GLViewer() gl_struct = viewer.glv_add_struct(self.struct) ## orient the structure with the super-spiffy orientation algorithm ## which hilights the chain we are examining ori = calc_orientation(self.struct, chain) viewer.glo_update_properties(R=ori["R"], cor=ori["centroid"], zoom=ori["hzoom"], near=ori["near"], far=ori["far"], width=ori["pwidth"], height=ori["pheight"], bg_color="White") ## turn off axes and unit cell visualization gl_struct.glo_update_properties_path("gl_axes/visible", False) gl_struct.glo_update_properties_path("gl_unit_cell/visible", False) ## setup base structural visualization for gl_chain in gl_struct.glo_iter_children(): if not isinstance(gl_chain, Viewer.GLChain): continue ## chain is hidden if show_chain.get(gl_chain.chain.chain_id, False) == False: gl_chain.properties.update(visible=False) continue if gl_chain.chain.chain_id == chain.chain_id: if gl_chain.chain.has_amino_acids(): gl_chain.properties.update(lines=False, trace=True, trace_radius=0.25, trace_color="0.80,0.80,0.80") elif gl_chain.chain.has_nucleic_acids(): gl_chain.properties.update(lines=False, ball_stick=True, ball_stick_radius=0.25, color="0.80,0.80,0.80") else: if gl_chain.chain.has_amino_acids(): gl_chain.properties.update(lines=False, trace=True, trace_radius=0.25, trace_color="0.80,0.80,0.80") elif gl_chain.chain.has_nucleic_acids(): gl_chain.properties.update(hetatm_visible=True, trace=True, trace_radius=0.35, trace_color="0.80,0.80,0.80", ball_stick=True, ball_stick_radius=0.25, color="0.60,0.60,0.70") else: gl_chain.properties.update(visible=True, ball_stick=True, ball_stick_radius=0.25, cpk=False) ## add the TLS group visualizations has_amino_acids = cpartition.chain.has_amino_acids() has_nucleic_acids = cpartition.chain.has_nucleic_acids() for tls in cpartition.iter_tls_segments(): if tls.method != "TLS": continue if self.tlsmd_analysis.target_chain is not None: if tls.rmsd_pre_alignment <= 0.8: continue if (tls.rmsd_pre_alignment - tls.sresult.rmsd) < 0.5: continue tls_name = "TLS_%s" % (tls.filename_label()) gl_tls_group = TLS.GLTLSGroup(oatm_visible=False, side_chain_visible=False, hetatm_visible=True, adp_prob=settings.ADP_PROB, L_axis_scale=2.0, L_axis_radius=0.20, both_phases=True, tls_group=tls.tls_group, tls_info=tls.model_tls_info, tls_name=tls_name, tls_color=tls.color.name) gl_struct.glo_add_child(gl_tls_group) if tls.superposition_vscrew != None: gl_tls_group.properties.update( COR_vector=tls.superposition_vscrew) ## set width of trace according to the group's translationral tensor trace mtls_info = tls.model_tls_info tiso = (mtls_info["Tr1_eigen_val"] + mtls_info["Tr2_eigen_val"] + mtls_info["Tr3_eigen_val"]) / 3.0 ## too big usually for good visualization -- cheat and scale it down radius = 0.30 if has_amino_acids: gl_tls_group.gl_atom_list.properties.update( trace_radius=radius) elif has_nucleic_acids: gl_tls_group.gl_atom_list.properties.update( oatm_visible=True, side_chain_visible=True, trace=True, trace_radius=0.25, ball_stick=True, ball_stick_radius=radius) gl_tls_group.glo_update_properties(time=0.25) ## got target chain? if self.tlsmd_analysis.target_chain is not None: gl_chain = Viewer.GLChain(chain=self.tlsmd_analysis.target_chain) gl_chain.properties.update(oatm_visible=False, side_chain_visible=False, hetatm_visible=True, lines=False, ball_stick=False, trace=True, trace_radius=0.25, trace_color="0.40,0.40,0.40") gl_struct.glo_add_child(gl_chain) driver.glr_set_render_png_path(png_path) viewer.glv_render_one(driver) ## got target chain? if self.tlsmd_analysis.target_chain != None: for atm in self.tlsmd_analysis.target_chain.iter_all_atoms(): atm.position = atm.orig_position del atm.orig_position return "", png_path