コード例 #1
0
ファイル: assign.py プロジェクト: jchodera/pymol
def amber99(selection="(all)",quiet=0,_self=cmd):
    cmd=_self
    result = 1
    # first, set all parameters to zero

    cmd.alter(selection,"partial_charge=0")
    cmd.alter(selection,"elec_radius=0.0")
    cmd.alter(selection,"text_type=''")

    # next, flag all atoms so that we'll be able to detect what we miss
    
    cmd.flag(23,selection,'set')

    # get the amber99 dictionary
    
    if not hasattr(champ,'amber99_dict'):
        from chempy.champ.amber99 import amber99_dict
        champ.amber99_dict = amber99_dict

    # iterate through the residue dictionary matching each residue based on chemistry
    # and generating the expressions for reassigning formal charges
    
    alter_list = []
    for resn in champ.amber99_dict.keys():
        if cmd.select(tmp_sele1,"(%s) and resn %s"%(selection,resn))>0:
            entry = champ.amber99_dict[resn]
            for rule in entry:
                model = cmd.get_model(tmp_sele1)
                ch = Champ()
                model_pat = ch.insert_model(model)
                ch.pattern_detect_chirality(model_pat)
                assn_pat = ch.insert_pattern_string(rule[0])
                ch.pattern_clear_tags(model_pat)
                if ch.match_1v1_n(assn_pat,model_pat,10000,2)>0:
                    result = ch.pattern_get_ext_indices_with_tags(model_pat)
                    for atom_tag in result[0]: # just iterate over atom tags
                        if len(atom_tag[1])==1: # one and only one match
                            tag = atom_tag[1][0]
                            prop_list = rule[1][tag]
                            # the following expression both changes the formal charge and resets flag 23
                            alter_list.append([atom_tag[0],
            "name='''%s''';text_type='''%s''';partial_charge=%f;elec_radius=%f;flags=flags&-8388609"%prop_list])

    # now evaluate all of these expressions efficiently en-masse 
    cmd.alter_list(selection,alter_list)

    # see if we missed any atoms
    missed_count = cmd.count_atoms("("+selection+") and flag 23")

    if missed_count>0:
        if not quiet:
            # looks like we did, so alter the user
            print " WARNING: %d atoms did not have properties assigned"%missed_count
        result = 0

    # remove the temporary selection we used to select appropriate residues
    
    cmd.delete(tmp_sele1)

    return result
コード例 #2
0
ファイル: B07.py プロジェクト: Almad/pymol
def load():
   cmd.set("valence")
   r = 0
   list = glob("pdb/*/*")

#   list = ["pdb/06/pdb406d"]
#   while list[0]!="pdb/f8/pdb1f8u":
#      list.pop(0)
   for file in list:
      cmd.delete('pdb')
      cmd.load(file,'pdb')
      cmd.remove("not alt ''+A")
      cmd.fix_chemistry("all","all")
      cmd.h_add()
      sys.__stderr__.write(file)
      sys.__stderr__.flush()
      ch = Champ()
      model = cmd.get_model('pdb')
      idx = ch.insert_model(model)

      ch.pattern_orient_bonds(idx)
      print " %5d"%cmd.count_atoms(),"%5d"%len(ch.pattern_get_string(idx)),
      ch.pattern_detect_chirality(idx)
      pat = ch.pattern_get_string(idx)
      print "%5d"%len(pat),pat[0:22]+"..."+pat[-10:]
コード例 #3
0
def missing_c_termini(selection="(all)", quiet=0, _self=cmd):
    cmd = _self
    # assumes that hydogens are not present!

    sele_list = []
    ch = Champ()
    model = cmd.get_model(selection)
    model_pat = ch.insert_model(model)
    assn_pat = ch.insert_pattern_string("[N+0+1]C[C;D2]<0>(=O)")
    ch.pattern_clear_tags(model_pat)
    if ch.match_1v1_n(assn_pat, model_pat, 10000, 2) > 0:
        result = ch.pattern_get_ext_indices_with_tags(model_pat)
        for atom_tag in result[0]:  # just iterate over atom tags
            if len(atom_tag[1]) == 1:  # one and only one match
                if atom_tag[1][0] == 0:
                    sele_list.append(atom_tag[0])
    cmd.select_list(tmp_sele1, selection, sele_list, mode='index')
    while cmd.pop(tmp_sele2, tmp_sele1) > 0:  # complete the carboxy terminus
        cmd.edit(tmp_sele2)
        cmd.attach("O", 1, 1, "OXT", quiet=1)
        cmd.unpick()
    cmd.delete(tmp_sele1)
コード例 #4
0
ファイル: assign.py プロジェクト: baoboa/pymol
def missing_c_termini(selection="(all)",quiet=0,_self=cmd):
    cmd=_self
    # assumes that hydogens are not present!
    
    sele_list = []
    ch=Champ()
    model = cmd.get_model(selection)
    model_pat = ch.insert_model(model)
    assn_pat = ch.insert_pattern_string("[N+0+1]C[C;D2]<0>(=O)")
    ch.pattern_clear_tags(model_pat)
    if ch.match_1v1_n(assn_pat,model_pat,10000,2)>0:
        result = ch.pattern_get_ext_indices_with_tags(model_pat)
        for atom_tag in result[0]: # just iterate over atom tags
            if len(atom_tag[1])==1: # one and only one match
                if atom_tag[1][0]==0:
                    sele_list.append(atom_tag[0])
    cmd.select_list(tmp_sele1,selection,sele_list, mode='index')
    while cmd.pop(tmp_sele2,tmp_sele1)>0: # complete the carboxy terminus
        cmd.edit(tmp_sele2)
        cmd.attach("O",1,1,"OXT",quiet=1)
        cmd.unpick()
    cmd.delete(tmp_sele1)
コード例 #5
0
ファイル: 50nci.py プロジェクト: kingdavid72/pymol-OpenSource
from chempy.champ import Champ

# see if we can read-in and read-out all of the NCI
# database SMILES strings without a hitch

import re
num_re = re.compile("[0-9]")
pnum_re = re.compile(r"\%[0-9][0-9]")

ch = Champ()

f = open("nci.smi")

c = 1
lst = []
while 1:
   l = f.readline()
   if not l: break
   l = string.strip(l)
   if len(l):
      if 1000*(c/1000)==c:
         print c
      c = c + 1
#      print l
      idx = ch.insert_pattern_string(l)
 #      ch.pattern_dump(idx)
      o = ch.get_pattern_string(idx)
      if len(o) != len(l): # same length?
         print "orig:  ",l
         print "champ: ",o
         ch.pattern_dump(idx)
コード例 #6
0
def formal_charges(selection="(all)", quiet=0, _self=cmd):
    cmd = _self
    result = 1
    # assumes that hydogens are not present!

    # first, set all formal charges to zero

    cmd.alter(selection, "formal_charge=0")

    # next, flag all atoms so that we'll be able to detect what we miss

    cmd.flag(23, selection, 'set')

    # get the residue dictionary for formal charges

    if not hasattr(champ, 'formal_charge_dict'):
        from chempy.champ.formal_charges import formal_charge_dict
        champ.formal_charge_dict = formal_charge_dict

    # iterate through the residue dictionary matching each residue based on chemistry
    # and generating the expressions for reassigning formal charges

    alter_list = []
    for resn in champ.formal_charge_dict.keys():
        if cmd.select(tmp_sele1, "(%s) and resn %s" % (selection, resn)) > 0:
            entry = champ.formal_charge_dict[resn]
            for rule in entry:
                model = cmd.get_model(tmp_sele1)
                ch = Champ()
                model_pat = ch.insert_model(model)
                assn_pat = ch.insert_pattern_string(rule[0])
                ch.pattern_clear_tags(model_pat)
                if ch.match_1v1_n(assn_pat, model_pat, 10000, 2) > 0:
                    result = ch.pattern_get_ext_indices_with_tags(model_pat)
                    for atom_tag in result[0]:  # just iterate over atom tags
                        if len(atom_tag[1]) == 1:  # one and only one match
                            tag = atom_tag[1][0]
                            formal_charge = rule[1][tag]
                            # the following expression both changes the formal charge and resets flag 23
                            alter_list.append([
                                atom_tag[0],
                                "formal_charge=%d;flags=flags&-8388609" %
                                formal_charge
                            ])

    if 1:  # n-terminal amine
        # non-proline
        ch = Champ()
        model = cmd.get_model(selection)
        model_pat = ch.insert_model(model)
        assn_pat = ch.insert_pattern_string("[N;D1]<0>CC(=O)")
        ch.pattern_clear_tags(model_pat)
        if ch.match_1v1_n(assn_pat, model_pat, 10000, 2) > 0:
            result = ch.pattern_get_ext_indices_with_tags(model_pat)
            for atom_tag in result[0]:  # just iterate over atom tags
                if len(atom_tag[1]) == 1:  # one and only one match
                    if atom_tag[1][0] == 0:
                        # the following expression both changes the formal charge and resets flag 23
                        alter_list.append([
                            atom_tag[0], "formal_charge=1;flags=flags&-8388609"
                        ])
        # proline residues
        ch = Champ()
        model = cmd.get_model(selection)
        model_pat = ch.insert_model(model)
        assn_pat = ch.insert_pattern_string("C1CC[N;D2]<0>C1C(=O)")
        ch.pattern_clear_tags(model_pat)
        if ch.match_1v1_n(assn_pat, model_pat, 10000, 2) > 0:
            result = ch.pattern_get_ext_indices_with_tags(model_pat)
            for atom_tag in result[0]:  # just iterate over atom tags
                if len(atom_tag[1]) == 1:  # one and only one match
                    if atom_tag[1][0] == 0:
                        # the following expression both changes the formal charge and resets flag 23
                        alter_list.append([
                            atom_tag[0], "formal_charge=1;flags=flags&-8388609"
                        ])

    if 1:  # c-terminal acid
        ch = Champ()
        model = cmd.get_model(selection)
        model_pat = ch.insert_model(model)
        assn_pat = ch.insert_pattern_string("NCC(=O<0>)[O;D1]<1>")
        ch.pattern_clear_tags(model_pat)
        if ch.match_1v1_n(assn_pat, model_pat, 10000, 2) > 0:
            result = ch.pattern_get_ext_indices_with_tags(model_pat)
            for atom_tag in result[0]:  # just iterate over atom tags
                if len(atom_tag[1]) == 1:  # one and only one match
                    if atom_tag[1][0] == 1:
                        # the following expression both changes the formal charge and resets flag 23
                        alter_list.append([
                            atom_tag[0],
                            "formal_charge=-1;flags=flags&-8388609"
                        ])

    # now evaluate all of these expressions efficiently en-masse
    cmd.alter_list(selection, alter_list)

    # see if we missed any atoms
    missed_count = cmd.count_atoms("(" + selection + ") and flag 23")

    if missed_count > 0:
        if not quiet:
            # looks like we did, so alter the user
            print(" WARNING: %d atoms did not have formal charges assigned" %
                  missed_count)
        result = 0
    # remove the temporary selection we used to select appropriate residues

    cmd.delete(tmp_sele1)

    return result
コード例 #7
0
import string

print '''# NOTE: This file was autogenerated
formal_charge_dict = {
'''

for res in ('ala', 'arg', 'asp', 'asn', 'cys', 'gln', 'glu', 'gly', 'his',
            'hip', 'hie', 'hid', 'ile', 'leu', 'lys', 'met', 'phe', 'pro',
            'ser', 'thr', 'trp', 'tyr', 'val'):

    stored.fc_dict = {}
    print "'" + string.upper(res) + "': ["
    print "   ("

    ch = Champ()
    cmd.fragment(res, "tmp")
    cmd.iterate("tmp", "stored.fc_dict[name]=formal_charge", quiet=1)
    cmd.alter("all", "formal_charge=0", quiet=1)
    cmd.remove("hydro", quiet=1)
    model = cmd.get_model("tmp")
    cmd.delete("tmp")

    m1 = ch.insert_model(model)
    ch.pattern_detect_chirality(m1)
    ch.pattern_orient_bonds(m1)
    pat1 = ch.pattern_get_string_with_names(m1)
    ch.pattern_detect_chirality(m1)
    pat2 = ch.pattern_get_string_with_names(m1)

    # confirm that CHAMP handles this pattern well...
コード例 #8
0
ファイル: assign.py プロジェクト: baoboa/pymol
def formal_charges(selection="(all)",quiet=0,_self=cmd):
    cmd=_self
    result = 1
    # assumes that hydogens are not present!
    
    # first, set all formal charges to zero
    
    cmd.alter(selection,"formal_charge=0")

    # next, flag all atoms so that we'll be able to detect what we miss
    
    cmd.flag(23,selection,'set')

    # get the residue dictionary for formal charges
    
    if not hasattr(champ,'formal_charge_dict'):
        from chempy.champ.formal_charges import formal_charge_dict
        champ.formal_charge_dict = formal_charge_dict

    # iterate through the residue dictionary matching each residue based on chemistry
    # and generating the expressions for reassigning formal charges
    
    alter_list = []
    for resn in champ.formal_charge_dict.keys():
        if cmd.select(tmp_sele1,"(%s) and resn %s"%(selection,resn))>0:
            entry = champ.formal_charge_dict[resn]
            for rule in entry:
                model = cmd.get_model(tmp_sele1)
                ch = Champ()
                model_pat = ch.insert_model(model)         
                assn_pat = ch.insert_pattern_string(rule[0])
                ch.pattern_clear_tags(model_pat)
                if ch.match_1v1_n(assn_pat,model_pat,10000,2)>0:
                    result = ch.pattern_get_ext_indices_with_tags(model_pat)
                    for atom_tag in result[0]: # just iterate over atom tags
                        if len(atom_tag[1])==1: # one and only one match
                            tag = atom_tag[1][0]
                            formal_charge = rule[1][tag]
                            # the following expression both changes the formal charge and resets flag 23
                            alter_list.append([atom_tag[0],
                                                     "formal_charge=%d;flags=flags&-8388609"%formal_charge])

    if 1: # n-terminal amine
        # non-proline 
        ch=Champ()
        model = cmd.get_model(selection)
        model_pat = ch.insert_model(model)
        assn_pat = ch.insert_pattern_string("[N;D1]<0>CC(=O)")
        ch.pattern_clear_tags(model_pat)
        if ch.match_1v1_n(assn_pat,model_pat,10000,2)>0:
                result = ch.pattern_get_ext_indices_with_tags(model_pat)
                for atom_tag in result[0]: # just iterate over atom tags
                    if len(atom_tag[1])==1: # one and only one match
                        if atom_tag[1][0]==0:
                            # the following expression both changes the formal charge and resets flag 23
                            alter_list.append([atom_tag[0],
                                                     "formal_charge=1;flags=flags&-8388609"])
        # proline residues
        ch=Champ()
        model = cmd.get_model(selection)
        model_pat = ch.insert_model(model)
        assn_pat = ch.insert_pattern_string("C1CC[N;D2]<0>C1C(=O)")
        ch.pattern_clear_tags(model_pat)
        if ch.match_1v1_n(assn_pat,model_pat,10000,2)>0:
                result = ch.pattern_get_ext_indices_with_tags(model_pat)
                for atom_tag in result[0]: # just iterate over atom tags
                    if len(atom_tag[1])==1: # one and only one match
                        if atom_tag[1][0]==0:
                            # the following expression both changes the formal charge and resets flag 23
                            alter_list.append([atom_tag[0],
                                                     "formal_charge=1;flags=flags&-8388609"])
                                    
    if 1: # c-terminal acid
        ch=Champ()
        model = cmd.get_model(selection)
        model_pat = ch.insert_model(model)
        assn_pat = ch.insert_pattern_string("NCC(=O<0>)[O;D1]<1>")
        ch.pattern_clear_tags(model_pat)
        if ch.match_1v1_n(assn_pat,model_pat,10000,2)>0:
                result = ch.pattern_get_ext_indices_with_tags(model_pat)
                for atom_tag in result[0]: # just iterate over atom tags
                    if len(atom_tag[1])==1: # one and only one match
                        if atom_tag[1][0]==1:
                            # the following expression both changes the formal charge and resets flag 23
                            alter_list.append([atom_tag[0],
                                                     "formal_charge=-1;flags=flags&-8388609"])
        
    # now evaluate all of these expressions efficiently en-masse 
    cmd.alter_list(selection,alter_list)

    # see if we missed any atoms
    missed_count = cmd.count_atoms("("+selection+") and flag 23")

    if missed_count>0:
        if not quiet:
            # looks like we did, so alter the user
            print " WARNING: %d atoms did not have formal charges assigned"%missed_count
        result = 0
    # remove the temporary selection we used to select appropriate residues
    
    cmd.delete(tmp_sele1)
    
    return result
コード例 #9
0
from chempy.champ import Champ

ch = Champ()
p1 = ch.insert_pattern_string("C(N)(F)O")
ch.pattern_dump(p1)

ch = Champ()
p1 = ch.insert_pattern_string("C1(N)(F).O1")
ch.pattern_dump(p1)
コード例 #10
0
from chempy.champ import Champ

ch = Champ()

# basic validation of stereochemistry handling on the simplest system

IS = [  # implicit patterns (S) 
    "[C@H](C)(N)O",
    "[C@H](N)(O)C",
    "[C@H](O)(C)N",
    "C[C@H](N)O",
    "N[C@H](O)C",
    "O[C@H](C)N",
    "[C@@H](C)(O)N",
    "[C@@H](N)(C)O",
    "[C@@H](O)(N)C",
    "C[C@@H](O)N",
    "N[C@@H](C)O",
    "O[C@@H](N)C",
]

IR = [  # implicit patterns (R) 
    "[C@@H](C)(N)O",
    "[C@@H](N)(O)C",
    "[C@@H](O)(C)N",
    "C[C@@H](N)O",
    "N[C@@H](O)C",
    "O[C@@H](C)N",
    "[C@H](C)(O)N",
    "[C@H](N)(C)O",
    "[C@H](O)(N)C",
コード例 #11
0
ファイル: 20export_naming.py プロジェクト: Almad/pymol
from pymol import cmd
from chempy.champ import Champ

import string


print '''# NOTE: This file was autogenerated
aa_dict = {'
'''

for res in (  'ala','arg','asp','asn','cys','gln','glu','gly','his','ile','leu','lys','met','phe','pro','ser','thr','trp','tyr','val' ):

   print "'"+string.upper(res)+"': ["
   
   ch = Champ()
   cmd.fragment(res,"tmp")
   model = cmd.get_model("tmp")
   cmd.delete("tmp")
   
   m1 = ch.insert_model(model)
   ch.pattern_detect_chirality(m1)
   ch.pattern_orient_bonds(m1)
   pat1 = ch.pattern_get_string_with_names(m1)
   ch.pattern_detect_chirality(m1)
   pat2 = ch.pattern_get_string_with_names(m1)

# confirm that CHAMP handles this pattern well...

   if pat1!=pat2:
      print " Chirality Assignment Error!"
コード例 #12
0
ファイル: 10stereo.py プロジェクト: Almad/pymol
from chempy.champ import Champ

ch = Champ()

# basic validation of stereochemistry handling on the simplest system

IS = [ # implicit patterns (S) 
   "[C@H](C)(N)O",
   "[C@H](N)(O)C",
   "[C@H](O)(C)N",

   "C[C@H](N)O",
   "N[C@H](O)C",
   "O[C@H](C)N",

   "[C@@H](C)(O)N",
   "[C@@H](N)(C)O",
   "[C@@H](O)(N)C",

   "C[C@@H](O)N",
   "N[C@@H](C)O",
   "O[C@@H](N)C",

   ]

IR = [ # implicit patterns (R) 
   "[C@@H](C)(N)O",
   "[C@@H](N)(O)C",
   "[C@@H](O)(C)N",

   "C[C@@H](N)O",
コード例 #13
0
ファイル: 01basic.py プロジェクト: Almad/pymol
from chempy.champ import Champ

ch = Champ()
p1 = ch.insert_pattern_string("C(N)(F)O")
ch.pattern_dump(p1)


ch = Champ()
p1 = ch.insert_pattern_string("C1(N)(F).O1")
ch.pattern_dump(p1)

コード例 #14
0
ファイル: 11stereo.py プロジェクト: Almad/pymol
from chempy.champ import Champ

ch = Champ()

# basic validation of stereochemistry handling on the simplest system

IS = [ # implicit patterns (S) 
   "[C@H](C)(N)O",
   "[C@H](N)(O)C",
   "[C@H](O)(C)N",

   "C[C@H](N)O",
   "N[C@H](O)C",
   "O[C@H](C)N",

   "[C@@H](C)(O)N",
   "[C@@H](N)(C)O",
   "[C@@H](O)(N)C",

   "C[C@@H](O)N",
   "N[C@@H](C)O",
   "O[C@@H](N)C",

   ]

IR = [ # implicit patterns (R) 
   "[C@@H](C)(N)O",
   "[C@@H](N)(O)C",
   "[C@@H](O)(C)N",

   "C[C@@H](N)O",
コード例 #15
0
from chempy.champ import Champ

ch = Champ()

# basic validation of stereochemistry handling on the simplest system

IS = [  # implicit patterns (S) 
    "[C@H](C)(N)O",
    "[C@H](N)(O)C",
    "[C@H](O)(C)N",
    "C[C@H](N)O",
    "N[C@H](O)C",
    "O[C@H](C)N",
    "[C@@H](C)(O)N",
    "[C@@H](N)(C)O",
    "[C@@H](O)(N)C",
    "C[C@@H](O)N",
    "N[C@@H](C)O",
    "O[C@@H](N)C",
]

IR = [  # implicit patterns (R) 
    "[C@@H](C)(N)O",
    "[C@@H](N)(O)C",
    "[C@@H](O)(C)N",
    "C[C@@H](N)O",
    "N[C@@H](O)C",
    "O[C@@H](C)N",
    "[C@H](C)(O)N",
    "[C@H](N)(C)O",
    "[C@H](O)(N)C",