Exemple #1
0
def test_add_missing_atoms():
    cmd.reinitialize()
    cmd.load(DATA_PATH / '2x19-frag-mse.pdb')
    cmd.remove("not backbone")
    assert cmd.count_atoms("resi 132") == 4
    psico.modelling.add_missing_atoms('resi 132+133', cycles=10)
    assert cmd.count_atoms("resi 132") == 8
Exemple #2
0
    def testCifMissing(self):
        N = 7
        cmd.fragment('gly', 'm1')
        cmd.alter('all', '(chain, segi, resv, alt) = ("?", ".", 5, "")')

        s = cmd.get_str('cif')
        self.assertTrue("'?'" in s or '"?"' in s)  # chain
        self.assertTrue("'.'" in s or '"."' in s)  # segi
        self.assertTrue(' ? ' in s)  # e.g. pdbx_PDB_ins_code
        self.assertTrue(' . ' in s)  # e.g. label_alt_id

        cmd.delete('*')
        cmd.set('cif_keepinmemory')
        cmd.load(s, 'm2', format='cifstr')
        self.assertEqual(['?'], cmd.get_chains())
        self.assertEqual(cmd.count_atoms('segi .'), N)
        self.assertEqual(cmd.count_atoms('alt ""'), N)  # no alt
        self.assertEqual(cmd.count_atoms('resi 5'), N)  # no ins_code

        from pymol.querying import cif_get_array
        self.assertEqual(cif_get_array("m2", "_atom_site.type_symbol"),
                         list('NCCOHHH'))
        self.assertEqual(cif_get_array("m2", "_atom_site.id", "i"),
                         list(range(1, N + 1)))
        self.assertEqual(cif_get_array("m2", "_atom_site.auth_asym_id"),
                         ['?'] * N)
        self.assertEqual(cif_get_array("m2", "_atom_site.label_asym_id"),
                         ['.'] * N)
        self.assertEqual(cif_get_array("m2", "_atom_site.pdbx_pdb_ins_code"),
                         [None] * N)
        self.assertEqual(cif_get_array("m2", "_atom_site.label_alt_id"),
                         [None] * N)
Exemple #3
0
 def testShow(self):
     cmd.fragment('ala')
     self.assertEqual(cmd.count_atoms('rep sticks'), 0)
     cmd.show('sticks')
     self.assertEqual(cmd.count_atoms('rep sticks'), 10)
     cmd.hide('lines', 'not elem C')
     self.assertEqual(cmd.count_atoms('rep lines'), 3)
Exemple #4
0
 def testIndicate(self):
     cmd.load(self.datafile("1oky.pdb.gz"), "m1")
     cmd.indicate("polymer")
     self.assertEquals(cmd.count_atoms("polymer"),
                       cmd.count_atoms("indicate"))
     self.assertEquals(
         cmd.count_atoms("indicate & solvent & organic & inorganic"), 0)
    def testMultifilesave(self):
        import glob

        for name in ['ala', 'gly', 'his', 'arg']:
            cmd.fragment(name)

        # multistate
        for i in range(2, 11):
            cmd.create('ala', 'ala', 1, i)

        for fmt in ['{}-{:02}.cif', '{}-{state}.cif']:
            with testing.mkdtemp() as dirname:
                cmd.multifilesave(os.path.join(dirname, fmt), 'ala', 0)
                filenames = [os.path.basename(p) for p in glob.glob(os.path.join(dirname, '*.cif'))]
                self.assertEqual(len(filenames), 10)
                self.assertTrue('ala-03.cif' in filenames)

        with testing.mkdtemp() as dirname:
            cmd.multifilesave(os.path.join(dirname, '{}.pdb'), 'a* g*')
            filenames_full = sorted(glob.glob(os.path.join(dirname, '*.pdb')))
            filenames = [os.path.basename(p) for p in filenames_full]
            self.assertEqual(filenames, ['ala.pdb', 'arg.pdb', 'gly.pdb'])

            cmd.delete('*')
            cmd.load(filenames_full[0])
            self.assertEqual(cmd.count_atoms(), 10)

            cmd.delete('*')
            cmd.load(filenames_full[1])
            self.assertEqual(cmd.count_atoms(), 24)
Exemple #6
0
def output_protein_info_data(output_protein_info, this_PDB_file, \
                             distances_from_A_interface_center, euc_dist_Aterms_iface_0, euc_dist_Aterms_iface_1, \
                             distances_from_B_interface_center, euc_dist_Bterms_iface_0, euc_dist_Bterms_iface_1):
  # data for chain A
  A_n_res       = cmd.count_atoms("chain A & name CA")
  A_n_res_iface = cmd.count_atoms("A_interface and name CA")
  A_center_iface_CA            = distances_from_A_interface_center[2][0].split("/")[4].split("`")[1]  # get the closest CA
  A_center_farthest_iface_CA   = distances_from_A_interface_center[-1][0].split("/")[4].split("`")[1] # get farthest interface CA residue from the interface center (and distance)
  d_A_center_iface_CA          = "%.1f" % distances_from_A_interface_center[2][4]                     # get the distance
  d_A_center_farthest_iface_CA = "%.1f" % distances_from_A_interface_center[-1][4]
  # data for chain B
  B_n_res       = cmd.count_atoms("chain B & name ca")
  B_n_res_iface = cmd.count_atoms("B_interface and name CA")
  B_center_iface_CA            = distances_from_B_interface_center[2][0].split("/")[4].split("`")[1]  # get the closest CA
  B_center_farthest_iface_CA   = distances_from_B_interface_center[-1][0].split("/")[4].split("`")[1] # get farthest interface CA residue from the interface center (and distance)
  d_B_center_iface_CA          = "%.1f" % distances_from_B_interface_center[2][4]                     # get the distance
  d_B_center_farthest_iface_CA = "%.1f" % distances_from_B_interface_center[-1][4]
  output_protein_info.write("%s" % this_PDB_file)
  output_protein_info.write("\t%s"*20 % (A_n_res, A_n_res_iface, A_center_iface_CA, d_A_center_iface_CA, A_center_farthest_iface_CA, d_A_center_farthest_iface_CA, \
                                         euc_dist_Aterms_iface_0["N_term_res"], euc_dist_Aterms_iface_1["N_term_res"], \
                                         euc_dist_Aterms_iface_0["C_term_res"], euc_dist_Aterms_iface_1["C_term_res"], \
                                         B_n_res, B_n_res_iface, B_center_iface_CA, d_B_center_iface_CA, B_center_farthest_iface_CA, d_B_center_farthest_iface_CA, \
                                         euc_dist_Bterms_iface_0["N_term_res"], euc_dist_Bterms_iface_1["N_term_res"], \
                                         euc_dist_Bterms_iface_0["C_term_res"], euc_dist_Bterms_iface_1["C_term_res"]) )
  output_protein_info.write("\n")
    def testCifMissing(self):
        N = 7
        cmd.fragment('gly', 'm1')
        cmd.alter('all', '(chain, segi, resv, alt) = ("?", ".", 5, "")')

        s = cmd.get_str('cif')
        self.assertTrue("'?'" in s or '"?"' in s) # chain
        self.assertTrue("'.'" in s or '"."' in s) # segi
        self.assertTrue(' ? ' in s) # e.g. pdbx_PDB_ins_code
        self.assertTrue(' . ' in s) # e.g. label_alt_id

        cmd.delete('*')
        cmd.set('cif_keepinmemory')
        cmd.load(s, 'm2', format='cifstr')
        self.assertEqual(['?'], cmd.get_chains())
        self.assertEqual(cmd.count_atoms('segi .'), N)
        self.assertEqual(cmd.count_atoms('alt ""'), N)  # no alt
        self.assertEqual(cmd.count_atoms('resi 5'), N)  # no ins_code

        from pymol.querying import cif_get_array
        self.assertEqual(cif_get_array("m2", "_atom_site.type_symbol"), list('NCCOHHH'))
        self.assertEqual(cif_get_array("m2", "_atom_site.id", "i"),     list(range(1, N + 1)))
        self.assertEqual(cif_get_array("m2", "_atom_site.auth_asym_id"),        ['?'] * N)
        self.assertEqual(cif_get_array("m2", "_atom_site.label_asym_id"),       ['.'] * N)
        self.assertEqual(cif_get_array("m2", "_atom_site.pdbx_pdb_ins_code"),   [None] * N)
        self.assertEqual(cif_get_array("m2", "_atom_site.label_alt_id"),        [None] * N)
Exemple #8
0
 def testUndoAfterRemoveAtomOnDiscrete(self, discr):
     cmd.set('suspend_undo', 0)
     cmd.load(self.datafile('ligs3d.sdf'), discrete=discr)
     natms = cmd.count_atoms()
     cmd.remove("index 1")
     cmd.undo()
     self.assertEqual(natms, cmd.count_atoms())
Exemple #9
0
def is_amino_acid(selection: str) -> bool:
    """Decide if the selection is a single amino-acid

    :param selection: the selection
    :type selection: str
    :return: True or False
    :rtype: bool
    """
    if not cmd.count_atoms(
            '({}) and name N and symbol N'.format(selection)) == 1:
        # either does not contain a nitrogen called "N" (no amino-acid), or
        # contains more of them (not a single residue)
        return False
    elif not cmd.count_atoms(
            '({}) and name C and symbol C'.format(selection)) == 1:
        # either does not contain a carbon called "C" (no amino-acid),
        # or contains more of them (not a single residue)
        return False
    elif not cmd.count_atoms(
            '({}) and (neighbor (name C and symbol C)) and (name CA and symbol C)'
            .format(selection)) == 1:
        # the "C" atom must have a "CA" neighbour
        return False
    else:
        return True
Exemple #10
0
    def testSaveSelection(self, format, pymol_version):
        if pymol_version > testing.PYMOL_VERSION[1]:
            self.skipTest("version %f" % (pymol_version))

        cmd.fragment('trp', 'm1')
        cmd.fragment('glu', 'm2')

        n_O = cmd.count_atoms('elem O')
        n_N = cmd.count_atoms('elem N')

        with testing.mktemp('.' + format) as filename:
            cmd.set('raise_exceptions',
                    0)  # 1.7.6 save xyz doesn't set r=DEFAULT_SUCCESS
            cmd.save(filename, 'elem O+N')
            cmd.set('raise_exceptions', 1)

            if format == 'mae' and not pymol.invocation.options.incentive_product:
                format = 'cms'

            cmd.delete('*')
            cmd.load(filename, 'm2', discrete=1,
                     format=format)  # avoid merging of atoms

        self.assertEqual(n_O, cmd.count_atoms('elem O'))
        self.assertEqual(n_N, cmd.count_atoms('elem N'))
        self.assertEqual(n_O + n_N, cmd.count_atoms())
Exemple #11
0
def test_polyala():
    cmd.reinitialize()
    cmd.fab('EFG', 'm1')
    psico.editing.polyala()
    assert cmd.count_atoms('name CA') == 3
    assert cmd.count_atoms('name CB') == 2
    assert cmd.count_atoms('name CG+CD+CD1+CD2+2HG+3HG+1HD+2HD') == 0
def get_coord(v):
    if not isinstance(v, str):
        try:
            return v[:3]
        except:
            return False
    if v.startswith('['):
        return cmd.safe_list_eval(v)[:3]
    try:
        if cmd.count_atoms(v) == 1:
            # atom coordinates
            return cmd.get_atom_coords(v)
        else:
            # more than one atom --> use "center"
            # alt check!
            if cmd.count_atoms('(alt *) and not (alt "")') != 0:
                print(
                    "distancetoatom: warning! alternative coordinates found for origin, using center!"
                )
            view_temp = cmd.get_view()
            cmd.zoom(v)
            v = cmd.get_position()
            cmd.set_view(view_temp)
            return v
    except:
        return False
 def testUndoAfterRemoveAtomOnDiscrete(self, discr):
     cmd.set('suspend_undo', 0)
     cmd.load(self.datafile('ligs3d.sdf'), discrete=discr)
     natms = cmd.count_atoms()
     cmd.remove("index 1")
     cmd.undo()
     self.assertEqual(natms, cmd.count_atoms())
    def testMultifilesave(self):
        import glob

        for name in ['ala', 'gly', 'his', 'arg']:
            cmd.fragment(name)

        # multistate
        for i in range(2, 11):
            cmd.create('ala', 'ala', 1, i)

        for fmt in ['{}-{:02}.cif', '{}-{state}.cif']:
            with testing.mkdtemp() as dirname:
                cmd.multifilesave(os.path.join(dirname, fmt), 'ala', 0)
                filenames = [os.path.basename(p) for p in glob.glob(os.path.join(dirname, '*.cif'))]
                self.assertEqual(len(filenames), 10)
                self.assertTrue('ala-03.cif' in filenames)

        with testing.mkdtemp() as dirname:
            cmd.multifilesave(os.path.join(dirname, '{}.pdb'), 'a* g*')
            filenames_full = sorted(glob.glob(os.path.join(dirname, '*.pdb')))
            filenames = [os.path.basename(p) for p in filenames_full]
            self.assertEqual(filenames, ['ala.pdb', 'arg.pdb', 'gly.pdb'])

            cmd.delete('*')
            cmd.load(filenames_full[0])
            self.assertEqual(cmd.count_atoms(), 10)

            cmd.delete('*')
            cmd.load(filenames_full[1])
            self.assertEqual(cmd.count_atoms(), 24)
 def testByRing(self):
     cmd.fragment('trp')
     self.assertEqual(cmd.count_atoms('byring name CB'), 0)
     self.assertEqual(cmd.count_atoms('byring name CG'), 5)
     self.assertEqual(cmd.count_atoms('byring name CD2'), 9)
     self.assertEqual(cmd.count_atoms('byring name CE3'), 6)
     self.assertEqual(cmd.count_atoms('byring all'), 9)
Exemple #16
0
def fSumWMCresidue(molecule, SGNameAngle, chain, residue, MCNeighbour,
                   DieElecMC, MCchargeC, MCchargeO, MCchargeN, MCchargeH,
                   AmideName, printMC):
    # print "residue", MCNeighbour
    SumWMCresidue = 0.0
    SGnameselect = "/" + SGNameAngle + "//" + "/" + "/SG"
    NBnameselect = "/" + molecule + "//" + chain + "/" + str(MCNeighbour)
    cmd.select("MC", NBnameselect)
    MCpdbstr = cmd.get_pdbstr("MC")
    MCsplit = MCpdbstr.split()
    residueName = MCsplit[3]
    # print NBnameselect, residueName
    AmideProt = "/" + molecule + "//" + chain + "/" + str(MCNeighbour) + "/H01"
    Hnameselect = "/" + AmideName + "//" + chain + "/" + str(
        MCNeighbour) + "/H01"
    if cmd.count_atoms(AmideProt) == 0 and cmd.count_atoms(Hnameselect) == 0:
        HbuildSelect = "/" + molecule + "//" + chain + "/" + str(
            MCNeighbour) + "/N"
        cmd.h_add(HbuildSelect)
        cmd.create(AmideName, AmideName + " + " + AmideProt)
        cmd.remove(AmideProt)
    # Mainchain AmideH
    ResDist = cmd.dist(residue + 'distResH', SGnameselect, Hnameselect)
    WMC = fWMC(MCchargeH, DieElecMC, ResDist)
    SumWMCresidue = SumWMCresidue + WMC
    if printMC == 'yes':
        print("MC H ", MCNeighbour, " ", MCchargeH, " ", DieElecMC, " ",
              ResDist, " ", WMC)
    # Mainchain C
    Cnameselect = "/" + molecule + "//" + chain + "/" + str(MCNeighbour) + "/C"
    ResDist = cmd.dist(residue + 'distResC', SGnameselect, Cnameselect)
    WMC = fWMC(MCchargeC, DieElecMC, ResDist)
    SumWMCresidue = SumWMCresidue + WMC
    if printMC == 'yes':
        print("MC C ", MCNeighbour, " ", MCchargeC, " ", DieElecMC, " ",
              ResDist, " ", WMC)
    # Mainchain O
    Onameselect = "/" + molecule + "//" + chain + "/" + str(MCNeighbour) + "/O"
    ResDist = cmd.dist(residue + 'distResO', SGnameselect, Onameselect)
    WMC = fWMC(MCchargeO, DieElecMC, ResDist)
    SumWMCresidue = SumWMCresidue + WMC
    if printMC == 'yes':
        print("MC O ", MCNeighbour, " ", MCchargeO, " ", DieElecMC, " ",
              ResDist, " ", WMC)
    # Mainchain N
    Nnameselect = "/" + molecule + "//" + chain + "/" + str(MCNeighbour) + "/N"
    ResDist = cmd.dist(residue + 'distResN', SGnameselect, Nnameselect)
    WMC = fWMC(MCchargeN, DieElecMC, ResDist)
    SumWMCresidue = SumWMCresidue + WMC
    if printMC == 'yes':
        print("MC N ", MCNeighbour, " ", MCchargeN, " ", DieElecMC, " ",
              ResDist, " ", WMC)
    cmd.delete(residue + 'distResH')
    cmd.delete(residue + 'distResC')
    cmd.delete(residue + 'distResO')
    cmd.delete(residue + 'distResN')
    cmd.show("nb_spheres", AmideName)
    cmd.delete("MC")
    return SumWMCresidue
Exemple #17
0
def check_selections(queue):
    """ Check if the selection made by the user changed """
    global previous_mouse_mode
    global myspace
    while True:
        # Check if the user changed the selection mode (atom/residue/chain/molecule)
        logging.debug("Current mouse selection mode : %d" %
                      int(cmd.get("mouse_selection_mode")))
        logging.debug("Number of selections: %d" %
                      len(cmd.get_names("selections")))
        if int(cmd.get("mouse_selection_mode")) == 5 and len(
                cmd.get_names("selections")) > 0:
            #logging.debug(cmd.get_names("selections")[1])
            nb_selected_objects = cmd.count_atoms('sele')
            if nb_selected_objects > 0:
                logging.info("--- Selection made by the user ---")
                logging.info(nb_selected_objects)
                cmd.iterate('(sele)', 'models.add(model)', space=myspace)
                logging.info(myspace['models'])
                tmp = set()
                # Make the list with unique items
                for i in myspace['models']:
                    if int(i) not in tmp:
                        tmp.add(int(i))
                # Check if the selection has changed
                if tmp != myspace['previous']:
                    myspace['previous'] = tmp
                    queue.put(tmp)
                else:
                    time.sleep(1)
                cmd.select('none')
        elif int(cmd.get("mouse_selection_mode")) == 1 and len(
                cmd.get_names("selections")) > 0:
            #logging.debug(cmd.get_names("selections")[0])

            nb_selected_objects = cmd.count_atoms('sele')
            if nb_selected_objects > 0:
                logging.info("--- Selection made by the user ---")
                cmd.iterate('(sele)', 'residues.add(resv)', space=myspace)
                logging.info(myspace['residues'])
                tmp = set()
                # Make the list with unique items
                for i in myspace['residues']:
                    if int(i) not in tmp:
                        tmp.add(int(i))
                # Check if the selection has changed
                if tmp != myspace['previous']:
                    myspace['previous'] = tmp
                    queue.put(tmp)
                    #cmd.delete('lb')
                else:
                    time.sleep(1)
                cmd.select('none')

        else:
            # if len(cmd.get_names("selections", enabled_only=1)) == 0:
            #     queue.put(set())
            #previous_mouse_mode = cmd.get("mouse_selection_mode")
            time.sleep(0.5)
Exemple #18
0
 def test_protein_nucleic(self):
     npro = 340
     nnuc = 112
     cmd.load(self.datafile("1oky-frag.pdb"), "1p")
     cmd.load(self.datafile('1ehz-5.pdb'), "1n")
     self.assertEqual(cmd.count_atoms('polymer'), npro + nnuc)
     self.assertEqual(cmd.count_atoms('polymer.protein'), npro)
     self.assertEqual(cmd.count_atoms('polymer.nucleic'), nnuc)
 def test_protein_nucleic(self):
     npro = 340
     nnuc = 112
     cmd.load(self.datafile("1oky-frag.pdb"), "1p")
     cmd.load(self.datafile('1ehz-5.pdb'), "1n")
     self.assertEqual(cmd.count_atoms('polymer'), npro + nnuc)
     self.assertEqual(cmd.count_atoms('polymer.protein'), npro)
     self.assertEqual(cmd.count_atoms('polymer.nucleic'), nnuc)
Exemple #20
0
 def test_attach(self):
     cmd.pseudoatom()
     cmd.edit('first all')
     cmd.attach('C', 1, 1)
     self.assertEqual(2, cmd.count_atoms())
     cmd.attach('C', 1, 1)
     self.assertEqual(3, cmd.count_atoms())
     self.assertEqual(['C01', 'C02', 'PS1'], sorted(get_atom_names()))
 def testLoadMMTF(self):
     cmd.load(self.datafile("3njw.mmtf.gz"))
     self.assertEqual(169, cmd.count_atoms())
     self.assertEqual(36, cmd.count_atoms('ss S'))
     self.assertEqual(25, cmd.count_atoms('solvent'))
     symmetry = cmd.get_symmetry()
     self.assertArrayEqual(symmetry[:6], [19.465, 21.432, 29.523, 90.0, 90.0, 90.0], delta=1e-4)
     self.assertEqual(symmetry[6], 'P 21 21 21')
 def testGetSession(self):
     cmd.fragment('ala')
     x = cmd.count_atoms()
     s = cmd.get_session()
     cmd.reinitialize()
     cmd.set_session(s)
     self.assertEqual(['ala'], cmd.get_names())
     self.assertEqual(x, cmd.count_atoms())
Exemple #23
0
def test_select_range():
    cmd.reinitialize()
    cmd.fab("GASGAGS", "m1")
    cmd.select("s1", "resn ALA")
    psico.selecting.select_range()
    assert 4 == cmd.count_atoms("s1 & guide")
    psico.selecting.select_range("s2", "resn SER")
    assert 5 == cmd.count_atoms("s2 & guide")
Exemple #24
0
 def testLoadAlnMatchingIds(self):
     cmd.fab('ACDEFGHIKLMNPQRS', 'seq1')
     cmd.fab('ACDIKLMNP', 'seq2')
     cmd.fab('GHIKPQRS', 'seq3')
     cmd.load(self.datafile('alignment.aln'), 'aln')
     self.assertEqual(cmd.count_atoms('guide & aln & seq1'), 11)
     self.assertEqual(cmd.count_atoms('guide & aln & seq2'), 7)
     self.assertEqual(cmd.count_atoms('guide & aln & seq3'), 6)
Exemple #25
0
 def testGetSession(self):
     cmd.fragment('ala')
     x = cmd.count_atoms()
     s = cmd.get_session()
     cmd.reinitialize()
     cmd.set_session(s)
     self.assertEqual(['ala'], cmd.get_names())
     self.assertEqual(x, cmd.count_atoms())
Exemple #26
0
 def test_attach(self):
     cmd.pseudoatom()
     cmd.edit('first all')
     cmd.attach('C', 1, 1)
     self.assertEqual(2, cmd.count_atoms())
     cmd.attach('C', 1, 1)
     self.assertEqual(3, cmd.count_atoms())
     self.assertEqual(['C01', 'C02', 'PS1'], sorted(get_atom_names()))
Exemple #27
0
def helicize_beta_peptide(helixtype, selection='all'):
    """
    DESCRIPTION

    Adjust the torsion angles of a beta-peptide to different helical conformations

    USAGE

    helicize_beta_peptide helixtype [, selection]
    
    ARGUMENTS
    
    helixtype = the type of the helix (either short or IUPAC name),
        or a tuple of 3 floats, representing three torsional angles, or
        a list of tuples / short names / IUPAC names.
    
    selection = the selection to operate on. Must be a single peptide chain with 
        unique residue IDs (default: all)
    
    NOTES"""

    if isinstance(helixtype, str):
        for perczelname, iupacname, angles, theorylevel in helixtypes:
            helixtype = helixtype.replace(iupacname, perczelname).replace(
                perczelname, '({}, {}, {})'.format(*angles))
        helixtype = helixtype.strip()
        if not all([h in '0123456789.,()[] -+efg' for h in helixtype]):
            raise ValueError(
                'Helixtype parameter contains an invalid character (only numbers, parentheses, brackets, space and commas are accepted)'
            )
        helixtype = eval(helixtype, {}, {})
    assert isinstance(helixtype, collections.Iterable)
    if all([isinstance(x, numbers.Real)
            for x in helixtype]) and len(helixtype) == 3:
        helixtype = [helixtype]
    print('Helixtypes: {}'.format(helixtype))
    space = {'lis': []}
    cmd.iterate(selection, 'lis.append(resv)', space=space)
    residues = sorted(set(space['lis']))
    for r, ht in zip(sorted(residues), itertools.cycle(helixtype)):
        if len(ht) != 3 and not all([isinstance(x, numbers.Real) for x in ht]):
            raise ValueError('Invalid helixtype: {}'.format(ht))
        calpha = '({}) and (name CA) and (resi {})'.format(selection, r)
        cbeta = '({}) and (name CB+CB1) and (resi {})'.format(selection, r)
        c = '({}) and (name C) and (resi {})'.format(selection, r)
        n = '({}) and (name N) and (resi {})'.format(selection, r)
        prevc = '(neighbor ({})) and (name C)'.format(n)
        nextn = '(neighbor ({})) and (name N)'.format(c)
        prevo = '(neighbor ({})) and (name O)'.format(prevc)
        hn = '(neighbor ({})) and (name H+HN)'.format(n)
        o = '(neighbor ({})) and (name O)'.format(c)
        nexthn = '(neighbor ({})) and (name H+HN)'.format(nextn)
        set_beta_helix(prevc, n, cbeta, calpha, c, nextn, ht, selection)
        for n_, h_, c_, o_ in [(n, hn, prevc, prevo), (nextn, nexthn, c, o)]:
            if cmd.count_atoms(n_) + cmd.count_atoms(h_) + cmd.count_atoms(
                    c_) + cmd.count_atoms(o_) == 4:
                cmd.set_dihedral(h_, n_, c_, o_, 180.)
    cmd.orient(selection)
    def runStride(self):
        """
        """
        # delete old results
        self.sel_obj_list = []
        self.stride_rlt_dict = {}
        self.SSE_res_dict = {}
        self.SSE_sel_dict = {}

        pdb_fn = None
        sel_name = None
        sel = self.pymol_sel.get()

        if len(sel) > 0:  # if any pymol selection/object is specified
            all_sel_names = cmd.get_names('all')  # get names of all selections
            if sel in all_sel_names:
                if cmd.count_atoms(sel) == 0:
                    err_msg = 'ERROR: The selection %s is empty.' % (sel, )
                    print('ERROR: %s' % (err_msg, ))
                    tkMessageBox.showinfo(title='ERROR', message=err_msg)
                    return False
                else:
                    sel_name = sel
            # no selection/object with the input name is found
            # we assume either a single-word selector or
            # some other selection-expression is uesd
            else:
                print('The selection/object you specified is not found.')
                print(
                    'Your input will be interpreted as a selection-expression.'
                )
                tmpsel = self.randomSeleName(prefix='your_sele_')
                cmd.select(tmpsel, sel)
                if cmd.count_atoms(tmpsel) == 0:
                    cmd.delete(tmpsel)
                    err_msg = 'ERROR: The selection %s is empty.' % (sel, )
                    print('ERROR: %s' % (err_msg, ))
                    tkMessageBox.showinfo(title='ERROR', message=err_msg)
                    return False
                else:
                    sel_name = tmpsel

        else:  # what structure do you want Stride to work on?
            err_msg = 'No PyMOL selection/object specified!'
            print('ERROR: %s' % (err_msg, ))
            tkMessageBox.showinfo(title='ERROR', message=err_msg)
            return False

        # each object in the selection is treated as an independent struc
        objlist = cmd.get_object_list(sel_name)
        self.ss_asgn_prog = 'Stride'
        print('Starting %s ...' % (self.ss_asgn_prog, ))

        for objname in objlist:
            self.sel_obj_list.append('%s and %s' % (sel_name, objname))
            self.runStrideOneObj(self.sel_obj_list[-1])

        return True
Exemple #29
0
def fSumWMCLast(molecule, SGNameAngle, chain, residue, MCNeighbour, DieElecMC, MCchargeN, MCchargeH, MCchargeProCA, MCchargeProCD, MCchargeProN, AmideName, printMC):
	#print "Last", MCNeighbour
	SumWMCLast = 0.0
	SGnameselect = "/"+SGNameAngle+"//"+"/"+"/SG"
	NBnameselect = "/"+molecule+"//"+chain+"/"+str(MCNeighbour)
	cmd.select("MC", NBnameselect)
	MCpdbstr = cmd.get_pdbstr("MC")
	MCsplit = MCpdbstr.split()
	residueName = MCsplit[3]
	#print NBnameselect, residueName
	if residueName == "PRO":
		### Proline CA
		CAnameselect = "/"+molecule+"//"+chain+"/"+str(MCNeighbour)+"/CA"
		ResDist = cmd.dist(residue+'distLastProCA', SGnameselect,CAnameselect)
		WMC = fWMC(MCchargeProCA, DieElecMC, ResDist)
		SumWMCLast = SumWMCLast + WMC
		if printMC == 'yes': print "MC ProCA ", MCNeighbour, " ", MCchargeProCA, " ", DieElecMC, " ", ResDist, " ", WMC
		### Proline CD
		CDnameselect = "/"+molecule+"//"+chain+"/"+str(MCNeighbour)+"/CD"
		ResDist = cmd.dist(residue+'distLastProCD', SGnameselect,CDnameselect)
		WMC = fWMC(MCchargeProCD, DieElecMC, ResDist)
		SumWMCLast = SumWMCLast + WMC
		if printMC == 'yes': print "MC ProCD ", MCNeighbour, " ", MCchargeProCD, " ", DieElecMC, " ", ResDist, " ", WMC
		### Proline N
		Nnameselect = "/"+molecule+"//"+chain+"/"+str(MCNeighbour)+"/N"
		ResDist = cmd.dist(residue+'distLastProN', SGnameselect,Nnameselect)
		WMC = fWMC(MCchargeProN, DieElecMC, ResDist)
		SumWMCLast = SumWMCLast + WMC
		if printMC == 'yes': print "MC ProN ", MCNeighbour, " ", MCchargeProN, " ", DieElecMC, " ", ResDist, " ", WMC
	else:
		AmideProt = "/"+molecule+"//"+chain+"/"+str(MCNeighbour)+"/H01"
		Hnameselect = "/"+AmideName+"//"+chain+"/"+str(MCNeighbour)+"/H01"
		if cmd.count_atoms(AmideProt) == 0 and cmd.count_atoms(Hnameselect) == 0:
			HbuildSelect = "/"+molecule+"//"+chain+"/"+str(MCNeighbour)+"/N"
			cmd.h_add(HbuildSelect)
			cmd.create(AmideName, AmideName+" + "+AmideProt)
			cmd.remove(AmideProt)
		### Mainchain AmideH
		ResDist = cmd.dist(residue+'distLastH', SGnameselect,Hnameselect)
		WMC = fWMC(MCchargeH, DieElecMC, ResDist)
		SumWMCLast = SumWMCLast + WMC
		if printMC == 'yes': print "MC H ", MCNeighbour, " ", MCchargeH, " ", DieElecMC, " ", ResDist, " ", WMC
		### Mainchain N
		Nnameselect = "/"+molecule+"//"+chain+"/"+str(MCNeighbour)+"/N"
		ResDist = cmd.dist(residue+'distLastN', SGnameselect,Nnameselect)
		WMC = fWMC(MCchargeN, DieElecMC, ResDist)
		SumWMCLast = SumWMCLast + WMC
		if printMC == 'yes': print "MC N ", MCNeighbour, " ", MCchargeN, " ", DieElecMC, " ", ResDist, " ", WMC
	cmd.delete(residue+'distLastProCA')
	cmd.delete(residue+'distLastProCD')
	cmd.delete(residue+'distLastProN')
	cmd.delete(residue+'distLastH')
	cmd.delete(residue+'distLastN')
	cmd.show("nb_spheres", AmideName)
	cmd.delete("MC")
	return SumWMCLast
    def runStride(self):
        """
        """
        # delete old results
        self.sel_obj_list = []
        self.stride_rlt_dict = {}
        self.SSE_res_dict = {}
        self.SSE_sel_dict = {}

        pdb_fn = None
        sel_name = None
        sel = self.pymol_sel.get()

        if len(sel) > 0:  # if any pymol selection/object is specified
            all_sel_names = cmd.get_names('all')  # get names of all selections
            if sel in all_sel_names:
                if cmd.count_atoms(sel) == 0:
                    err_msg = 'ERROR: The selection %s is empty.' % (sel,)
                    print('ERROR: %s' % (err_msg,))
                    tkMessageBox.showinfo(title='ERROR', message=err_msg)
                    return False
                else:
                    sel_name = sel
            # no selection/object with the input name is found
            # we assume either a single-word selector or
            # some other selection-expression is uesd
            else:
                print('The selection/object you specified is not found.')
                print('Your input will be interpreted as a selection-expression.')
                tmpsel = self.randomSeleName(prefix='your_sele_')
                cmd.select(tmpsel, sel)
                if cmd.count_atoms(tmpsel) == 0:
                    cmd.delete(tmpsel)
                    err_msg = 'ERROR: The selection %s is empty.' % (sel,)
                    print('ERROR: %s' % (err_msg,))
                    tkMessageBox.showinfo(title='ERROR', message=err_msg)
                    return False
                else:
                    sel_name = tmpsel

        else:   # what structure do you want Stride to work on?
            err_msg = 'No PyMOL selection/object specified!'
            print('ERROR: %s' % (err_msg,))
            tkMessageBox.showinfo(title='ERROR', message=err_msg)
            return False

        # each object in the selection is treated as an independent struc
        objlist = cmd.get_object_list(sel_name)
        self.ss_asgn_prog = 'Stride'
        print('Starting %s ...' % (self.ss_asgn_prog, ))

        for objname in objlist:
            self.sel_obj_list.append('%s and %s' % (sel_name, objname))
            self.runStrideOneObj(self.sel_obj_list[-1])

        return True
 def testMorphRigimol(self):
     cmd.set('suspend_undo')
     import epymol.rigimol
     cmd.fab('ACD', 'm1')
     cmd.create('m1', 'm1', 1, 2)
     cmd.rotate('x', 90, 'm1', 2)
     steps = 5
     cmd.morph('mout', 'm1', refinement=1, steps=steps, method='rigimol')
     self.assertEqual(steps, cmd.count_states('mout'))
     self.assertEqual(cmd.count_atoms('m1'), cmd.count_atoms('mout'))
Exemple #32
0
 def test_replace(self):
     # NOTES:
     # - doc says "Immature functionality"
     # - will not preserve ID
     # - will not re-add hydrogens with h_fill=1
     cmd.fragment('ala')
     cmd.edit('elem O')
     cmd.replace('S', 0, 0, 0)
     self.assertEqual(0, cmd.count_atoms('elem O'))
     self.assertEqual(1, cmd.count_atoms('elem S'))
Exemple #33
0
 def testLoadMMTF(self):
     cmd.load(self.datafile("3njw.mmtf.gz"))
     self.assertEqual(169, cmd.count_atoms())
     self.assertEqual(36, cmd.count_atoms('ss S'))
     self.assertEqual(25, cmd.count_atoms('solvent'))
     symmetry = cmd.get_symmetry()
     self.assertArrayEqual(symmetry[:6],
                           [19.465, 21.432, 29.523, 90.0, 90.0, 90.0],
                           delta=1e-4)
     self.assertEqual(symmetry[6], 'P 21 21 21')
Exemple #34
0
    def testShow(self):
        if testing.PYMOL_VERSION[1] > 1.84:
            cmd.set('auto_show_classified', 0)

        cmd.fragment('ala')
        self.assertEqual(cmd.count_atoms('rep sticks'), 0)
        cmd.show('sticks')
        self.assertEqual(cmd.count_atoms('rep sticks'), 10)
        cmd.hide('lines', 'not elem C')
        self.assertEqual(cmd.count_atoms('rep lines'), 3)
Exemple #35
0
def test_remove_alt():
    cmd.reinitialize()
    cmd.fab('AC', 'm1')
    cmd.alter('resn ALA', 'alt="A"')
    cmd.alter('resn CYS', 'alt="B"')
    cmd.create('m2', 'm1')
    psico.editing.remove_alt('m1')
    psico.editing.remove_alt('m2', keep='B')
    assert cmd.count_atoms('m1') == 10
    assert cmd.count_atoms('m2') == 11
Exemple #36
0
    def testShow(self):
        if testing.PYMOL_VERSION[1] > 1.84:
            cmd.set('auto_show_classified', 0)

        cmd.fragment('ala')
        self.assertEqual(cmd.count_atoms('rep sticks'), 0)
        cmd.show('sticks')
        self.assertEqual(cmd.count_atoms('rep sticks'), 10)
        cmd.hide('lines', 'not elem C')
        self.assertEqual(cmd.count_atoms('rep lines'), 3)
Exemple #37
0
 def testNumeric(self):
     cmd.fragment('ala')
     cmd.alter_state(1, 'all', 'p.x, p.y, p.index = x, y, index')
     cmd.select('sele_p_x', 'p.x < 0')
     cmd.select('sele_p_y', 'p.y > 0')
     cmd.select('sele_p_i', 'p.index = 3')
     cmd.select('sele_x', 'x < 0.0')
     cmd.select('sele_y', 'y > 0.0')
     cmd.select('sele_i', 'index 3')
     counts = [
         cmd.count_atoms('sele_p_x'),
         cmd.count_atoms('sele_x'),
         cmd.count_atoms('sele_x & sele_p_x'),
     ]
     self.assertEqual(counts[0], 8)
     self.assertEqual(counts[0], counts[1])
     self.assertEqual(counts[0], counts[2])
     counts = [
         cmd.count_atoms('sele_p_y'),
         cmd.count_atoms('sele_y'),
         cmd.count_atoms('sele_y & sele_p_y'),
     ]
     self.assertEqual(counts[0], 6)
     self.assertEqual(counts[0], counts[1])
     self.assertEqual(counts[0], counts[2])
     counts = [
         cmd.count_atoms('sele_i'),
         cmd.count_atoms('sele_p_i'),
         cmd.count_atoms('sele_i & sele_p_i'),
     ]
     self.assertEqual(counts[0], 1)
     self.assertEqual(counts[0], counts[1])
     self.assertEqual(counts[0], counts[2])
    def testSdfV3000(self):
        cmd.load(self.datafile('1rx1.pdb'))
        with testing.mktemp('.sdf') as filename:
            cmd.save(filename)
            cmd.delete('*')
            cmd.load(filename)
        self.assertEqual(cmd.count_atoms(), 1435)

        # check for capitalized element symbols
        cmd.set('ignore_case', 0)
        self.assertEqual(cmd.count_atoms('elem Ca'), 1)
 def test(self):
     cmd.set('suspend_undo')
     cmd.fragment('gly', 'm1')
     cmd.remove('not ID 0+1')
     cmd.create('m1', 'm1', 1, 2)
     cmd.rotate('x', 90, 'm1', 2)
     steps = 5
     cmd.morph('mout', 'm1', refinement=0, steps=steps, method='rigimol')
     self.assertEqual(steps, cmd.count_states('mout'))
     self.assertEqual(cmd.count_atoms('m1'),
                      cmd.count_atoms('mout'))
Exemple #40
0
 def testMorphRigimol(self):
     cmd.set('suspend_undo')
     import epymol.rigimol
     cmd.fab('ACD', 'm1')
     cmd.create('m1', 'm1', 1, 2)
     cmd.rotate('x', 90, 'm1', 2)
     steps = 5
     cmd.morph('mout', 'm1', refinement=1, steps=steps, method='rigimol')
     self.assertEqual(steps, cmd.count_states('mout'))
     self.assertEqual(cmd.count_atoms('m1'),
                      cmd.count_atoms('mout'))
    def testSdfV3000(self):
        cmd.load(self.datafile('1rx1.pdb'))
        with testing.mktemp('.sdf') as filename:
            cmd.save(filename)
            cmd.delete('*')
            cmd.load(filename)
        self.assertEqual(cmd.count_atoms(), 1435)

        # check for capitalized element symbols
        cmd.set('ignore_case', 0)
        self.assertEqual(cmd.count_atoms('elem Ca'), 1)
Exemple #42
0
    def test(self):
        if cmd.get_setting_int('suspend_undo'):
            self.skipTest("need suspend_undo=0")

        cmd.fragment('gly', 'm1')
        cmd.create('m2', 'm1')
        cmd.edit('m1 & name N')
        cmd.replace('I', 1, 1)
        self.assertEqual(cmd.count_atoms('m1 in m2'), 5)
        cmd.undo()
        self.assertEqual(cmd.count_atoms('m1 in m2'), 7)
    def test(self):
        if cmd.get_setting_int('suspend_undo'):
            self.skipTest("need suspend_undo=0")

        cmd.fragment('gly', 'm1')
        cmd.create('m2', 'm1')
        cmd.edit('m1 & name N')
        cmd.replace('I', 1, 1)
        self.assertEqual(cmd.count_atoms('m1 in m2'), 5)
        cmd.undo()
        self.assertEqual(cmd.count_atoms('m1 in m2'), 7)
 def test_load_hypothesis_phypo(self):
     from epymol import ph4
     ph4.load_phypo(
             self.datafile('phase/ADHHRR_1_trans.phypo'),
             'g1', zoom=-1, mimic=1, atom_props='', _self=cmd)
     self.assertEqual(cmd.count_atoms('g1.ADHHRR_1 and name A2+H6'), 2)
     self.assertEqual(cmd.count_atoms('g1.endo-1'), 35)
     self.assertEqual(cmd.count_atoms('g1.endo-2'), 37)
     self.assertEqual(cmd.count_atoms('g1.endo-36'), 28)
     self.assertEqual(cmd.count_atoms('g1.ADHHRR_1_xvol'), 936)
     self.assertTrue('g1.ADHHRR_1_cgo' in cmd.get_names_of_type('object:cgo'))
Exemple #45
0
    def test_bond(self):
        cmd.pseudoatom('m1', pos=(0,0,0))
        cmd.pseudoatom('m1', pos=(1,0,0))
        cmd.pseudoatom('m1', pos=(1,1,0))

        cmd.bond('m1`1', 'm1`2')
        count = cmd.count_atoms('(m1`1) extend 1')
        self.assertEqual(count, 2)

        cmd.unbond('m1`1', 'm1`2')
        count = cmd.count_atoms('(m1`1) extend 1')
        self.assertEqual(count, 1)
Exemple #46
0
 def testSymexp(self):
     cmd.load(self.datafile('1oky.pdb.gz'), 'm1')
     n = cmd.count_atoms()
     cmd.symexp('s', 'm1', '%m1 & resi 283', 20.0)
     x = cmd.get_object_list()
     self.assertEqual(x, [
         'm1',
         's01000000',
         's03000000',
         's04000000',
         ])
     self.assertEqual(n * 4, cmd.count_atoms())
Exemple #47
0
 def testCast(self):
     cmd.fragment('ala')
     cmd.alter('all', 'p.s, p.index = "10e0", index')
     cmd.alter('index 2+3', 'p.s = "30e0"')
     cmd.select('sele_p_s', 'p.s > 20')
     cmd.select('sele_p_i', 'p.index in 2+3')
     counts = [
         cmd.count_atoms('sele_p_s'),
         cmd.count_atoms('sele_p_i'),
     ]
     self.assertEqual(counts[0], 2)
     self.assertEqual(counts[1], 2)
    def _add_vis(self, mymol, row, l_cgo):
        mycolind = int((np.sign(row.sdiff) + 1) / 2)
        if self.df_rgn_seg_res_bb is None:
            cmd.select(
                "sel1",
                "/%s/%s and i. %d and name ca" % (mymol, row.seg1, row.res1))
            cmd.select(
                "sel2",
                "/%s/%s and i. %d and name ca" % (mymol, row.seg2, row.res2))
        else:
            df_unique_rgnsegbb = self.df_rgn_seg_res_bb[["seg"
                                                         ]].drop_duplicates()
            for myrgn in [row.rgn1, row.rgn2]:
                selstr = "/%s and (" % (mymol)
                for sindex, srow in df_unique_rgnsegbb.iterrows():
                    df_sel = self.df_rgn_seg_res_bb.query(
                        "rgn == '%s' and seg == '%s'" % (myrgn, srow.seg))
                    if df_sel.shape[0] > 0:
                        selstr += "(c. %s and i. %s) or" % (srow.seg, "+".join(
                            [str(x) for x in df_sel.res.values[0]]))
                selstr = selstr[:-3] + ")"
                cmd.select("%s" % myrgn, selstr)
            cmd.set_name("%s" % row.rgn1, "sel1")
            cmd.set_name("%s" % row.rgn2, "sel2")

        count1 = cmd.count_atoms("sel1")
        count2 = cmd.count_atoms("sel2")
        if 0 in [count1, count2]:
            raise ValueError(
                "ZeroCount: count(%s.%d.%s.ca): %d, count(%s.%d.%s.ca): %d" %
                (row.seg1, row.res1, row.rnm1, count1, row.seg2, row.res2,
                 row.rnm2, count2))
        else:
            com("sel1", state=1)
            #cmd.color(self.sgn2col[mycolind], "sel1")
            coord1 = cmd.get_model("sel1_COM", state=1).atom[0].coord
            cmd.delete("sel1_COM")
            com("sel2", state=1)
            #cmd.color(self.sgn2col[mycolind], "sel2")
            coord2 = cmd.get_model("sel2_COM", state=1).atom[0].coord
            cmd.delete("sel2_COM")
            l_cgo += [ \
                LINEWIDTH, self.linewidth, \
                BEGIN, LINES, \
                COLOR, self.l_r[mycolind], self.l_g[mycolind], self.l_b[mycolind], \
                VERTEX,   coord1[0], coord1[1],coord1[2], \
                VERTEX,   coord2[0], coord2[1],coord2[2], \
                END \
            ]
            cmd.show("sticks", "sel1")
            cmd.show("sticks", "sel2")
        cmd.delete("sel1")
        cmd.delete("sel2")
 def testString(self):
     cmd.fragment('ala')
     cmd.alter('all', 'p.name = name')
     cmd.select('sele_p_x', 'p.name in C+N+O')
     cmd.select('sele_x', 'name C+N+O')
     counts = [
         cmd.count_atoms('sele_p_x'),
         cmd.count_atoms('sele_x'),
         cmd.count_atoms('sele_x & sele_p_x'),
     ]
     self.assertEqual(counts[0], 3)
     self.assertEqual(counts[0], counts[1])
     self.assertEqual(counts[0], counts[2])
Exemple #50
0
    def testLoadAlnMappingDict(self):
        cmd.fab('ACDIKLMNP', 'm2')
        cmd.fab('GHIKPQRS', 'm3')

        from pymol.seqalign import load_aln_multi

        load_aln_multi(self.datafile('alignment.aln'), 'aln', mapping={
            'seq2': 'm2',
            'seq3': 'm3',
        })

        self.assertEqual(cmd.count_atoms('guide & aln & m2'), 2)
        self.assertEqual(cmd.count_atoms('guide & aln & m3'), 2)
Exemple #51
0
    def testLoadAlnMappingStr(self):
        cmd.fab('ACDEFGHIKLMNPQRS', 'm1')
        cmd.fab('ACDIKLMNP', 'm2')

        from pymol.seqalign import load_aln_multi

        load_aln_multi(self.datafile('alignment.aln'), 'aln', mapping=
            'seq1 m1 '
            'seq2 m2 '
        )

        self.assertEqual(cmd.count_atoms('guide & aln & m1'), 7)
        self.assertEqual(cmd.count_atoms('guide & aln & m2'), 7)
    def testMMTFExportSele(self):
        cmd.fab('ACDE')

        with testing.mktemp('.mmtf') as filename:
            cmd.save(filename, 'resn CYS+ASP')
            cmd.delete('*')
            cmd.load(filename)

        self.assertEqual(cmd.count_atoms(), 23)
        self.assertEqual(cmd.count_atoms('bound_to ASP/CG'), 3)
        self.assertEqual(cmd.get_model('ASP/CG ASP/OD1').bond[0].order, 2)
        self.assertEqual(cmd.get_model('ASP/CG ASP/OD2').bond[0].order, 1)
        self.assertEqual(cmd.get_model('CYS/C ASP/N').bond[0].order, 1)
def fSumWMCresidue(molecule, SGNameAngle, chain, residue, MCNeighbour, DieElecMC, MCchargeC, MCchargeO, MCchargeN, MCchargeH, AmideName, printMC):
    # print "residue", MCNeighbour
    SumWMCresidue = 0.0
    SGnameselect = "/" + SGNameAngle + "//" + "/" + "/SG"
    NBnameselect = "/" + molecule + "//" + chain + "/" + str(MCNeighbour)
    cmd.select("MC", NBnameselect)
    MCpdbstr = cmd.get_pdbstr("MC")
    MCsplit = MCpdbstr.split()
    residueName = MCsplit[3]
    # print NBnameselect, residueName
    AmideProt = "/" + molecule + "//" + chain + "/" + str(MCNeighbour) + "/H01"
    Hnameselect = "/" + AmideName + "//" + chain + "/" + str(MCNeighbour) + "/H01"
    if cmd.count_atoms(AmideProt) == 0 and cmd.count_atoms(Hnameselect) == 0:
        HbuildSelect = "/" + molecule + "//" + chain + "/" + str(MCNeighbour) + "/N"
        cmd.h_add(HbuildSelect)
        cmd.create(AmideName, AmideName + " + " + AmideProt)
        cmd.remove(AmideProt)
    # Mainchain AmideH
    ResDist = cmd.dist(residue + 'distResH', SGnameselect, Hnameselect)
    WMC = fWMC(MCchargeH, DieElecMC, ResDist)
    SumWMCresidue = SumWMCresidue + WMC
    if printMC == 'yes':
        print("MC H ", MCNeighbour, " ", MCchargeH, " ", DieElecMC, " ", ResDist, " ", WMC)
    # Mainchain C
    Cnameselect = "/" + molecule + "//" + chain + "/" + str(MCNeighbour) + "/C"
    ResDist = cmd.dist(residue + 'distResC', SGnameselect, Cnameselect)
    WMC = fWMC(MCchargeC, DieElecMC, ResDist)
    SumWMCresidue = SumWMCresidue + WMC
    if printMC == 'yes':
        print("MC C ", MCNeighbour, " ", MCchargeC, " ", DieElecMC, " ", ResDist, " ", WMC)
    # Mainchain O
    Onameselect = "/" + molecule + "//" + chain + "/" + str(MCNeighbour) + "/O"
    ResDist = cmd.dist(residue + 'distResO', SGnameselect, Onameselect)
    WMC = fWMC(MCchargeO, DieElecMC, ResDist)
    SumWMCresidue = SumWMCresidue + WMC
    if printMC == 'yes':
        print("MC O ", MCNeighbour, " ", MCchargeO, " ", DieElecMC, " ", ResDist, " ", WMC)
    # Mainchain N
    Nnameselect = "/" + molecule + "//" + chain + "/" + str(MCNeighbour) + "/N"
    ResDist = cmd.dist(residue + 'distResN', SGnameselect, Nnameselect)
    WMC = fWMC(MCchargeN, DieElecMC, ResDist)
    SumWMCresidue = SumWMCresidue + WMC
    if printMC == 'yes':
        print("MC N ", MCNeighbour, " ", MCchargeN, " ", DieElecMC, " ", ResDist, " ", WMC)
    cmd.delete(residue + 'distResH')
    cmd.delete(residue + 'distResC')
    cmd.delete(residue + 'distResO')
    cmd.delete(residue + 'distResN')
    cmd.show("nb_spheres", AmideName)
    cmd.delete("MC")
    return SumWMCresidue
    def testSetKey(self):
        if testing.PYMOL_VERSION[1] > 1.84:
            cmd.set('auto_show_classified', 0)

        cmd.fragment('gly')
        N = cmd.count_atoms()
        self.assertEqual(0, cmd.count_atoms('rep sticks | rep spheres'))
        cmd.set_key('F3', cmd.show, ('sticks',))
        cmd._special(3, 0, 0)
        self.assertEqual(N, cmd.count_atoms('rep sticks'))
        cmd.do('set_key F3, hide sticks; show spheres')
        cmd._special(3, 0, 0)
        self.assertEqual(0, cmd.count_atoms('rep sticks'))
        self.assertEqual(N, cmd.count_atoms('rep spheres'))
Exemple #55
0
def nice(selection='(all)', simple=1e5):
    '''
DESCRIPTION

    My favourite representation

    Color: by chain (elem C) and by element (others)

    Representation: cartoon (polymer), sticks (organic),
    spheres (inorganic) and nonbonded (solvent)

USAGE

    nice [ selection ]
    '''
    simple = int(simple)
    cmd.util.cbc(selection)
    cmd.color('atomic', '(%s) and not elem C' % (selection))
    if simple and cmd.count_atoms(selection) >= simple:
        cmd.show_as('ribbon', selection)
        cmd.show_as('lines', '(%s) and organic' % (selection))
        cmd.show_as('nonbonded', '(%s) and inorganic' % (selection))
    else:
        cmd.show_as('cartoon', selection)
        cmd.show_as('sticks', '(%s) and organic' % (selection))
        cmd.show_as('spheres', '(%s) and inorganic' % (selection))
        cmd.show_as('nonbonded', '(%s) and solvent' % (selection))