try: from SimpleSession.versions.v29 import beginRestore,\ registerAfterModelsCB, reportRestoreError except ImportError: from chimera import UserError raise UserError('Cannot open session that was saved in a' ' newer version of Chimera; update your version') import chimera from chimera import replyobj replyobj.status('Beginning session restore...', \ blankAfter=0) beginRestore() def restoreCoreModels(): from SimpleSession.versions.v29 import init, restoreCamera, \ restoreMolecules, restoreColors, restoreSurfaces, \ restoreVRML, restorePseudoBondGroups molInfo = {'ballScale': (0, None, {}), 'ribbonHidesMainchain': (0, None, {}), 'pointSize': (0, None, {}), 'name': (0, None, {}), 'color': (0, None, {}), 'optional': {}, 'pdbHeaders': [], 'ids': (0, None, {}), 'surfaceOpacity': (0, None, {}), 'autochain': (0, None, {}), 'vdwDensity': (0, None, {}), 'lineWidth': (0, None, {}), 'stickScale': (0, None, {}), 'display': (0, None, {})} resInfo = {'insert': (0, None, {}), 'name': (0, None, {}), 'chain': (0, None, {}), 'ss': (0, None, {}), 'molecule': (0, None, {}), 'ribbonColor': (0, None, {}), 'label': (0, None, {}), 'labelColor': (0, None, {}), 'isHet': (0, None, {}), 'position': [], 'ribbonDisplay': (0, None, {}), 'optional': {}, 'ribbonDrawMode': (0, None, {})} atomInfo = {'residue': (0, None, {}), 'vdwColor': (0, None, {}), 'name': (0, None, {}), 'vdw': (0, None, {}), 'surfaceDisplay': (0, None, {}), 'color': (0, None, {}), 'idatmType': (0, None, {}), 'label': (0, None, {}), 'surfaceOpacity': (0, None, {}), 'element': (0, None, {}), 'labelColor': (0, None, {}), 'surfaceColor': (0, None, {}), 'radius': (0, None, {}), 'surfaceCategory': (0, None, {}), 'drawMode': (0, None, {}), 'optional': {}, 'display': (0, None, {})} bondInfo = {'drawMode': (0, None, {}), 'display': (0, None, {}), 'atoms': []} crdInfo = {} surfInfo = {'category': (0, None, {}), 'probeRadius': (0, None, {}), 'name': [], 'density': (0, None, {}), 'colorMode': (0, None, {}), 'molecule': [], 'drawMode': (0, None, {}), 'display': (0, None, {}), 'customColors': []} vrmlInfo = {'subid': (0, None, {}), 'display': (0, None, {}), 'id': (0, None, {}), 'vrmlString': [], 'name': (0, None, {})} colors = {'_openColor00': ((1.0, 1.0, 1.0), 1.0, 'default'), '_openColor01': ((1.0, 0.0, 1.0), 1.0, 'default'), '_openColor02': ((0.0, 1.0, 1.0), 1.0, 'default'), '_openColor03': ((1.0, 1.0, 0.0), 1.0, 'default'), '_openColor04': ((1.0, 0.0, 0.0), 1.0, 'default'), '_openColor05': ((0.0, 0.0, 1.0), 1.0, 'default'), '_openColor06': ((0.67000000000000004, 1.0, 0.0), 1.0, 'default'), '_openColor07': ((0.67000000000000004, 0.0, 1.0), 1.0, 'default'), '_openColor08': ((0.67000000000000004, 1.0, 1.0), 1.0, 'default'), '_openColor09': ((1.0, 0.67000000000000004, 0.0), 1.0, 'default'), '_openColor14': ((0.0, 1.0, 0.5), 1.0, 'default'), '_openColor11': ((1.0, 0.67000000000000004, 1.0), 1.0, 'default'), '_openColor15': ((0.67000000000000004, 0.67000000000000004, 1.0), 1.0, 'default'), 'medium purple': ((0.57647058823529407, 0.4392156862745098, 0.85882352941176465), 1.0, 'default'), '_openColor10': ((0.0, 0.67000000000000004, 1.0), 1.0, 'default'), '_openColor12': ((1.0, 1.0, 0.5), 1.0, 'default'), '_openColor13': ((1.0, 0.0, 0.5), 1.0, 'default')} materials = {'default': ((0.84999999999999998, 0.84999999999999998, 0.84999999999999998), 30.0)} pbInfo = {'category': ['distance monitor'], 'bondInfo': [{'color': (0, None, {}), 'atoms': [], 'label': (0, None, {}), 'halfbond': (0, None, {}), 'labelColor': (0, None, {}), 'drawMode': (0, None, {}), 'display': (0, None, {})}], 'color': (1, 0, {}), 'wireStipple': (1, (1, 61680), {}), 'showStubBonds': (1, False, {}), 'lineWidth': (1, 1.0, {}), 'stickScale': (1, 1.0, {}), 'id': [-2]} colorInfo = {0: ('yellow', (1.0, 1.0, 0.0, 1.0)), 1: ('', (1.0, 1.0, 1.0, 1.0)), 2: ('green', (0.0, 1.0, 0.0, 1.0))} detail = 1.0 viewerFog = None viewerBG = 1 viewerHL = 2 viewerLB = 2 viewerAttrs = {'silhouetteColor': None, 'yonIntensity': 0.0, 'showSilhouette': False, 'startRatio': 0.40000000596046448, 'viewSize': 221.70172119140625, 'scaleFactor': 1.4162323474884033, 'silhouetteWidth': 1.0, 'depthCue': True, 'highlight': 0, 'lensBorder': True} cameraAttrs = {'center': (-120.71147155761719, -108.72090911865234, 111.00948333740234), 'fieldOfView': 25.0, 'nearFar': (313.92703247070312, -28.148937225341797), 'ortho': True, 'eyeSeparation': 50.799999237060547, 'focal': 111.00948333740234} cameraMode = 'mono' replyobj.status("Initializing session restore...", blankAfter=0) init(colorInfo) replyobj.status("Restoring colors...", blankAfter=0) restoreColors(colors, materials) replyobj.status("Restoring molecules...", blankAfter=0) restoreMolecules(molInfo, resInfo, atomInfo, bondInfo, crdInfo) replyobj.status("Restoring surfaces...", blankAfter=0) restoreSurfaces(surfInfo) replyobj.status("Restoring VRML models...", blankAfter=0) restoreVRML(vrmlInfo) replyobj.status("Restoring pseudobond groups...", blankAfter=0) restorePseudoBondGroups(pbInfo) replyobj.status("Restoring camera...", blankAfter=0) restoreCamera(detail, viewerFog, viewerBG, viewerHL, viewerLB, viewerAttrs, cameraAttrs, cameraMode) replyobj.status("Restoring other models...", blankAfter=0) try: restoreCoreModels() except: reportRestoreError("Error restoring core models") replyobj.status("Restoring extension info...", blankAfter=0) def restore_surface_zones(): surface_zone_state = \ { 'class': 'Surface_Zone_State', 'version': 1, 'zone_table': {}, } try: import SurfaceZone.session SurfaceZone.session.restore_surface_zone_state(surface_zone_state) except: reportRestoreError('Error restoring surface zones') registerAfterModelsCB(restore_surface_zones) def restore_surface_color_mapping(): try: surface_color_state = \ { 'class': 'Surface_Colorings_State', 'coloring_table': { ( 0, 0, ): ( { 'axis': ( -0.29999999999999999, 0.38, 0.42999999999999999, ), 'class': 'Height_Color_State', 'colormap': { 'class': 'Color_Map_State', 'color_above_value_range': ( 0.0, 0.0, 1.0, 1.0, ), 'color_below_value_range': ( 1.0, 0.0, 0.0, 1.0, ), 'color_no_value': ( 0.5, 0.5, 0.5, 1, ), 'colors': [ ( 1.0, 0.0, 0.0, 1.0, ), ( 1.0, 1.0, 0.0, 1.0, ), ( 0.0, 1.0, 0.0, 1.0, ), ( 0.0, 1.0, 1.0, 1.0, ), ( 0.0, 0.0, 1.0, 1.0, ), ], 'data_values': [ -83.069999999999993, -8.9529999999999994, 65.170000000000002, 139.30000000000001, 213.40000000000001, ], 'version': 1, }, 'origin': ( 0.0, 0.0, 0.0, ), 'version': 1, }, False, ), }, 'version': 1, } import SurfaceColor.session SurfaceColor.session.restore_surface_color_state(surface_color_state) except: reportRestoreError('Error restoring surface color mapping') registerAfterModelsCB(restore_surface_color_mapping) def restore_volume_data(): volume_data_state = \ { 'class': 'Volume_Manager_State', 'data_and_regions_state': [ ( { 'available_subsamplings': {}, 'cell_angles': ( 90.0, 90.0, 90.0, ), 'class': 'Data_State', 'file_type': 'mrc', 'grid_id': '', 'path': 'emd_1063.map', 'rotation': ( ( 1, 0, 0, ), ( 0, 1, 0, ), ( 0, 0, 1, ), ), 'symmetries': ( ), 'version': 4, 'xyz_origin': None, 'xyz_step': ( 3.2599999999999998, 3.2599999999999998, 3.2599999999999998, ), }, [ { 'class': 'Volume_State', 'default_rgba': ( 0.69999999999999996, 0.69999999999999996, 0.69999999999999996, 1, ), 'region': ( [ 0, 0, 0, ], [ 129, 129, 129, ], [ 1, 1, 1, ], ), 'region_list': { 'class': 'Region_List_State', 'current_index': 1, 'named_regions': [ ], 'region_list': [ ( ( 0, 0, 0, ), ( 127, 127, 127, ), ), ( ( 0, 0, 0, ), ( 129, 129, 129, ), ), ], 'version': 1, }, 'region_name': '', 'rendering_options': { 'bt_correction': False, 'cap_faces': True, 'class': 'Rendering_Options_State', 'colormap_size': 256, 'dim_transparency': True, 'dim_transparent_voxels': True, 'flip_normals': True, 'limit_voxel_count': False, 'line_thickness': 1.0, 'linear_interpolation': True, 'maximum_intensity_projection': False, 'mesh_lighting': True, 'minimal_texture_memory': False, 'outline_box_rgb': ( 1.0, 1.0, 1.0, ), 'show_outline_box': False, 'smooth_lines': True, 'smoothing_factor': 0.29999999999999999, 'smoothing_iterations': 2, 'square_mesh': False, 'subdivide_surface': False, 'subdivision_levels': 1, 'surface_smoothing': False, 'two_sided_lighting': True, 'use_2d_textures': True, 'use_colormap': True, 'version': 1, 'voxel_limit': 1.0, }, 'representation': 'surface', 'solid_brightness_factor': 1.0, 'solid_colors': [ ( 1.0, 1.0, 1.0, 1, ), ( 1.0, 1.0, 1.0, 1, ), ( 1.0, 1.0, 1.0, 1, ), ], 'solid_levels': [ ( 0.073516859084367753, 0, ), ( 0.15603967680037023, 0.5, ), ( 0.23856249451637268, 1, ), ], 'solid_model': None, 'surface_brightness_factor': 1.0, 'surface_colors': [ ( 0.70399999999999996, 0.95999999999999996, 0.64000000000000001, 1.0, ), ], 'surface_levels': [ 0.0007362974542149596, ], 'surface_model': { 'active': True, 'class': 'Model_State', 'clip_plane_normal': ( 0.0, 0.0, -1.0, ), 'clip_plane_origin': ( 0.0, 0.0, 0.0, ), 'clip_thickness': 1.0, 'display': True, 'id': 0, 'name': 'emd_1063.map', 'osl_identifier': '#0', 'subid': 0, 'use_clip_plane': False, 'use_clip_thickness': False, 'version': 4, 'xform': { 'class': 'Xform_State', 'rotation_angle': 154.27260325260735, 'rotation_axis': ( 0.47003354978358786, -0.24814819981089481, -0.84704836521207627, ), 'translation': ( 134.8370215171648, 131.16696996307437, 62.360502412364006, ), 'version': 1, }, }, 'transparency_depth': 0.012307692491099999, 'transparency_factor': 0.0, 'version': 5, }, ], ), ], 'version': 1, } from VolumeViewer import session session.restore_volume_data_state(volume_data_state) try: restore_volume_data() except: reportRestoreError('Error restoring volume data') def restore_volume_dialog(): volume_dialog_state = \ { 'adjust_camera': False, 'auto_show_subregion': False, 'box_padding': '0', 'class': 'Volume_Dialog_State', 'data_cache_size': '32', 'focus_region_name': 'emd_1063.map', 'geometry': '404x910+2689+86', 'histogram_active_order': [ 0, ], 'histogram_region_names': [ 'emd_1063.map', ], 'immediate_update': True, 'initial_colors': ( ( 0.69999999999999996, 0.69999999999999996, 0.69999999999999996, 1, ), ( 1, 1, 0.69999999999999996, 1, ), ( 0.69999999999999996, 1, 1, 1, ), ( 0.69999999999999996, 0.69999999999999996, 1, 1, ), ( 1, 0.69999999999999996, 1, 1, ), ( 1, 0.69999999999999996, 0.69999999999999996, 1, ), ( 0.69999999999999996, 1, 0.69999999999999996, 1, ), ( 0.90000000000000002, 0.75, 0.59999999999999998, 1, ), ( 0.59999999999999998, 0.75, 0.90000000000000002, 1, ), ( 0.80000000000000004, 0.80000000000000004, 0.59999999999999998, 1, ), ), 'is_visible': False, 'max_histograms': '3', 'representation': 'surface', 'selectable_subregions': False, 'show_on_open': True, 'show_plane': True, 'shown_panels': [ 'Feature buttons', 'Data set list', 'Precomputed subsamples', 'Coordinates', 'Threshold and Color', 'Brightness and Transparency', 'Display style', 'Region bounds', 'Zone', 'Atom box', 'Named regions', 'Surface and Mesh options', ], 'subregion_button': 'button 2', 'use_initial_colors': True, 'version': 11, 'voxel_limit_for_open': '256', 'voxel_limit_for_plane': '256', 'zone_radius': 2.0, } from VolumeViewer import session session.restore_volume_dialog_state(volume_dialog_state) try: restore_volume_dialog() except: reportRestoreError('Error restoring volume dialog') def restore_scale_bar(): scale_bar_state = \ { 'bar_length': '100', 'bar_rgba': ( 0, 0, 0, 1, ), 'bar_thickness': '10', 'class': 'Scale_Bar_Dialog_State', 'frozen_models': [ ], 'geometry': '256x198+1335+370', 'is_visible': False, 'label_rgba': ( 0, 0, 0, 1, ), 'label_text': '# A', 'label_x_offset': '', 'label_y_offset': '3', 'model': { 'active': False, 'class': 'Model_State', 'clip_plane_normal': ( 0.0, 0.0, -1.0, ), 'clip_plane_origin': ( 0.0, 0.0, 0.0, ), 'clip_thickness': 1.0, 'display': True, 'id': 9, 'name': 'scale bar', 'osl_identifier': '#9', 'subid': 0, 'use_clip_plane': False, 'use_clip_thickness': False, 'version': 4, 'xform': { 'class': 'Xform_State', 'rotation_angle': 0.0, 'rotation_axis': ( 0.0, 0.0, 1.0, ), 'translation': ( -26.785479736328227, -249.6098968505857, 184.14604010009819, ), 'version': 1, }, }, 'move_scalebar': 0, 'orientation': 'horizontal', 'preserve_position': 1, 'screen_x_position': '0.6', 'screen_y_position': '-0.9', 'show_scalebar': True, 'version': 1, } import ScaleBar.session ScaleBar.session.restore_scale_bar_state(scale_bar_state) try: restore_scale_bar() except: reportRestoreError('Error restoring scale bar') def restore_surface_capping(): capper_state = \ { 'cap_offset': '0.001', 'cap_rgba': ( 1, 1, 1, 1.0, ), 'cap_style': 'solid', 'class': 'Capper_Dialog_State', 'color_caps': 0, 'geometry': '1x1+1372+599', 'is_visible': False, 'show_caps': True, 'subdivision_factor': '1.0', 'version': 1, } import SurfaceCap.session SurfaceCap.session.restore_capper_state(capper_state) try: restore_surface_capping() except: reportRestoreError('Error restoring surface capping') def restoreLightController(): import Lighting c = Lighting.get().setFromParams({'shininess': (30.0, (0.84999999999999998, 0.84999999999999998, 0.84999999999999998)), 'key': (True, (0.47826086956521729, 0.99999999999999989, 1.0), 0.60000002384185791, (1.0, 1.0, 1.0), 0.80000001192092896, (-0.073706499999999994, 0.71279353364800679, 0.79557485271483086)), 'fill': (True, (1.0, 0.0, 0.0), 0.34999999403953552, (1.0, 0.0, 0.0), 0.34999999403953552, (0.6066415143672933, -0.39957763374886418, 0.73437802646974237))}) try: restoreLightController() except: reportRestoreError("Error restoring lighting parameters") def restoreSession_RibbonStyleEditor(): import SimpleSession import RibbonStyleEditor userScalings = [] userXSections = [] userResidueClasses = [] residueData = [] SimpleSession.registerAfterModelsCB(RibbonStyleEditor.restoreState, (userScalings, userXSections, userResidueClasses, residueData)) try: restoreSession_RibbonStyleEditor() except: reportRestoreError("Error restoring RibbonStyleEditor state") def restoreMidasText(): from Midas import midas_text midas_text.aliases = {} midas_text.userSurfCategories = {} try: restoreMidasText() except: reportRestoreError('Error restoring Midas text state') def restoreMidasBase(): import chimera from SimpleSession import modelMap, modelOffset def deformatPosition(pos): xfDict = {} for molId, xfData in pos[5].items(): mid, subid = molId trData, rotData = xfData xf = chimera.Xform.translation(*trData) xf.rotate(*rotData) xfDict[(mid+modelOffset, subid)] = xf try: from chimera.misc import KludgeWeakWrappyDict clipDict = KludgeWeakWrappyDict("Model") except ImportError: from weakref import WeakKeyDictionary clipDict = WeakKeyDictionary() for clipID, clipInfo in pos[6].items(): mid, subid, className = clipID models = [m for m in modelMap.get((mid, subid), []) if m.__class__.__name__ == className] if not models: continue useClip, ox, oy, oz, nx, ny, nz, useThick, thickness = clipInfo if useClip: origin = chimera.Point(ox, oy, oz) normal = chimera.Vector(nx, ny, nz) plane = chimera.Plane(origin, normal) else: plane = chimera.Plane() for m in models: clipDict[m] = (useClip, plane, useThick, thickness) return pos[:-2] + (xfDict, clipDict) formattedPositions = {'default': (1.4162323474884033, 221.70172119140625, (-120.71147155761719, -108.72090911865234, 111.00948333740234), (332.71121215820312, -46.933120727539062), 111.00948333740234, {(9, 0): ((-214.63746337890626, -202.64690093994142, 73.313369750976562), (0.0, 0.0, 1.0, 0.0)), (0, 0): ((134.8370215171667, 131.16696996307653, 62.360502412362862), (0.47003354978359241, -0.24814819981089206, -0.84704836521207605, 154.2726032526075))}, {(0, 0, 'Volume'): (False, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, False, 1.0), (9, 0, 'Molecule'): (False, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, False, 1.0)}), 'session-start': (1.4162323474884033, 221.70172119140625, (-120.71147155761719, -108.72090911865234, 111.00948333740234), (313.92703247070312, -28.148937225341797), 111.00948333740234, {(9, 0): ((-162.74381656646727, -155.83139648437501, 73.313369750976562), (0.0, 0.0, 1.0, 0.0)), (0, 0): ((134.8370215171648, 131.16696996307437, 62.360502412364006), (0.47003354978358786, -0.24814819981089481, -0.84704836521207627, 154.27260325260735))}, {(0, 0, 'Volume'): (False, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, False, 1.0), (9, 0, 'Molecule'): (False, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, False, 1.0)})} positions = {} for name, fpos in formattedPositions.items(): positions[name] = deformatPosition(fpos) import Midas if modelOffset > 0: Midas.positions.clear() Midas.positions.update(positions) positionStack = [] Midas._positionStack = map(deformatPosition, positionStack) def delayedMidasBase(): try: restoreMidasBase() except: reportRestoreError('Error restoring Midas base state') import SimpleSession SimpleSession.registerAfterModelsCB(delayedMidasBase) try: import StructMeasure from StructMeasure.DistMonitor import restoreDistances registerAfterModelsCB(restoreDistances, 1) except: reportRestoreError("Error restoring distances in session") def restoreRemainder(): from SimpleSession.versions.v29 import restoreWindowSize, \ restoreOpenStates, restoreSelections, restoreFontInfo, \ restoreOpenModelsAttrs, restoreModelClip curSelIds = [] savedSels = [] openModelsAttrs = { 'cofrMethod': 3 } windowSize = (500, 500) xformMap = {} fontInfo = {'face': ('Sans Serif', 'Normal', 16)} clipPlaneInfo = {} replyobj.status("Restoring window...", blankAfter=0) restoreWindowSize(windowSize) replyobj.status("Restoring open states...", blankAfter=0) restoreOpenStates(xformMap) replyobj.status("Restoring font info...", blankAfter=0) restoreFontInfo(fontInfo) replyobj.status("Restoring selections...", blankAfter=0) restoreSelections(curSelIds, savedSels) replyobj.status("Restoring openModel attributes...", blankAfter=0) restoreOpenModelsAttrs(openModelsAttrs) replyobj.status("Restoring model clipping...", blankAfter=0) restoreModelClip(clipPlaneInfo) replyobj.status("Restoring remaining extension info...", blankAfter=0) try: restoreRemainder() except: reportRestoreError("Error restoring post-model state") from SimpleSession.versions.v29 import makeAfterModelsCBs makeAfterModelsCBs() from SimpleSession.versions.v29 import endRestore replyobj.status('Finishing restore...', blankAfter=0) endRestore() replyobj.status('Restore finished.')