def _sessionCB(self, trigName, myData, sesFile):
        from SimpleSession import sessionID
        data = (1, sessionID(self.residue), self.resType,
                [sessionID(rot) for rot in self.rotamers], self.bbdep,
                self.lib.displayName, self.rotTable.getRestoreInfo())
        print >> sesFile, """
try:
	from Rotamers.gui import sessionRestore
	sessionRestore(%s)
except:
	reportRestoreError('Error restoring Rotamers')
""" % repr(data)
示例#2
0
	def _sessionCB(self, trigName, myData, sesFile):
		from SimpleSession import sessionID
		data = (1, sessionID(self.residue), self.resType,
			[sessionID(rot) for rot in self.rotamers], self.bbdep,
			self.lib.displayName, self.rotTable.getRestoreInfo())
		print>>sesFile, """
try:
	from Rotamers.gui import sessionRestore
	sessionRestore(%s)
except:
	reportRestoreError('Error restoring Rotamers')
""" % repr(data)
示例#3
0
    def _sessionSave(self, trigger, myData, session):
        if not self.rotations:
            return

        from SimpleSession import sesRepr, sessionID
        print >> session, """info = %s
try:
	from BondRotMgr import bondRotMgr
	bondRotMgr._sessionRestore(info)
except:
	reportRestoreError("Error restoring bond rotations")
""" % sesRepr([(sessionID(br.bond), sessionID(br.anchorSide), br.get(), br.id)
               for br in self.rotations.values()])
示例#4
0
	def _sessionAngleSaveCB(self, trigName, myData, sessionFile):
		from SimpleSession import sessionID, sesRepr
		sesData = []
		for atoms in self.angleInfo:
			sesData.append([sessionID(a) for a in atoms])
		print>>sessionFile, "angleInfo = %s" % sesRepr(sesData)
		print>>sessionFile, """
示例#5
0
def model_id(model):

  if model is None or model.was_deleted:
    return None

  from SimpleSession import sessionID
  try:
    id = sessionID(model)
  except Exception:
    id = (model.id, model.subid, model.name)
  return id
示例#6
0
 def _sessionSaveCB(self, triggerName, myData, sessionFile):
     sesData = dict()
     sesData["version"] = 1
     sesData["molecule"] = sessionID(self.molecule)
     sesData["atoms"] = [sessionID(a) for a in self.atoms]
     modeData = list()
     if self.modeNumber == False:
         for nmp in self.modeData:
             modeData.append((nmp.active, nmp.frequency,
                              [v.data() for v in nmp.displacements]))
     else:
         n = 0
         while n < int(self.modeText.getvalue()):
             print n, self.modeText.getvalue()
             modeData.append(
                 (self.modeData[n].active, self.modeData[n].frequency,
                  [v.data() for v in self.modeData[n].displacements]))
             n += 1
     sesData["modeData"] = modeData
     print >> sessionFile, "nmtData = %s" % pickled(sesData)
     print >> sessionFile, """
def _saveSessionCB(trigName, myArg, session):
    from SimpleSession import sessionID, sesRepr
    info = []
    for seq, mav in _seqInspectors.items():
        info.append((seq.name, sessionID(seq.molecule),
                     [seq.saveInfo() for seq in mav.seqs], mav.saveInfo()))
    print >> session, """
try:
	from ModelPanel import restoreSeqInspectors
	restoreSeqInspectors(%s)
except:
	reportRestoreError("Error restoring sequence viewers")
""" % sesRepr(info)
示例#8
0
def _saveSessionCB(trigName, myArg, session):
	from SimpleSession import sessionID, sesRepr
	info = []
	for seq, mav in _seqInspectors.items():
		info.append((seq.name, sessionID(seq.molecule),
			[seq.saveInfo() for seq in mav.seqs], mav.saveInfo()))
	print>>session, """
try:
	from ModelPanel import restoreSeqInspectors
	restoreSeqInspectors(%s)
except:
	reportRestoreError("Error restoring sequence viewers")
""" % sesRepr(info)
 def _sessionData(self):
     from SimpleSession import sessionID, colorID
     axisData = {}
     for axis, sel in self.axisData.items():
         axisData[(
             axis.number,
             axis.name,
             0,  # used to be cmpVal
             axis.radius,
             colorID(axis.model.color),
             axis.extents,
             axis.center.data(),
             axis.direction.data())] = [sessionID(a) for a in sel.atoms()]
     return axisData
示例#10
0
	def _sessionCB(self, trigger, myData, sesFile):
		from SimpleSession import sessionID
		data = (1,					# version
			self.title,				# title
			[ sessionID(m) for m in self.molList ],	# molecules
			[ m.modbaseInfo for m in self.molList ],# stats
			self.modBaseTable.getRestoreInfo())	# GUI
		print >> sesFile, """
try:
	from ModBase.gui import sessionRestore
	sessionRestore(%s)
except:
	reportRestoreError("Error restoring ModBase")
""" % repr(data)
示例#11
0
    def state_from_link(self, link):

        l = link
        self.marker_id_1 = l.marker1.id
        self.marker_id_2 = l.marker2.id
        from SimpleSession import sessionID
        self.bond_session_id = sessionID(l.bond)
        self.displayed = l.bond.display
        self.rgba = l.rgba(allow_none=True)
        self.radius = l.radius()
        if hasattr(l, 'extra_attributes'):  # from XML file
            self.extra_attributes = l.extra_attributes
        else:
            self.extra_attributes = None
示例#12
0
  def state_from_link(self, link):

    l = link
    self.marker_id_1 = l.marker1.id
    self.marker_id_2 = l.marker2.id
    from SimpleSession import sessionID
    self.bond_session_id = sessionID(l.bond)
    self.displayed = l.bond.display
    self.rgba = l.rgba(allow_none = True)
    self.radius = l.radius()
    if hasattr(l, 'extra_attributes'):		# from XML file
      self.extra_attributes = l.extra_attributes
    else:
      self.extra_attributes = None
	def _sessionData(self):
		from SimpleSession import sessionID, colorID
		planeData = {}
		for plane, sel in self.planeData.items():
			planeData[(
				plane.number,
				plane.name,
				0, # used to be cmpVal
				plane.radius,
				plane.thickness,
				colorID(plane.model.color),
				plane.plane.origin.data(),
				plane.plane.normal.data()
			)] = [sessionID(a) for a in sel.atoms()]
		return planeData
示例#14
0
  def state_from_marker_set(self, marker_set):

    ms = marker_set
    self.name = ms.name

    if ms.molecule:
      from SessionUtil.stateclasses import Model_State
      self.marker_model = Model_State()
      self.marker_model.state_from_model(ms.molecule)
      from SimpleSession import sessionID
      self.molecule_session_id = sessionID(ms.molecule)
      self.color = ms.molecule.color.rgba()
    else:
      self.marker_model = None
      self.molecule_session_id = None
      self.color = None

    if ms.curve_model:
      from SessionUtil.stateclasses import Model_State
      cm = Model_State()
      cm.state_from_model(ms.curve_model)
      self.curve_parameters = ms.curve_parameters
      self.curve_model = cm
    else:
      self.curve_model = None
      self.curve_parameters = None

    self.next_marker_id = ms.next_marker_id
    self.file_path = ms.file_path

    self.markers = []
    for m in ms.markers():
      s = Marker_State()
      s.state_from_marker(m)
      self.markers.append(s)

    self.links = []
    for l in ms.links():
      s = Link_State()
      s.state_from_link(l)
      self.links.append(s)

    if hasattr(ms, 'extra_attribtues'):		# from reading XML
      self.extra_attributes = ms.extra_attributes
    else:
      self.extra_attributes = None
示例#15
0
    def state_from_marker(self, marker):

        m = marker
        self.id = m.id
        from SimpleSession import sessionID
        self.atom_session_id = sessionID(m.atom)
        self.displayed = m.atom.display
        self.xyz = m.xyz()
        self.rgba = m.rgba(allow_none=True)
        self.radius = m.radius()
        self.note = m.note()
        self.note_rgba = m.note_rgba()
        self.note_shown = m.note_shown()
        if hasattr(m, 'extra_attributes'):  # from XML file
            self.extra_attributes = m.extra_attributes
        else:
            self.extra_attributes = None
示例#16
0
    def state_from_marker_set(self, marker_set):

        ms = marker_set
        self.name = ms.name

        if ms.molecule:
            from SessionUtil.stateclasses import Model_State
            self.marker_model = Model_State()
            self.marker_model.state_from_model(ms.molecule)
            from SimpleSession import sessionID
            self.molecule_session_id = sessionID(ms.molecule)
            self.color = ms.molecule.color.rgba()
        else:
            self.marker_model = None
            self.molecule_session_id = None
            self.color = None

        if ms.curve_model:
            from SessionUtil.stateclasses import Model_State
            cm = Model_State()
            cm.state_from_model(ms.curve_model)
            self.curve_parameters = ms.curve_parameters
            self.curve_model = cm
        else:
            self.curve_model = None
            self.curve_parameters = None

        self.next_marker_id = ms.next_marker_id
        self.file_path = ms.file_path

        self.markers = []
        for m in ms.markers():
            s = Marker_State()
            s.state_from_marker(m)
            self.markers.append(s)

        self.links = []
        for l in ms.links():
            s = Link_State()
            s.state_from_link(l)
            self.links.append(s)

        if hasattr(ms, 'extra_attribtues'):  # from reading XML
            self.extra_attributes = ms.extra_attributes
        else:
            self.extra_attributes = None
示例#17
0
  def state_from_marker(self, marker):

    m = marker
    self.id = m.id
    from SimpleSession import sessionID
    self.atom_session_id = sessionID(m.atom)
    self.displayed = m.atom.display
    self.xyz = m.xyz()
    self.rgba = m.rgba(allow_none = True)
    self.radius = m.radius()
    self.note = m.note()
    self.note_rgba = m.note_rgba()
    self.note_shown = m.note_shown()
    if hasattr(m, 'extra_attributes'):		# from XML file
      self.extra_attributes = m.extra_attributes
    else:
      self.extra_attributes = None
示例#18
0
	def _sessionSaveCB(self, trigName, myData, sessionFile):
		from SimpleSession import sesRepr, sessionID
		targetMap = {}
		for surfMap in self._surfMap.values():
			for atom, pieceMap in surfMap.items():
				if not isinstance(atom, Atom):
					continue
				colors = []
				for geom in ["ellipsoid", "axes", "ellipses"]:
					if pieceMap.get(geom, None):
						color = pieceMap[geom][0].color
					else:
						color = None
					colors.append(color)
				targetMap.setdefault((pieceMap["anisoParams"],
					tuple(colors)), []).append(sessionID(atom))
		print>>sessionFile, "targetMap = %s" % sesRepr(targetMap)
		print>>sessionFile, """
示例#19
0
def saveSession(trigger, data, f):
	import scaling, xsection, atoms
	import chimera
	from SimpleSession import sessionID, sesRepr, autoRestorable
	userScalings = scaling.sessionSaveUsed()
	userXSections = xsection.sessionSaveUsed()
	userResidueClasses = atoms.sessionSaveUsed()
	residueData = []
	for m in chimera.openModels.list(modelTypes=[chimera.Molecule]):
		if not autoRestorable(m):
			continue
		for r in m.residues:
			ident = sessionID(r)
			sc = scaling.sessionSaveResidue(r)
			xs = xsection.sessionSaveResidue(r)
			rc = atoms.sessionSaveResidue(r)
			residueData.append((ident, sc, xs, rc))
	restoringCode = \
"""
def restoreSession_RibbonStyleEditor():
	import SimpleSession
	import RibbonStyleEditor
	userScalings = %s
	userXSections = %s
	userResidueClasses = %s
	residueData = %s
	flags = RibbonStyleEditor.NucleicDefault1
	SimpleSession.registerAfterModelsCB(RibbonStyleEditor.restoreState,
				(userScalings, userXSections,
				userResidueClasses, residueData, flags))
try:
	restoreSession_RibbonStyleEditor()
except:
	reportRestoreError("Error restoring RibbonStyleEditor state")
"""
	f.write(restoringCode % (sesRepr(userScalings), sesRepr(userXSections),
			sesRepr(userResidueClasses), sesRepr(residueData)))