예제 #1
0
    def RMSDSepInternal(self, simp_R, simp_L, simp_Rp, simp_Lp, also_separate,
                        fail_on_error):
        """Refactored to differentiate RMSDSep and RMSDSepSelf."""
        eprint('%s: %d vs %d' %
               (simp_R, pymol.cmd.count_atoms(simp_R), len(self._cont_R)))
        eprint('%s: %d vs %d' %
               (simp_Rp, pymol.cmd.count_atoms(simp_Rp), len(self._cont_Rp)))
        eprint('%s: %d vs %d' %
               (simp_L, pymol.cmd.count_atoms(simp_L), len(self._cont_L)))
        eprint('%s: %d vs %d' %
               (simp_Lp, pymol.cmd.count_atoms(simp_Lp), len(self._cont_Lp)))
        if not eassert(pymol.cmd.count_atoms(simp_R) == len(self._cont_R),
                       'number of atoms in contact selection bad for gold:R',
                       fail_on_error=fail_on_error):
            return None
        if not eassert(pymol.cmd.count_atoms(simp_Rp) == len(self._cont_Rp),
                       'number of atoms in contact selection bad for test:R',
                       fail_on_error=fail_on_error):
            return None
        if not eassert(pymol.cmd.count_atoms(simp_L) == len(self._cont_L),
                       'number of atoms in contact selection bad for gold:L',
                       fail_on_error=fail_on_error):
            return None
        if not eassert(pymol.cmd.count_atoms(simp_Lp) == len(self._cont_Lp),
                       'number of atoms in contact selection bad for test:L',
                       fail_on_error=fail_on_error):
            return None

        if also_separate:
            return (pymol.cmd.pair_fit(simp_R, simp_Rp, simp_L, simp_Lp),
                    pymol.cmd.pair_fit(simp_R, simp_Rp),
                    pymol.cmd.pair_fit(simp_L, simp_Lp))
        return pymol.cmd.pair_fit(simp_R, simp_Rp, simp_L, simp_Lp)
def RunMols(args, separated):
  if separated:
    runner = SeparateMols(args)
  else:
    runner = TogetherMols(args)

  alnr = PyMolAligner('pR', 'pRp', 'pL', 'pLp', args.dist,
      args.fail_on_missing_atoms)

  lig_files = runner.GetLigandModels()
  rec_files = runner.GetReceptorModels()
  eprint('ligs are', lig_files)
  eprint('recs are', rec_files)
  eassert(len(lig_files) == len(rec_files),
      'you didn\'t specify the correct number of rec/lig files!')

  # Test with a single one because Pool hides traceback.
  if utils._VERBOSE:
    RunSingle((runner, alnr, lig_files[0], rec_files[0]))

  p = Pool(args.nproc)
  all_rms = p.map(RunSingle, [(runner, alnr, lig_files[i], rec_files[i]) for i in
    range(len(lig_files))])

  for i in range(len(lig_files)):
    print('%s %f' % all_rms[i])
예제 #3
0
 def RMSDTog(self, prot):
     """Returns the RMSD between gold and test, specifying a single structure and
 getting R+L from chains."""
     simp_R = utils.SimplifySelection(self._protR, self._cont_R)
     simp_Rp = utils.SimplifySelection(prot, self._cont_Rp)
     simp_L = utils.SimplifySelection(self._protL, self._cont_L)
     simp_Lp = utils.SimplifySelection(prot, self._cont_Lp)
     eprint('%s: %d vs %d' %
            (simp_R, pymol.cmd.count_atoms(simp_R), len(self._cont_R)))
     eprint('%s: %d vs %d' %
            (simp_Rp, pymol.cmd.count_atoms(simp_Rp), len(self._cont_Rp)))
     eprint('%s: %d vs %d' %
            (simp_L, pymol.cmd.count_atoms(simp_L), len(self._cont_L)))
     eprint('%s: %d vs %d' %
            (simp_Lp, pymol.cmd.count_atoms(simp_Lp), len(self._cont_Lp)))
     eassert(
         pymol.cmd.count_atoms(simp_R) == len(self._cont_R),
         'number of atoms in contact selection bad for gold:R')
     eassert(
         pymol.cmd.count_atoms(simp_Rp) == len(self._cont_Rp),
         'number of atoms in contact selection bad for test:R')
     eassert(
         pymol.cmd.count_atoms(simp_L) == len(self._cont_L),
         'number of atoms in contact selection bad for gold:L')
     eassert(
         pymol.cmd.count_atoms(simp_Lp) == len(self._cont_Lp),
         'number of atoms in contact selection bad for test:L')
     return pymol.cmd.pair_fit(simp_R, simp_Rp, simp_L, simp_Lp)
예제 #4
0
def _fixContact(contact, contact_idx, aln_list, fatal_missing):
    # Remove things that align with nothing in the other sequence.
    no_align = []
    for i, x in enumerate(contact_idx):
        if aln_list[x] == -1:
            no_align.append(i)
    for i, x in enumerate(no_align):
        # Each thing we delete will reduce the position by 1.
        eprint('Deleting contact at position %d=%d' % (x, contact_idx[x - i]))
        if fatal_missing:
            eassert(
                False,
                'Error aligning to a gap! Remove --fail_on_missing_atoms '
                'to continue.')

        del contact[x - i]
        del contact_idx[x - i]

    return (contact, contact_idx)
예제 #5
0
    def FullRMSDSep(self, rec, lig):
        full_idx_R = []
        full_sel_R = []
        for i, x in enumerate(self._aln_list_R):
            if x != -1:
                full_idx_R.append(i)
                full_sel_R.append(self._full_R[i])

        full_idx_L = []
        full_sel_L = []
        for i, x in enumerate(self._aln_list_L):
            if x != -1:
                full_idx_L.append(i)
                full_sel_L.append(self._full_L[i])

        full_sel_Rp = _testContactRes(self._aln_list_R, full_idx_R,
                                      self._full_Rp)
        full_sel_Lp = _testContactRes(self._aln_list_L, full_idx_L,
                                      self._full_Lp)

        simp_R = utils.SimplifySelection(self._protR, full_sel_R)
        simp_Rp = utils.SimplifySelection(rec, full_sel_Rp)
        simp_L = utils.SimplifySelection(self._protL, full_sel_L)
        simp_Lp = utils.SimplifySelection(lig, full_sel_Lp)
        eprint('%s: %d vs %d' %
               (simp_R, pymol.cmd.count_atoms(simp_R), len(full_sel_R)))
        eprint('%s: %d vs %d' %
               (simp_Rp, pymol.cmd.count_atoms(simp_Rp), len(full_sel_Rp)))
        eprint('%s: %d vs %d' %
               (simp_L, pymol.cmd.count_atoms(simp_L), len(full_sel_L)))
        eprint('%s: %d vs %d' %
               (simp_Lp, pymol.cmd.count_atoms(simp_Lp), len(full_sel_Lp)))
        eassert(
            pymol.cmd.count_atoms(simp_R) == len(full_sel_R),
            'number of atoms in contact selection bad for gold:R')
        eassert(
            pymol.cmd.count_atoms(simp_Rp) == len(full_sel_Rp),
            'number of atoms in contact selection bad for test:R')
        eassert(
            pymol.cmd.count_atoms(simp_L) == len(full_sel_L),
            'number of atoms in contact selection bad for gold:L')
        eassert(
            pymol.cmd.count_atoms(simp_Lp) == len(full_sel_Lp),
            'number of atoms in contact selection bad for test:L')

        return (pymol.cmd.pair_fit(simp_R, simp_Rp, simp_L, simp_Lp),
                pymol.cmd.pair_fit(simp_R, simp_Rp),
                pymol.cmd.pair_fit(simp_L, simp_Lp))
예제 #6
0
def _testContactRes(aln_list, contact_idx, full_seq):
    """From the alignment list, aln_list, get the contact residue indices for
  the test seq (similar to getContactResIndx for gold).

  Arguments:
    aln_list: alignment list from getAlignmentList
    contact_idx: contact residue indices for gold
    full_seq: the tuple (from getFullRes) representing the full sequence
       for this test protein.
  
  """
    test_cont = []
    for x in contact_idx:
        # This means it aligns to nothing--will cause the number of atoms in
        # test and gold to be different (bad for RMS).
        eassert(aln_list[x] != -1,
                'shouldn\'t align to nothing! at pos %d:%d' % (x, aln_list[x]))

        #eprint(' - test appending x=%d, len %d,%d'
        #    %(x, len(full_seq), len(aln_list)))
        #eprint('   which is', aln_list[x], full_seq[aln_list[x]])
        test_cont.append(full_seq[aln_list[x]])
    return test_cont
  def __init__(self, args):
    utils.load_pdb(args.gold_p, 'goldp')
    utils.load_pdb(args.test_p, 'testp')

    eprint('goldp & chain %s' % '+'.join(args.gold_rec_chains))
    cmd.create('pR', 'goldp & chain %s' % '+'.join(args.gold_rec_chains))
    cmd.create('pL', 'goldp & chain %s' % '+'.join(args.gold_lig_chains))
    cmd.create('pRp', 'testp & chain %s' % '+'.join(args.test_rec_chains))
    cmd.create('pLp', 'testp & chain %s' % '+'.join(args.test_lig_chains))
    eassert(cmd.count_atoms('pR') > 0, 'no atoms in gold:R')
    eassert(cmd.count_atoms('pL') > 0, 'no atoms in gold:L')
    eassert(cmd.count_atoms('pRp') > 0, 'no atoms in test:R')
    eassert(cmd.count_atoms('pLp') > 0, 'no atoms in test:L')
    for obj in cmd.get_names():
      eprint('obj is %s' % obj)
    self._gold_rec_chains = args.gold_rec_chains
    self._gold_lig_chains = args.gold_lig_chains
    self._test_rec_chains = args.test_rec_chains
    self._test_lig_chains = args.test_lig_chains

    self._test_confs = getRegexFiles(args.test_confs, args.input_fn)