예제 #1
0
  def show_constraints(self, mardi_path, pdb_path):

    midas.process(self.session).unshow_objects('constraints')

    if not mardi_path or not pdb_path:
      return

    show_satisfied = self.satisfied.get()
    show_violated = self.violated.get()
    if not (show_satisfied or show_violated):
      return
    
    lines = midas.midas_object_file('constraints')
    model = pdb.model(self.session, pdb_path)
    mardi = mardigras.bounds(self.session, mardi_path)
    for (num_atom_1, num_atom_2), (rmin, rmax) in mardi.bounds_table.items():
      num_atom_1 = translate_atom_name(num_atom_1, mardi, model)
      num_atom_2 = translate_atom_name(num_atom_2, mardi, model)
      pdb_atom_1 = model.num_atom_to_pdb_atom(num_atom_1)
      pdb_atom_2 = model.num_atom_to_pdb_atom(num_atom_2)
      if pdb_atom_1 and pdb_atom_2:
        d = pyutil.distance(pdb_atom_1.xyz, pdb_atom_2.xyz)
        if ((show_satisfied and d >= rmin and d <= rmax) or
            (show_violated and (d < rmin or d > rmax))):
          if d < .8 * rmin:	color = 'blue'
          elif d < rmin:	color = 'cyan'
          elif d <= rmax:	color = 'green'
          elif d < 1.2 * rmax:	color = 'magenta'
          else:			color = 'red'
          pdb_atom_1 = model.num_atom_to_pdb_atom(num_atom_1)
          pdb_atom_2 = model.num_atom_to_pdb_atom(num_atom_2)
	  lines.add_line(pdb_atom_1.xyz, pdb_atom_2.xyz, color)

    lines.show_objects(self.session)
예제 #2
0
    def chimera_open_model(self, pdb_path):

        if pdb_path == self.pdb_path:
            return

        if self.model:
            chimera = self.chimera()
            chimera.openModels.close([self.model])
            self.model = None
            # I suspect closing the model also eliminates all constraint pseudobonds
            self.num_atom_pair_to_pseudobond = {}

        self.pdb_path = pdb_path
        chimera = self.chimera()
        models = chimera.openModels.open(pdb_path, type='PDB')
        self.model = models[0]  # assume just one molecule in the PDB file
        self.model.color = chimera.Color_lookup('gray')

        trans = pdb.model(self.session, pdb_path).atom_translations
        self.make_atom_tables(self.model.atoms, trans)

        if self.pseudobond_group == None:
            m = chimera.PseudoBondMgr_mgr()
            self.pseudobond_group = m.newPseudoBondGroup('NOESY constraints')
            del m

        chimera.openModels.add([self.pseudobond_group], sameAs=self.model)
예제 #3
0
    def show_constraint_lines(self, mardi_path, pdb_path, range_colors):

        # unshow previous constraints

        if not mardi_path or not pdb_path:
            return

        show_satisfied = self.show_satisfied.get()
        show_violated = self.show_violated.get()
        if not (show_satisfied or show_violated):
            return

        pdb_model = pdb.model(self.session, pdb_path)
        mardi = mardigras.bounds(self.session, mardi_path)
        for (num_atom_1, num_atom_2), (rmin,
                                       rmax) in mardi.bounds_table.items():
            num_atom_1 = translate_atom_name(num_atom_1, mardi, pdb_model)
            num_atom_2 = translate_atom_name(num_atom_2, mardi, pdb_model)
            pdb_atom_1 = pdb_model.num_atom_to_pdb_atom(num_atom_1)
            pdb_atom_2 = pdb_model.num_atom_to_pdb_atom(num_atom_2)
            if pdb_atom_1 and pdb_atom_2:
                d = pyutil.distance(pdb_atom_1.xyz, pdb_atom_2.xyz)
                if ((show_satisfied and d >= rmin and d <= rmax)
                        or (show_violated and (d < rmin or d > rmax))):
                    if d < .8 * rmin: color = range_colors[0]
                    elif d < rmin: color = range_colors[1]
                    elif d <= rmax: color = range_colors[2]
                    elif d < 1.2 * rmax: color = range_colors[3]
                    else: color = range_colors[4]
                    self.show_constraint(num_atom_1, num_atom_2, color)
예제 #4
0
  def show_constraint_lines(self, mardi_path, pdb_path, range_colors):

    # unshow previous constraints

    if not mardi_path or not pdb_path:
      return

    show_satisfied = self.show_satisfied.get()
    show_violated = self.show_violated.get()
    if not (show_satisfied or show_violated):
      return
    
    pdb_model = pdb.model(self.session, pdb_path)
    mardi = mardigras.bounds(self.session, mardi_path)
    for (num_atom_1, num_atom_2), (rmin, rmax) in mardi.bounds_table.items():
      num_atom_1 = translate_atom_name(num_atom_1, mardi, pdb_model)
      num_atom_2 = translate_atom_name(num_atom_2, mardi, pdb_model)
      pdb_atom_1 = pdb_model.num_atom_to_pdb_atom(num_atom_1)
      pdb_atom_2 = pdb_model.num_atom_to_pdb_atom(num_atom_2)
      if pdb_atom_1 and pdb_atom_2:
        d = pyutil.distance(pdb_atom_1.xyz, pdb_atom_2.xyz)
        if ((show_satisfied and d >= rmin and d <= rmax) or
            (show_violated and (d < rmin or d > rmax))):
          if d < .8 * rmin:	color = range_colors[0]
          elif d < rmin:	color = range_colors[1]
          elif d <= rmax:	color = range_colors[2]
          elif d < 1.2 * rmax:	color = range_colors[3]
          else:			color = range_colors[4]
	  self.show_constraint(num_atom_1, num_atom_2, color)
예제 #5
0
  def chimera_open_model(self, pdb_path):
      
    if pdb_path == self.pdb_path:
      return

    if self.model:
      chimera = self.chimera()
      chimera.openModels.close([self.model])
      self.model = None
      # I suspect closing the model also eliminates all constraint pseudobonds
      self.num_atom_pair_to_pseudobond = {}

    self.pdb_path = pdb_path
    chimera = self.chimera()
    models = chimera.openModels.open(pdb_path, type='PDB')
    self.model = models[0]    # assume just one molecule in the PDB file
    self.model.color = chimera.Color_lookup('gray')

    trans = pdb.model(self.session, pdb_path).atom_translations
    self.make_atom_tables(self.model.atoms, trans)

    if self.pseudobond_group == None:
      m = chimera.PseudoBondMgr_mgr()
      self.pseudobond_group = m.newPseudoBondGroup('NOESY constraints')
      del m

    chimera.openModels.add([self.pseudobond_group], sameAs = self.model)
예제 #6
0
def assigned_pdb_atoms(session, pdb_path, condition):

    assigned = []
    model = pdb.model(session, pdb_path)
    for a in model.pdb_atoms:
        if model.find_resonance(a, condition):
            assigned.append(a)
    return assigned
예제 #7
0
def assigned_pdb_atoms(session, pdb_path, condition):

  assigned = []
  model = pdb.model(session, pdb_path)
  for a in model.pdb_atoms:
    if model.find_resonance(a, condition):
      assigned.append(a)
  return assigned
예제 #8
0
  def get_models(self, pdb_paths):

    models = []
    bad_paths = ''
    for pdb_path in pdb_paths:
      model = pdb.model(self.session, pdb_path)
      if model == None:
        bad_paths = bad_paths + pdb_path + '\n'
      else:
        models.append(model)
    if bad_paths:
      self.progress_report("Couldn't open\n" + bad_paths)
    return models
예제 #9
0
    def get_models(self, pdb_paths):

        models = []
        bad_paths = ''
        for pdb_path in pdb_paths:
            model = pdb.model(self.session, pdb_path)
            if model == None:
                bad_paths = bad_paths + pdb_path + '\n'
            else:
                models.append(model)
        if bad_paths:
            self.progress_report("Couldn't open\n" + bad_paths)
        return models
예제 #10
0
  def midas_pick_to_pdb_atom(self, midas_atom_spec):

    match = re.match('(#)(\d+)(:)(\d+)(@)(.+)', midas_atom_spec)
    if match:
      g = match.groups()
      model_number = string.atoi(g[1])
      path = self.model_path(model_number)
      if path:
        residue_number = string.atoi(g[3])
        atom_name = g[5]
        model = pdb.model(self.session, path)
        num_atom = (residue_number, atom_name)
        pdb_atom = model.num_atom_to_pdb_atom(num_atom)
	return model, pdb_atom

    return None, None
예제 #11
0
    def midas_pick_to_pdb_atom(self, midas_atom_spec):

        match = re.match('(#)(\d+)(:)(\d+)(@)(.+)', midas_atom_spec)
        if match:
            g = match.groups()
            model_number = string.atoi(g[1])
            path = self.model_path(model_number)
            if path:
                residue_number = string.atoi(g[3])
                atom_name = g[5]
                model = pdb.model(self.session, path)
                num_atom = (residue_number, atom_name)
                pdb_atom = model.num_atom_to_pdb_atom(num_atom)
                return model, pdb_atom

        return None, None
예제 #12
0
 def initialize(self, session, peaks, stoppable):
   self.models = []
   for pdb_path in self.pdb_path_list:
     m = pdb.model(session, pdb_path, stoppable)	# read pdb files
     self.models.append(m)
예제 #13
0
 def initialize(self, session, peaks, stoppable):
     self.models = []
     for pdb_path in self.pdb_path_list:
         m = pdb.model(session, pdb_path, stoppable)  # read pdb files
         self.models.append(m)