Ejemplo n.º 1
0
 def collect_ftmap(cls):
     """Collect cluster objects from an FTMap session."""
     for obj in pm.get_object_list():
         if obj.endswith(".pdb"):
             new_name = obj[:-4].replace("crosscluster", "consensus")
             pm.set_name(obj, new_name)
     yield from cls.collect()
def cell_shift(object, dX, dY, dZ, rename = 1):
    if rename:
        oldName = object.split("_")
        oldPre = oldName[0]
        oldX = int(oldName[1])
        oldY = int(oldName[2])
        oldZ = int(oldName[3])
        newX = "_" + str(int(dX) + oldX)
        newY = "_" + str(int(dY) + oldY)
        newZ = "_" + str(int(dZ) + oldZ)
        newName = oldPre + newX + newY + newZ
        #if cmd.get_names().find(newName) != -1:
        #    print "Symmetry partner already exists in destination position!"
        #    quit()
        cmd.set_name(object, newName)
	object = newName
    stored.shift = [float(dX),float(dY),float(dZ)]
    stored.sgInfo = cmd.get_symmetry(object)
    a,b,c,alpha,beta,gamma = stored.sgInfo[0:6]
    ca = math.cos(math.radians(alpha))
    cb = math.cos(math.radians(beta))
    cg = math.cos(math.radians(gamma))
    sb = math.sin(math.radians(beta))
    sg = math.sin(math.radians(gamma))
    stored.fracToOrt = N.array([[a, b * cg, c * cb], 
                                [0.0, b * sg, c * (ca - cb * cg) / sg], 
                                [0.0, 0.0, c * sb * math.sqrt(1.0 - ((cb * cg - ca) / (sb * sg))**2)]])
    stored.fracToOrt = stored.fracToOrt.transpose()
    stored.ortToFrac = inv(stored.fracToOrt)
    cmd.cell_shift_helper = cell_shift_helper
    cmd.alter_state(1, object, "x,y,z = cmd.cell_shift_helper([x,y,z],stored.shift)")
def build_seq(name, seq,ss=None,phi=None,psi=None):
  """
  usage: build_seq name, seq [, ss=helix | phi=phi, psi=psi]
  example: build_seq peptide, QGAADLESLGQYFEEMKTKLIQDMTE, ss=helix 

  will build the above sequence in a helical conformation
  ss can be: helix or h or alpha  (phi=-57, psi=-47)
             antiparallel or beta (phi=-139, psi=-135)
             parallel             (phi=-119, psi=113)
             3/10 helix           (phi=-40.7,psi=30)
             polypro              (phi=-78, psi=149) (polyproline helix type II)

  Alternatively, you can specify the phi and psi angles directly:

  build_seq peptide, QGAADLESLGQ, phi=-60, psi=-40

  This will create an object with the name you provided, unless
  unless that selection already exists, then it will build onto that.

  """

  if name in cmd.get_names("selections"):
    obj='pk1'
  else:
    obj=seq[0:3]

  if phi == None or psi == None:
    if ss == None:
      phi = -139
      psi = -135
    else:
      ss = ss.lower()
      if ss[0:5] == 'helix' or ss[0] == 'h' or ss[0:5] == 'alpha':
        phi = -57
        psi = -47
      elif ss[0:5] == 'antip' or ss[0:4] == 'beta':
        phi = -139
        psi = -135
      elif ss[0:5] == 'paral':
        phi = -119
        psi = 113
      elif ss[0:4] == '3/10':
        phi = -40.7
        psi = -30
      elif ss[0:7] == 'polypro':
        phi = -78
        psi = 149

  print "Building sequence: ",seq

  ### Here seq_convert is used ###
#  seq3=seq_convert.seq1_to_seq3(seq)
  seq3=seq1_to_seq3(seq)
  attach_amino_acid(obj,seq3[0].lower(),phi,psi)
  for aa in seq3[1:]:
    aa = aa.lower()
    attach_amino_acid('pk1',aa,phi,psi)
  cmd.delete('pk1')
  cmd.delete('pkmol')
  cmd.set_name(seq3[0].lower(), name)
def draw_ENM(structure_filepath, script_filepath, structure_name="CAonly", output_dir='.', view=None):
    """ Draws elastic network model of a structure and saves image.
    """

    cmd.delete('all')
    cmd.load(structure_filepath, "CAonly")
    cmd.run(script_filepath)

    # Set name
    if structure_name == "CAonly":
        pass
    else:
        cmd.set_name("CAonly", structure_name)

    # Set view
    if view == None:
        cmd.orient()
    else:
        cmd.set_view(view)
    
    cmd.viewport(width=1200, height=1200)
    cmd.zoom(complete=1)

    png_filepath = os.path.join(output_dir, structure_name) + ".png"
    pse_filepath = os.path.join(output_dir, structure_name) + ".pse"

    cmd.save(pse_filepath)
    cmd.set('ray_opaque_background', 0)
    cmd.png(png_filepath, width=1200, height=1200, ray=1)

    return (pse_filepath, png_filepath)
Ejemplo n.º 5
0
def load_rep(target, offtarget):
    tprot = target[0]
    tprot_type = target[1]
    tligs = target[2:]

    cmd.load(tprot, tprot_type)
    for lig in tligs:
        cmd.load(lig, '%s_poses' % tprot_type[0])
    ligand_cartoon('(%s_poses or %s)' % (tprot_type[0], tprot_type))
    cmd.set_name('polar_contacts', '%s_polar_contacts' % tprot_type[0])
    util.cbag('(%s_poses or %s)' % (tprot_type[0], tprot_type))
    if offtarget:
        oprot = offtarget[0]
        oprot_type = offtarget[1]
        oligs = offtarget[2:]

        cmd.load(oprot, 'Off-Target')
        for lig in oligs:
            cmd.load(lig, 'O_poses')
        ligand_cartoon('(O_poses or Off-Target)')
        cmd.set_name('polar_contacts', 'O_polar_contacts')
        util.cbam('(O_poses or Off-Target)')
    # cmd.bg_color('white')
    # representation(rep)
    cmd.remove("all & hydro & not nbr. (don.|acc.)")
Ejemplo n.º 6
0
def select_catres(selection):
    """ Makes individual selections, each one containing all residues of the same
    index (in the PDB) from all objects."""

    groups = defaultdict(list)
    for obj in cmd.get_object_list(f'{selection}'):
        stored.ranked_atoms = {}
        cmd.iterate(obj, "stored.ranked_atoms[rank] = (f'/{model}//{chain}/{resi}', type)")

        # Make a list of residue selections, in the same order as in the PDB
        residues = []
        for k,v in sorted(stored.ranked_atoms.items()):
            if v[1] == 'HETATM':
                continue
            if v[0] not in residues:
                residues.append(v[0])

        for i, sele in enumerate(residues):
            groups[i].append(sele)

    # Now make group selections
    for i,reslist in groups.items():
        selection_name = f'catres_{i}'
        cmd.select('temp', 'none')
        for sele in reslist:
            cmd.select('cur', sele)
            cmd.select('temp', '(temp) or (cur)')
        cmd.set_name('temp', selection_name)
    cmd.delete('cur')
Ejemplo n.º 7
0
    def Btn_ExtractLigand_Clicked(self):

        state = cmd.get_state()

        # Get the Drop Down List Selection Name
        ddlSelection = self.defaultOption.get()

        if ddlSelection == '' or self.Validate_ObjectSelection(
                ddlSelection, 'Ligand', state):
            return

        LigandPath = tkFileDialog.asksaveasfilename(
            filetypes=[('PDB File', '*.pdb')],
            initialdir=self.top.FlexAIDLigandProject_Dir,
            title='Save the PDB File',
            initialfile=ddlSelection,
            defaultextension='.pdb')

        if len(LigandPath) > 0:

            LigandPath = os.path.normpath(LigandPath)

            if General.validate_String(LigandPath, '.pdb', True, False, True):
                self.DisplayMessage(
                    "  ERROR: Could not save the file because you entered an invalid name.",
                    2)
                return

            if self.top.ValidateSaveProject(LigandPath, 'Ligand'):
                self.DisplayMessage(
                    "  ERROR: The file can only be saved at its default location",
                    2)
                return

            try:
                cmd.save(LigandPath, ddlSelection, state)
                LigandName = os.path.basename(os.path.splitext(LigandPath)[0])

                cmd.extract(self.ExtractObject, ddlSelection)
                cmd.set_name(self.ExtractObject, LigandName)

                if ddlSelection != LigandName:
                    # as if the object was renamed, delete the object
                    cmd.delete(ddlSelection)

            except:
                self.DisplayMessage(
                    "  ERROR: An error occured while extracting the ligand object.",
                    1)
                return

            self.LigandPath.set(os.path.normpath(LigandPath))
            self.LigandName.set(LigandName)
            #self.LigandMD5.set(General.hashfile(self.LigandPath.get()))

            self.Reset_Ligand()

            self.DisplayMessage(
                '  Successfully extracted the ligand:  ' +
                self.LigandName.get() + "'", 0)
Ejemplo n.º 8
0
def build_seq(name, seq, ss=None, phi=None, psi=None):
    """
  usage: build_seq name, seq [, ss=helix | phi=phi, psi=psi]
  example: build_seq peptide, QGAADLESLGQYFEEMKTKLIQDMTE, ss=helix 

  will build the above sequence in a helical conformation
  ss can be: helix or h or alpha  (phi=-57, psi=-47)
             antiparallel or beta (phi=-139, psi=-135)
             parallel             (phi=-119, psi=113)
             3/10 helix           (phi=-40.7,psi=30)
             polypro              (phi=-78, psi=149) (polyproline helix type II)

  Alternatively, you can specify the phi and psi angles directly:

  build_seq peptide, QGAADLESLGQ, phi=-60, psi=-40

  This will create an object with the name you provided, unless
  unless that selection already exists, then it will build onto that.

  """

    if name in cmd.get_names("selections"):
        obj = 'pk1'
    else:
        obj = seq[0:3]

    if phi == None or psi == None:
        if ss == None:
            phi = -139
            psi = -135
        else:
            ss = ss.lower()
            if ss[0:5] == 'helix' or ss[0] == 'h' or ss[0:5] == 'alpha':
                phi = -57
                psi = -47
            elif ss[0:5] == 'antip' or ss[0:4] == 'beta':
                phi = -139
                psi = -135
            elif ss[0:5] == 'paral':
                phi = -119
                psi = 113
            elif ss[0:4] == '3/10':
                phi = -40.7
                psi = -30
            elif ss[0:7] == 'polypro':
                phi = -78
                psi = 149

    print "Building sequence: ", seq

    ### Here seq_convert is used ###
    #  seq3=seq_convert.seq1_to_seq3(seq)
    seq3 = seq1_to_seq3(seq)
    attach_amino_acid(obj, seq3[0].lower(), phi, psi)
    for aa in seq3[1:]:
        aa = aa.lower()
        attach_amino_acid('pk1', aa, phi, psi)
    cmd.delete('pk1')
    cmd.delete('pkmol')
    cmd.set_name(seq3[0].lower(), name)
Ejemplo n.º 9
0
def cell_shift(object, dX, dY, dZ, rename=1):
    if rename:
        oldName = object.split("_")
        oldPre = oldName[0]
        oldX = int(oldName[1])
        oldY = int(oldName[2])
        oldZ = int(oldName[3])
        newX = "_" + str(int(dX) + oldX)
        newY = "_" + str(int(dY) + oldY)
        newZ = "_" + str(int(dZ) + oldZ)
        newName = oldPre + newX + newY + newZ
        #if cmd.get_names().find(newName) != -1:
        #    print "Symmetry partner already exists in destination position!"
        #    quit()
        cmd.set_name(object, newName)
        object = newName
    stored.shift = [float(dX), float(dY), float(dZ)]
    stored.sgInfo = cmd.get_symmetry(object)
    a, b, c, alpha, beta, gamma = stored.sgInfo[0:6]
    ca = math.cos(math.radians(alpha))
    cb = math.cos(math.radians(beta))
    cg = math.cos(math.radians(gamma))
    sb = math.sin(math.radians(beta))
    sg = math.sin(math.radians(gamma))
    stored.fracToOrt = N.array(
        [[a, b * cg, c * cb], [0.0, b * sg, c * (ca - cb * cg) / sg],
         [0.0, 0.0,
          c * sb * math.sqrt(1.0 - ((cb * cg - ca) / (sb * sg))**2)]])
    stored.fracToOrt = stored.fracToOrt.transpose()
    stored.ortToFrac = inv(stored.fracToOrt)
    cmd.cell_shift_helper = cell_shift_helper
    cmd.alter_state(1, object,
                    "x,y,z = cmd.cell_shift_helper([x,y,z],stored.shift)")
Ejemplo n.º 10
0
 def testGroupRename(self):
     '''
     Rename group entries which have a group name prefix when renaming the group
     '''
     cmd.set('group_auto_mode', 2)
     cmd.pseudoatom('g1.m1')
     cmd.pseudoatom('g1.m2')
     cmd.set_name('g1', 'g2')
     m_list = []
     cmd.iterate('g2', 'm_list.append(model)', space=locals())
     self.assertItemsEqual(m_list, ['g2.m1', 'g2.m2'])
Ejemplo n.º 11
0
def builder(residues, bonds, mol_name):
    """Using the list generated by read_input connects monosacharides in 
    a single oligosaccharide"""
    cmd.set('suspend_updates', 'on')
    cmd.feedback('disable', 'executive', 'actions')
    every_object = cmd.get_object_list('all')
    if mol_name in every_object:
        cmd.delete(mol_name)
        every_object.remove(mol_name)
    if every_object:
        sel = 'not (' + ' or '.join(every_object) + ') and'
    else:
        sel = ''
    for i in range(0, len(residues)):
        res_name = residues[i]
        cmd.load(os.path.join(path, 'db_glycans', '%s.pdb' % res_name))
        cmd.set_name(res_name,
                     i)  #rename object (necessary to avoid repeating names)
        cmd.alter(i, 'resi = %s' % i)  #name residues for further referencing
        cmd.sort(i)
    for i in range(0, len(bonds)):
        resi_i, resi_j, atom_i, atom_j = bonds[i][0], bonds[i][2], bonds[i][
            4], bonds[i][5]
        if atom_i > atom_j:
            cmd.remove('%s (resi %s and name O%s+H%so)' %
                       (sel, resi_j, atom_j, atom_j))
            cmd.remove('%s (resi %s and name H%so)' % (sel, resi_i, atom_i))
            cmd.fuse('%s (resi %s and name O%s)' % (sel, resi_i, atom_i),
                     '%s (resi %s and name C%s)' % (sel, resi_j, atom_j),
                     mode=2)
        else:
            cmd.remove('%s (resi %s and name O%s+H%so)' %
                       (sel, resi_i, atom_i, atom_i))
            cmd.remove('%s (resi %s and name H%so)' % (sel, resi_j, atom_j))
            cmd.fuse('%s (resi %s and name C%s)' % (sel, resi_i, atom_i),
                     '%s (resi %s and name O%s)' % (sel, resi_j, atom_j),
                     mode=2)
        cmd.delete('%s' % i)
    cmd.copy(mol_name, '%s' % resi_j)
    cmd.delete('%s' % resi_j)
    for i in range(0, len(bonds)):
        set_phi(mol_name, bonds[i], -60)
        set_psi(mol_name, bonds[i], 120)
    cmd.delete('pk1')
    cmd.delete('pk2')
    cmd.delete('pkbond')
    cmd.delete('pkmol')
    if babel:
        fast_min(mol_name, 5000)
        minimize(mol_name)
    else:
        fast_min(mol_name, 5000)
    cmd.feedback('enable', 'executive', 'actions')
    cmd.set('suspend_updates', 'off')
Ejemplo n.º 12
0
    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")
Ejemplo n.º 13
0
	def setNative(self, base=""):

		# --- get last structure --- #
		if base == "":
			sess = cmd.get_session()
			for i in sess["names"]:
				if type(i) is ListType:
					base = i[0]

		cmd.set_name(base, "native")
		file = base + ".pdb"
		self.viewer.setNative(file)
		self.viewer.displayNative()
Ejemplo n.º 14
0
def export_pymol(file1, file2):
    py_object1 = file1.rsplit(".sdf", maxsplit=1)[0]
    py_object2 = file2.rsplit(".sdf", maxsplit=1)[0]
    pref1 = py_object1.split("/")[-1]
    pref2 = py_object2.split("/")[-1]
    cmd.load(filename=file1)
    cmd.set_name(pref1, "query_conf")
    cmd.load(filename=file2)
    cmd.split_states(object="query_conf")
    cmd.split_states(object=pref2)
    cmd.delete("query_conf")
    cmd.delete(pref2)
    cmd.save(f"{py_object2}.pse")
    cmd.delete("all")
Ejemplo n.º 15
0
	def setDesigned(self, base=""):
		
		# --- get last structure --- #
		if base == "":
			sess = cmd.get_session()
			for i in sess["names"]:
				if type(i) is ListType:
					base = i[0]

		file = base + ".pdb"
		cmd.set_name(base, "designed")
		self.viewer.setDesign(file)
		self.viewer.selectCatalytic()
		self.viewer.displayDesigned()
Ejemplo n.º 16
0
 def getListOfModels(self):
     #models can not contain the underscore character '_'
     #this is a Pmw limitation, but PyMOL does add such
     #characters often
     initialList = cmd.get_object_list()
     outputList = list();
     for m in initialList:
         if '_' in m:
             newName = m.translate(None,"_")
             cmd.set_name(m,newName)
             message("WARNING Renaming model \'"+m+ "\' to \'"+ newName+"\'")
             m = newName
         outputList.append(m)
     return outputList
Ejemplo n.º 17
0
def main(design_path, original_pdbs_directory='pdb'):
    """loads to the pymol session the original blades of the design.
    Args:
        design_path: path to the wanted design
	original_pdbs_directory: path to directory where all  pdbs are 
    """
    segment_count = 0
    for line in open(design_path):
        if line.startswith('segment_') and 'frm' not in line:
            segment_count += 1
            original = line.split()[-1]
            name = '{}_{}'.format(segment_count, original)
            print name
            cmd.load('{}/{}.pdb'.format(original_pdbs_directory, original))
            cmd.set_name(original, name)
Ejemplo n.º 18
0
    def Btn_ExtractLigand_Clicked(self):
                
        state = cmd.get_state()

        # Get the Drop Down List Selection Name
        ddlSelection = self.defaultOption.get()
        
        if ddlSelection == '' or self.Validate_ObjectSelection(ddlSelection, 'Ligand', state):
            return
        
        LigandPath = tkFileDialog.asksaveasfilename(filetypes=[('PDB File','*.pdb')],
                                                    initialdir=self.top.FlexAIDLigandProject_Dir, title='Save the PDB File', 
                                                    initialfile=ddlSelection, defaultextension='.pdb')
        
        if len(LigandPath) > 0:
            
            LigandPath = os.path.normpath(LigandPath)

            if General.validate_String(LigandPath, '.pdb', True, False, True):
                self.DisplayMessage("  ERROR: Could not save the file because you entered an invalid name.", 2)
                return

            if self.top.ValidateSaveProject(LigandPath, 'Ligand'):
                self.DisplayMessage("  ERROR: The file can only be saved at its default location", 2)
                return

            try:
                cmd.save(LigandPath, ddlSelection, state)
                LigandName = os.path.basename(os.path.splitext(LigandPath)[0])

                cmd.extract(self.ExtractObject, ddlSelection)
                cmd.set_name(self.ExtractObject, LigandName)
                
                if ddlSelection != LigandName:
                    # as if the object was renamed, delete the object
                    cmd.delete(ddlSelection)
                
            except:
                self.DisplayMessage("  ERROR: An error occured while extracting the ligand object.", 1)
                return
            
            self.LigandPath.set(os.path.normpath(LigandPath))
            self.LigandName.set(LigandName)
            #self.LigandMD5.set(General.hashfile(self.LigandPath.get()))

            self.Reset_Ligand()
            
            self.DisplayMessage('  Successfully extracted the ligand:  ' + self.LigandName.get() + "'", 0)
Ejemplo n.º 19
0
 def refreshModelSelectionWidget(self):
     self.modsW.deleteall()
     mols = self.getListOfModels()
     for m in mols:
         if '_' in m:
             newName = m
             newName.replace('_', '-')
             cmd.set_name(m,newName)
             m = newName
             message("Renaming a model...")
         self.modsW.add(m)
     if 1 > len(self.getListOfModels()):
         self.warnLabel.pack(fill='both', expand=True, padx=10, pady=5)
     else:
         self.warnLabel.pack_forget()
     return
Ejemplo n.º 20
0
 def refreshModelSelectionWidget(self):
     self.modsW.deleteall()
     mols = self.getListOfModels()
     for m in mols:
         if '_' in m:
             newName = m
             newName.replace('_', '-')
             cmd.set_name(m, newName)
             m = newName
             message("Renaming a model...")
         self.modsW.add(m)
     if 1 > len(self.getListOfModels()):
         self.warnLabel.pack(fill='both', expand=True, padx=10, pady=5)
     else:
         self.warnLabel.pack_forget()
     return
Ejemplo n.º 21
0
def builder(residues, bonds, mol_name):
    """Using the list generated by read_input connects monosacharides in 
    a single oligosaccharide"""
    cmd.set('suspend_updates', 'on')
    cmd.feedback('disable', 'executive', 'actions')
    every_object = cmd.get_object_list('all')
    if mol_name in every_object:
        cmd.delete(mol_name)
        every_object.remove(mol_name)
    if every_object:
        sel = 'not (' + ' or '.join(every_object) + ') and'
    else:
        sel = ''
    for i in range(0, len(residues)):
        res_name = residues[i]
        cmd.load(os.path.join(path, 'db_glycans', '%s.pdb' % res_name))
        cmd.set_name(res_name, i)  #rename object (necessary to avoid repeating names)
        cmd.alter(i, 'resi = %s' % i)  #name residues for further referencing
        cmd.sort(i)
    for i in range(0, len(bonds)):
        resi_i, resi_j, atom_i, atom_j = bonds[i][0], bonds[i][2], bonds[i][4], bonds[i][5]
        if atom_i > atom_j:
            cmd.remove('%s (resi %s and name O%s+H%so)' % (sel, resi_j, atom_j, atom_j))
            cmd.remove('%s (resi %s and name H%so)' % (sel, resi_i, atom_i))
            cmd.fuse('%s (resi %s and name O%s)' % (sel, resi_i, atom_i), '%s (resi %s and name C%s)' % (sel, resi_j, atom_j), mode=2)
        else:
            cmd.remove('%s (resi %s and name O%s+H%so)' % (sel, resi_i, atom_i, atom_i))
            cmd.remove('%s (resi %s and name H%so)' % (sel, resi_j, atom_j))
            cmd.fuse('%s (resi %s and name C%s)' % (sel, resi_i, atom_i), '%s (resi %s and name O%s)' % (sel, resi_j, atom_j), mode=2)
        cmd.delete('%s' % i)
    cmd.copy(mol_name, '%s' % resi_j)
    cmd.delete('%s' % resi_j)          
    for i in range(0, len(bonds)):
        set_phi(mol_name, bonds[i], -60)
        set_psi(mol_name, bonds[i], 120) 
    cmd.delete('pk1')
    cmd.delete('pk2')
    cmd.delete('pkbond')
    cmd.delete('pkmol')
    if babel:
        fast_min(mol_name, 5000)
        minimize(mol_name)
    else:
        fast_min(mol_name, 5000)
    cmd.feedback('enable', 'executive', 'actions')
    cmd.set('suspend_updates', 'off')
Ejemplo n.º 22
0
    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:
            if not hasattr(row, "seg"):
                raise ValueError(
                    "row has no column \"seg\", but self.df_rgn_seg_res_bb is None - maybe parameter \"coarse_grain_type\" is not properly set?"
                )
            cmd.select(
                "sel",
                "/%s/%s and i. %d and not h." % (mymol, row.seg, row.res))
        else:
            if not hasattr(row, "rgn"):
                raise ValueError(
                    "row has no column \"rgn\", but self.df_rgn_seg_res_bb is not None - maybe parameter \"coarse_grain_type\" is not properly set?"
                )
            df_unique_rgnsegbb = self.df_rgn_seg_res_bb[["seg"
                                                         ]].drop_duplicates()
            for myrgn in [row.rgn]:
                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.rgn, "sel")
        count = cmd.count_atoms("sel")
        if count == 0:
            if self.df_rgn_seg_res_bb is None:
                raise ValueError("count for %s.%d.%s.%d is zero!" %
                                 (row.seg, row.res, row.rnm))
            else:
                raise ValueError("count for %s is zero!" % (row.rgn))
        else:
            if self.df_rgn_seg_res_bb is None:
                cmd.show("sticks", "sel and (sidechain or name ca)")
                cmd.color(self.sgn2col[mycolind],
                          "sel and (sidechain or name ca)")
            else:
                #cmd.show("sticks", "sel")
                cmd.color(self.sgn2col[mycolind], "sel")

        cmd.delete("sel")
Ejemplo n.º 23
0
def sort_dcoms(subs):
    N = len(subs) / 2
    for i in range(1, N + 1):
        assert "tmp%iA" % i in cmd.get_object_list()
    for i in range(1, N + 1):
        assert "tmp%iB" % i in cmd.get_object_list()
    coms = [com(s) for s in subs]
    tmp = [(coms[0].distance(x), i) for i, x in enumerate(coms)]
    tmp.sort()
    td = tmp[2][0] - tmp[1][0] < tmp[3][0] - tmp[2][0]
    ring = [tmp[1 if td else 2][1], 0, tmp[2 if td else 3][1]]
    while len(ring) < N:
        tmp = [(coms[ring[-1]].distance(x), i) for i, x in enumerate(coms)]
        tmp.sort()
        assert (tmp[2][0] - tmp[1][0] < tmp[3][0] - tmp[2][0]) == td
        v1 = tmp[1 if td else 2][1]
        v2 = tmp[2 if td else 3][1]
        assert ring[-2] in (v1, v2)
        ring.append(v1 if v2 == ring[-2] else v2)
        # print ring
        # print [subs[i] for i in ring]
    namemap = {}
    for i, r in enumerate(ring):
        assert not subs[r] in namemap
        namemap[subs[r]] = "sub%iA" % (i + 1)
        tmp = [(coms[r].distance(x), j) for j, x in enumerate(coms)]
        tmp.sort()
        # print r, [subs[x[1]] for x in tmp]
        sub_partner = subs[tmp[3 if td else 1][1]]
        assert not sub_partner in namemap
        namemap[sub_partner] = "sub%iB" % (i + 1)
    assert len(set(namemap.keys())) == 2 * N
    for i in range(1, N + 1):
        assert "tmp%iA" % i in cmd.get_object_list()
    for i in range(1, N + 1):
        assert "tmp%iB" % i in cmd.get_object_list()
    chains = {}
    for i in range(N):
        chains["sub%iA" % (i + 1)] = string.uppercase[2 * N + 0]
        chains["sub%iB" % (i + 1)] = string.uppercase[2 * N + 1]
    for k in namemap:
        cmd.set_name(k, namemap[k])
        cmd.alter(namemap[k], "chain = '%s'" % chains[namemap[k]])
    for i in chains:
        assert i in cmd.get_object_list()
Ejemplo n.º 24
0
    def extrude_hub_at_single_n(single_name=None,
                                hub_name=None,
                                component_id=None):
        """Extrudes a hub at the n-terminus of a single module.

        Args:
        - single_name - string
        - hub_name - string
        - component_id - string id of the module component inside the hub to
            extend into
        """
        if single_name is None or \
            hub_name is None or \
            component_id is None:
            print(extrude_hub_at_single_n.__doc__)
        else:
            double_name = '-'.join([single_name, single_name])

            pdb_dir = os.getcwd() + '/../../resources/pdb_aligned/'

            cmd.load(pdb_dir + '/singles/' + single_name + '.pdb')
            cmd.set_name(single_name, 'single')
            cmd.load(pdb_dir + '/doubles/' + double_name + '.pdb')
            cmd.set_name(double_name, 'double')
            cmd.load(pdb_dir + '/doubles/' + double_name + '.pdb')
            cmd.set_name(double_name, 'double-o')
            cmd.load(pdb_dir + '/hubs/' + hub_name + '.pdb')
            cmd.set_name(hub_name, 'hub')

            xdb = utilities.read_json(os.getcwd() +
                                      '/../../resources/xdb.json')
            double_info = xdb['double_data'][single_name][single_name]

            # first, drop the double for reference
            tx('double',
               rot=double_info['rot'],
               tran_after=double_info['tran'])

            hub_comp_info = xdb['hub_data'][hub_name]['component_info']
            comp_a_cc = hub_comp_info[component_id]['c_connections'][
                single_name]

            # The frame drop order is important here

            # drop hub into component frame
            tx('hub', rot=comp_a_cc['rot'], tran_after=comp_a_cc['tran'])

            # drop hub into double's frame
            tx('hub', rot=double_info['rot'], tran_after=double_info['tran'])

            noclip()

            print('Extruded Hub {} Component {} at Single {}\'s N-Term'.\
                format(hub_name, component_id, single_name))
Ejemplo n.º 25
0
def show_active_siteMYR():
    """
    Select, shows active site of MYR ligand in range of 5 Angstrom
    """
    print(' >>>> Show active site <<<<')
    file_object = open('Full_AS_intr_res_list.csv', 'w')
    file_object1 = open('AS_intr_res_list.csv', 'w')
    #cmd.do("select active_site, ligands around 5");
    obj_list = cmd.get_names('objects')
    print(obj_list)
    for obj in obj_list:
        cmd.do("AS_res_list=[]")
        cmd.do("AS_L = []")
        cmd.do("AS_L_num = []")
        cmd.do("Lig_list=[]")
        cmd.do("fix_Lig_list=[]")
        cmd.do("AS_res_num_list=[]")
        obj_us_list = []
        print(obj)
        cmd.do("select resn MYR and " + str(obj))
        cmd.do("iterate sele, Lig_list.append((resi + resn))")
        #print list of ligands in pdbs
        cmd.do("fix_Lig_list=set(list(Lig_list))")
        #print((str(obj), fix_Lig_list))
        cmd.do("select sele1,( br. " + str(obj) +
               " within 5 of sele) and not sele")
        #and not sele")
        cmd.do("util.cbay sele1")
        cmd.do("iterate sele1, AS_res_list.append((resi, resn))")
        cmd.do("iterate sele1, AS_res_num_list.append((resi))")
        cmd.do("AS_L=(list(set(AS_res_list)))")
        cmd.do("AS_L_num=(list(set(AS_res_num_list)))")
        #print(str(obj), fix_Lig_list, fix_Lig_list, AS_L)\
        #change obj to list  for purpose of futher file playing :P
        cmd.do("if AS_L==[]: AS_L=['0']")
        cmd.do("if AS_L_num==[]: AS_L_num=['0']")
        file_object.write(csv_formatted_output(obj, fix_Lig_list, AS_L))
        file_object1.write(csv_formatted_output(obj, fix_Lig_list, AS_L_num))

        cmd.set_name("sele1", "AS_" + str(obj))

    file_object.close()
    file_object1.close()
Ejemplo n.º 26
0
    def test2667(self):
        cmd.fragment('ala', 'm1')
        cmd.alter_state(1, '%m1', 's.label_placement_offset = [1., 0., 0.]')

        with testing.mktemp('.pse') as filename:
            cmd.save(filename)
            cmd.set_name('m1', 'm2')
            cmd.load(filename, partial=1)

        # now we have two copies (m1 m2). If unique ids are converted upon
        # loading, then there will be no settings cross-leaking. Otherwise
        # changing m1 settings will affect m2.

        cmd.alter_state(1, '%m1', 's.label_placement_offset = [0., 1., 0.]')

        m2_setting = []
        cmd.iterate_state(1,
                'first %m2', 'm2_setting.append(s.label_placement_offset)',
                space=locals())

        self.assertArrayEqual([1., 0., 0.], m2_setting[0], 0.001)
Ejemplo n.º 27
0
    def test2667(self):
        cmd.fragment('ala', 'm1')
        cmd.alter_state(1, '%m1', 's.label_placement_offset = [1., 0., 0.]')

        with testing.mktemp('.pse') as filename:
            cmd.save(filename)
            cmd.set_name('m1', 'm2')
            cmd.load(filename, partial=1)

        # now we have two copies (m1 m2). If unique ids are converted upon
        # loading, then there will be no settings cross-leaking. Otherwise
        # changing m1 settings will affect m2.

        cmd.alter_state(1, '%m1', 's.label_placement_offset = [0., 1., 0.]')

        m2_setting = []
        cmd.iterate_state(1,
                          'first %m2',
                          'm2_setting.append(s.label_placement_offset)',
                          space=locals())

        self.assertArrayEqual([1., 0., 0.], m2_setting[0], 0.001)
Ejemplo n.º 28
0
def load_rep(target, offtarget):
    tprot = target[0]
    tprot_type = target[1]
    tligs = target[2:]

    cmd.load(tprot, tprot_type)
    for lig in tligs:
        cmd.load(lig, '%s_poses' % tprot_type[0])
    ligand_cartoon('(%s_poses or %s)' % (tprot_type[0], tprot_type))
    cmd.set_name('polar_contacts', '%s_polar_contacts' % tprot_type[0])
    util.cbag('(%s_poses or %s)' % (tprot_type[0], tprot_type))
    if offtarget:
        oprot = offtarget[0]
        oprot_type = offtarget[1]
        oligs = offtarget[2:]

        cmd.load(oprot, 'Off-Target')
        for lig in oligs:
            cmd.load(lig, 'O_poses')
        ligand_cartoon('(O_poses or Off-Target)')
        cmd.set_name('polar_contacts', 'O_polar_contacts')
        util.cbam('(O_poses or Off-Target)')
Ejemplo n.º 29
0
 def getListOfModels(self):
     #models can not contain the underscore character '_'
     #this is a Pmw limitation, but PyMOL does add such
     #characters often
     #dots are also removed, as they confuse crysol
     initialList = cmd.get_object_list()
     outputList = list()
     for m in initialList:
         if '_' in m:
             newName = m.translate(None, "_")
             cmd.set_name(m, newName)
             message("WARNING Renaming model \'" + m + "\' to \'" +
                     newName + "\'")
             m = newName
         if '.' in m:
             newName = m.translate(None, ".")
             cmd.set_name(m, newName)
             message("WARNING Renaming model \'" + m + "\' to \'" +
                     newName + "\'")
             m = newName
         outputList.append(m)
     return outputList
    def extrude_single_at_single_n(single_name=None, ext_single_name=None):
        """Extrudes a single at the n-terminus of a single module.

        Args:
        - single_name - string name of the fixed single
        - ext_single_name - string name of the extension single
        """
        if single_name is None or \
            ext_single_name is None:
            print(extrude_single_at_single_n.__doc__)
        else:
            double_name = '-'.join([ext_single_name, single_name])

            pdb_dir = os.getcwd() + '/../../resources/pdb_aligned/'

            cmd.load(pdb_dir + '/doubles/' + double_name + '.pdb')
            cmd.set_name(double_name, 'double')
            cmd.load(pdb_dir + '/singles/' + single_name + '.pdb')
            cmd.set_name(single_name, 'single')
            cmd.load(pdb_dir + '/singles/' + ext_single_name + '.pdb')
            cmd.set_name(ext_single_name, 'single-ext')

            xdb = utilities.read_json(os.getcwd() +
                                      '/../../resources/xdb.json')
            double_info = xdb['double_data'][ext_single_name][single_name]

            # first, drop the double (into its A frame) for reference
            tx('double',
               rot=double_info['rot'],
               tran_after=double_info['tran'])

            # extrude N term - drop into double's A frame
            tx('single-ext',
               rot=double_info['rot'],
               tran_after=double_info['tran'])

            cmd.disable('single-*')
            cmd.enable('single-ext')

            noclip()

            print('Extruded Single {} at Single {}\'s N-Term'.\
            format(ext_single_name, single_name))
Ejemplo n.º 31
0
    def extrude_hub_at_single_c(single_name=None,
                                hub_name=None,
                                component_id=None):
        """Extrudes a hub at the c-terminus of a single module.

        Args:
        - single_name - string
        - hub_name - string
        - component_id - string, indicating which module component inside the hub
            to extend into
        """
        if single_name is None or \
            hub_name is None or \
            component_id is None:
            print(extrude_hub_at_single_c.__doc__)
        else:
            double_name = '-'.join([single_name, single_name])

            pdb_dir = os.getcwd() + '/../../resources/pdb_aligned/'

            cmd.load(pdb_dir + '/singles/' + single_name + '.pdb')
            cmd.set_name(single_name, 'single')
            cmd.load(pdb_dir + '/doubles/' + double_name + '.pdb')
            cmd.set_name(double_name, 'double')
            cmd.load(pdb_dir + '/hubs/' + hub_name + '.pdb')
            cmd.set_name(hub_name, 'hub')

            xdb = utilities.read_json(os.getcwd() +
                                      '/../../resources/xdb.json')
            hub_comp_info = xdb['hub_data'][hub_name]['component_info']
            comp_a_cc = hub_comp_info[component_id]['n_connections'][
                single_name]

            tx('hub', rot=comp_a_cc['rot'], tran_after=comp_a_cc['tran'])

            noclip()

            print('Extruded Hub {} Component {} at Single {}\'s C-Term'.\
                format(hub_name, component_id, single_name))
    def extrude_single_at_single_c(single_name=None, ext_single_name=None):
        """Extrudes a single at the c-terminus of a single module.

        Args:
        - single_name - string name of the fixed single
        - ext_single_name - string name of the extension single
        """
        if single_name is None or \
            ext_single_name is None:
            print(extrude_single_at_single_c.__doc__)
        else:
            double_name = '-'.join([single_name, ext_single_name])

            pdb_dir = os.getcwd() + '/../../resources/pdb_aligned/'

            cmd.load(pdb_dir + '/doubles/' + double_name + '.pdb')
            cmd.set_name(double_name, 'double')
            cmd.load(pdb_dir + '/singles/' + single_name + '.pdb')
            cmd.set_name(single_name, 'single')
            cmd.load(pdb_dir + '/singles/' + ext_single_name + '.pdb')
            cmd.set_name(ext_single_name, 'single-ext')

            xdb = utilities.read_json(os.getcwd() +
                                      '/../../resources/xdb.json')
            double_info = xdb['double_data'][single_name][ext_single_name]

            # extrude C term - raise
            tx('single-ext',
               rot=np.array(double_info['rot']).transpose().tolist(),
               tran_before=[-t for t in double_info['tran']])

            cmd.disable('single-*')
            cmd.enable('single-ext')

            noclip()

            print('Extruded Single {} at Single {}\'s N-Term'.\
            format(ext_single_name, single_name))
Ejemplo n.º 33
0
def visualize_in_pymol(plcomplex):
    """Visualizes the protein-ligand pliprofiler at one site in PyMOL."""

    vis = PyMOLVisualizer(plcomplex)

    #####################
    # Set everything up #
    #####################

    pdbid = plcomplex.pdbid
    lig_members = plcomplex.lig_members
    chain = plcomplex.chain
    if config.PEPTIDES != []:
        vis.ligname = 'PeptideChain%s' % plcomplex.chain
    if config.INTRA is not None:
        vis.ligname = 'Intra%s' % plcomplex.chain

    ligname = vis.ligname
    hetid = plcomplex.hetid

    metal_ids = plcomplex.metal_ids
    metal_ids_str = '+'.join([str(i) for i in metal_ids])

    ########################
    # Basic visualizations #
    ########################

    start_pymol(run=True, options='-pcq', quiet=not config.DEBUG)
    vis.set_initial_representations()

    cmd.load(plcomplex.sourcefile)
    current_name = cmd.get_object_list(selection='(all)')[0]
    write_message('Setting current_name to "%s" and pdbid to "%s\n"' % (current_name, pdbid), mtype='debug')
    cmd.set_name(current_name, pdbid)
    cmd.hide('everything', 'all')
    if config.PEPTIDES != []:
        cmd.select(ligname, 'chain %s and not resn HOH' % plcomplex.chain)
    else:
        cmd.select(ligname, 'resn %s and chain %s and resi %s*' % (hetid, chain, plcomplex.position))
    write_message("Selecting ligand for PDBID %s and ligand name %s with: " % (pdbid, ligname), mtype='debug')
    write_message('resn %s and chain %s and resi %s*' % (hetid, chain, plcomplex.position), mtype='debug')

    # Visualize and color metal ions if there are any
    if not len(metal_ids) == 0:
        vis.select_by_ids(ligname, metal_ids, selection_exists=True)
        cmd.show('spheres', 'id %s and %s' % (metal_ids_str, pdbid))

    # Additionally, select all members of composite ligands
    if len(lig_members) > 1:
        for member in lig_members:
           resid, chain, resnr = member[0], member[1], str(member[2])
           cmd.select(ligname, '%s or (resn %s and chain %s and resi %s)' % (ligname, resid, chain, resnr))

    cmd.show('sticks', ligname)
    cmd.color('myblue')
    cmd.color('myorange', ligname)
    cmd.util.cnc('all')
    if not len(metal_ids) == 0:
        cmd.color('hotpink', 'id %s' % metal_ids_str)
        cmd.hide('sticks', 'id %s' % metal_ids_str)
        cmd.set('sphere_scale', 0.3, ligname)
    cmd.deselect()

    vis.make_initial_selections()

    vis.show_hydrophobic()  # Hydrophobic Contacts
    vis.show_hbonds()  # Hydrogen Bonds
    vis.show_halogen()  # Halogen Bonds
    vis.show_stacking()  # pi-Stacking Interactions
    vis.show_cationpi()  # pi-Cation Interactions
    vis.show_sbridges()  # Salt Bridges
    vis.show_wbridges()  # Water Bridges
    vis.show_metal()  # Metal Coordination

    vis.refinements()

    vis.zoom_to_ligand()

    vis.selections_cleanup()

    vis.selections_group()
    vis.additional_cleanup()
    if config.DNARECEPTOR:
        # Rename Cartoon selection to Line selection and change repr.
        cmd.set_name('%sCartoon' % plcomplex.pdbid, '%sLines' % plcomplex.pdbid)
        cmd.hide('cartoon', '%sLines' % plcomplex.pdbid)
        cmd.show('lines', '%sLines' % plcomplex.pdbid)

    if config.PEPTIDES != []:
        filename = "%s_PeptideChain%s" % (pdbid.upper(), plcomplex.chain)
        if config.PYMOL:
            vis.save_session(config.OUTPATH, override=filename)
    elif config.INTRA is not None:
        filename = "%s_IntraChain%s" % (pdbid.upper(), plcomplex.chain)
        if config.PYMOL:
            vis.save_session(config.OUTPATH, override=filename)
    else:
        filename = '%s_%s' % (pdbid.upper(), "_".join([hetid, plcomplex.chain, plcomplex.position]))
        if config.PYMOL:
            vis.save_session(config.OUTPATH)
    if config.PICS:
        vis.save_picture(config.OUTPATH, filename)
Ejemplo n.º 34
0
def split_alignment(object, object1=None, object2=None, delimiter="_"):
    """DESCRIPTION

    Splits a two-state object into two separate objects.

USAGE

    split_alignment object[, object1, object2][, delimiter]

ARGUMENTS

    object      Two-state input object
    object1     What to name the first state from the object [optional]
    object2     What to name the second state from the object [optional]
    delimiter   Delimiter which separates object1 and object2 in the object name.
                See DETAILS. [default '_']

DETAILS

    The input object must contain at least two states. Additional states are
    ignored.

    If object1 and object2 are ommitted, the script will attempt to generate
    them based on the input object's name. The name is split around the first
    instance of <delimiter>.  Thus, objects which follow the convention
    "object1_object2" will be properly split without additional arguments.

EXAMPLES

    # Results in objects '1AX8.A' and '3PIV.A'
    split_alignment 1AX8.A_3PIV.A

    # Results in objects 'query' and 'target'
    split_alignment alignment, query, target

    # Results in objects '1AX8.A' and '3PIV.A'
    split_alignment 1AX8.A_vs_3PIV.A, delimiter="_vs_"

"""
    # check that we have at least two states
    if cmd.count_states(object) < 2:
        print ("Error: input object must contain at least two states.")
        return

    prefix = "split%04d_" % random.randint(0, 9999)  # make unique

    # guess output names
    if object1 is None and object2 is None:
        try:
            d = object.index(delimiter)
            object1 = object[:d]
            object2 = object[d + len(delimiter) :]
        except:
            object1 = "%s_%04d" % (object, 1)
            object2 = "%s_%04d" % (object, 2)
            print "Warning: '%s' not found in '%s'. Using names %s and %s." % (delimiter, object, object1, object2)

    # split them
    cmd.split_states(object, prefix=prefix)

    # rename to output names
    cmd.set_name("%s%04d" % (prefix, 1), object1)
    cmd.set_name("%s%04d" % (prefix, 2), object2)

    # delete other states
    for o in cmd.get_names("objects"):
        if o.startswith(prefix):
            cmd.delete(o)
Ejemplo n.º 35
0
def spl_extract():
    for name in cmd.get_names("all"):
        #if name in ['5zwo', '5gm6', '5lj3', '5mps', '6exn', '5ylz', '5y88', '3jb9', '6icz', '6ff7', '5yzg', '5xjc', '5gan', '6qw6', '3jcr', '6qx9', '6ah0']: # this should be auto
        print(" \ Extracting mode for %s" % name)

        for n in cmd.get_names("all"):
            if '5zwo' in n:
                object_name = n
                print(object_name)

        if '5zwo' in name.lower():
            cmd.extract("PRP8_B5zwo", "chain A and " + object_name)
            cmd.extract("BRR2_B5zwo", "chain D and " + object_name)
            cmd.extract("LEA1_B5zwo", "chain o and " + object_name)
            cmd.extract("Msl1_B5zwo", "chain p and " + object_name)
            cmd.extract("SNU114_B5zwo", "chain C and " + object_name)
            cmd.extract("U2_B5zwo", "chain H and " + object_name)
            cmd.extract("U5_B5zwo", "chain B and " + object_name)
            cmd.extract("U6_B5zwo", "chain F and " + object_name)
            cmd.extract("U4_B5zwo", "chain I and " + object_name)
            cmd.extract("Intron_B5zwo", "chain G and " + object_name)
            cmd.extract("PRP4_B5zwo", "chain K and " + object_name)
            cmd.extract("PRP31_B5zwo", "chain L and " + object_name)
            cmd.extract("PRP6_B5zwo", "chain N and " + object_name)
            cmd.extract("PRP3_B5zwo", "chain J and " + object_name)
            cmd.extract("DIB1_B5zwo", "chain E and " + object_name)
            cmd.extract("SNU13_B5zwo", "chain M and " + object_name)
            cmd.extract("LSM8_B5zwo", "chain z and " + object_name)
            cmd.extract("LSM2_B5zwo", "chain q and " + object_name)
            cmd.extract("LSM3_B5zwo", "chain r and " + object_name)
            cmd.extract("LSM6_B5zwo", "chain x and " + object_name)
            cmd.extract("LSM5_B5zwo", "chain t and " + object_name)
            cmd.extract("LSM7_B5zwo", "chain y and " + object_name)
            cmd.extract("LSM4_B5zwo", "chain s and " + object_name)
            cmd.extract("SNU66_B5zwo", "chain O and " + object_name)
            cmd.extract("BUD13_B5zwo", "chain Y and " + object_name)
            cmd.extract("Cus1_B5zwo", "chain 2 and " + object_name)
            cmd.extract("HSH155_B5zwo", "chain 1 and " + object_name)
            cmd.extract("HSH49_B5zwo", "chain 4 and " + object_name)
            cmd.extract("PML1_B5zwo", "chain Z and " + object_name)
            cmd.extract("PRP11_B5zwo", "chain v and " + object_name)
            cmd.extract("RDS3_B5zwo", "chain 5 and " + object_name)
            cmd.extract("RSE1_B5zwo", "chain 3 and " + object_name)
            cmd.extract("SNU17_B5zwo", "chain X and " + object_name)
            cmd.extract("Ysf3_B5zwo", "chain 6 and " + object_name)
            cmd.extract("SMB1_1_B5zwo", "chain a and " + object_name)
            cmd.extract("SMB1_2_B5zwo", "chain P and " + object_name)
            cmd.extract("SMB1_3_B5zwo", "chain h and " + object_name)
            cmd.extract("SME1_1_B5zwo", "chain e and " + object_name)
            cmd.extract("SME1_2_B5zwo", "chain T and " + object_name)
            cmd.extract("SME1_3_B5zwo", "chain i and " + object_name)
            cmd.extract("SMX3_1_B5zwo", "chain f and " + object_name)
            cmd.extract("SMX3_2_B5zwo", "chain U and " + object_name)
            cmd.extract("SMX3_3_B5zwo", "chain j and " + object_name)
            cmd.extract("SMX2_1_B5zwo", "chain g and " + object_name)
            cmd.extract("SMX2_2_B5zwo", "chain V and " + object_name)
            cmd.extract("SMX2_3_B5zwo", "chain k and " + object_name)
            cmd.extract("SMD3_1_B5zwo", "chain d and " + object_name)
            cmd.extract("SMD3_2_B5zwo", "chain S and " + object_name)
            cmd.extract("SMD3_3_B5zwo", "chain l and " + object_name)
            cmd.extract("SMD1_1_B5zwo", "chain b and " + object_name)
            cmd.extract("SMD1_2_B5zwo", "chain Q and " + object_name)
            cmd.extract("SMD1_3_B5zwo", "chain m and " + object_name)
            cmd.extract("SMD2_1_B5zwo", "chain c and " + object_name)
            cmd.extract("SMD2_2_B5zwo", "chain R and " + object_name)
            cmd.extract("SMD2_3_B5zwo", "chain n and " + object_name)
            cmd.extract("PRP9_B5zwo", "chain u and " + object_name)
            cmd.extract("PRP21_B5zwo", "chain w and " + object_name)
            cmd.extract("SNU23_B5zwo", "chain W and " + object_name)
            cmd.extract("PRP38_B5zwo", "chain 0 and " + object_name)
            cmd.extract("SPP381_B5zwo", "chain 9 and " + object_name)
            cmd.set_name(object_name, "unknown_other_B5zwo")
            cmd.group("B5zwo", "*_B5zwo")
            cmd.do("order *, yes")

        for n in cmd.get_names("all"):
            if '5gm6' in n:
                object_name = n
                print(object_name)

        if '5gm6' in name.lower():
            cmd.extract("PRP8_Ba5gm6", "chain A and " + object_name)
            cmd.extract("BRR2_Ba5gm6", "chain B and " + object_name)
            cmd.extract("BUD31_Ba5gm6", "chain T and " + object_name)
            cmd.extract("CEF1_Ba5gm6", "chain c and " + object_name)
            cmd.extract("CWC15_Ba5gm6", "chain S and " + object_name)
            cmd.extract("CWC2_hRBM22_Ba5gm6", "chain R and " + object_name)
            cmd.extract("CWC21_Ba5gm6", "chain X and " + object_name)
            cmd.extract("CWC22_Ba5gm6", "chain Z and " + object_name)
            cmd.extract("PRP45_Ba5gm6", "chain P and " + object_name)
            cmd.extract("CDC40_Ba5gm6", "chain n and " + object_name)
            cmd.extract("PRP19_Ba5gm6", "chain f and " + object_name)
            cmd.extract("PRP46_Ba5gm6", "chain O and " + object_name)
            cmd.extract("SLT11/ECM2_Ba5gm6", "chain Q and " + object_name)
            cmd.extract("SNT309_Ba5gm6", "chain t and " + object_name)
            cmd.extract("SNU114_Ba5gm6", "chain C and " + object_name)
            cmd.extract("SYF2_Ba5gm6", "chain f and " + object_name)
            cmd.extract("SYF1_Ba5gm6", "chain v and " + object_name)
            cmd.extract("U2_Ba5gm6", "chain 2 and " + object_name)
            cmd.extract("U5_Ba5gm6", "chain 5 and " + object_name)
            cmd.extract("U6_Ba5gm6", "chain 6 and " + object_name)
            cmd.extract("Intron_Ba5gm6", "chain M and " + object_name)
            cmd.extract("Exon_Ba5gm6", "chain N and " + object_name)
            cmd.extract("BUD13_Ba5gm6", "chain W and " + object_name)
            cmd.extract("CLF2_Ba5gm6", "chain d and " + object_name)
            cmd.extract("Cus1_Ba5gm6", "chain H and " + object_name)
            cmd.extract("CWC24_Ba5gm6", "chain a and " + object_name)
            cmd.extract("CWC27_Ba5gm6", "chain b and " + object_name)
            cmd.extract("HSH155_Ba5gm6", "chain G and " + object_name)
            cmd.extract("HSH49_Ba5gm6", "chain e and " + object_name)
            cmd.extract("PML1_Ba5gm6", "chain U and " + object_name)
            cmd.extract("PRP11_Ba5gm6", "chain I and " + object_name)
            cmd.extract("PRP2_Ba5gm6", "chain Y and " + object_name)
            cmd.extract("RDS3_Ba5gm6", "chain J and " + object_name)
            cmd.extract("RSE1_Ba5gm6", "chain F and " + object_name)
            cmd.extract("SNU17_Ba5gm6", "chain V and " + object_name)
            cmd.extract("Ysf3_Ba5gm6", "chain K and " + object_name)
            cmd.set_name(object_name, "unknown_other_Ba5gm6")
            cmd.group("Ba5gm6", "*_Ba5gm6")
            cmd.do("order *, yes")

        for n in cmd.get_names("all"):
            if '5lj3' in n:
                object_name = n
                print(object_name)

        if '5lj3' in name.lower():
            cmd.extract("PRP8_C5lj3", "chain A and " + object_name)
            cmd.extract("BUD31_C5lj3", "chain L and " + object_name)
            cmd.extract("CEF1_C5lj3", "chain O and " + object_name)
            cmd.extract("CLF1_C5lj3", "chain S and " + object_name)
            cmd.extract("CWC15_C5lj3", "chain P and " + object_name)
            cmd.extract("CWC16/YJU2_C5lj3", "chain D and " + object_name)
            cmd.extract("CWC2_hRBM22_C5lj3", "chain M and " + object_name)
            cmd.extract("CWC21_C5lj3", "chain R and " + object_name)
            cmd.extract("CWC22_C5lj3", "chain H and " + object_name)
            cmd.extract("CWC25_C5lj3", "chain F and " + object_name)
            cmd.extract("ISY1_C5lj3", "chain G and " + object_name)
            cmd.extract("LEA1_C5lj3", "chain W and " + object_name)
            cmd.extract("Msl1_C5lj3", "chain Y and " + object_name)
            cmd.extract("PRP45_C5lj3", "chain K and " + object_name)
            cmd.extract("PRP46_C5lj3", "chain J and " + object_name)
            cmd.extract("SLT11/ECM2_C5lj3", "chain N and " + object_name)
            cmd.extract("SNU114_C5lj3", "chain C and " + object_name)
            cmd.extract("SYF1_C5lj3", "chain T and " + object_name)
            cmd.extract("U2_C5lj3", "chain Z and " + object_name)
            cmd.extract("U5_C5lj3", "chain U and " + object_name)
            cmd.extract("U6_C5lj3", "chain V and " + object_name)
            cmd.extract("Intron_C5lj3", "chain I and " + object_name)
            cmd.extract("Exon_C5lj3", "chain E and " + object_name)
            cmd.extract("SMB1_1_C5lj3", "chain b and " + object_name)
            cmd.extract("SMB1_2_C5lj3", "chain k and " + object_name)
            cmd.extract("SME1_1_C5lj3", "chain e and " + object_name)
            cmd.extract("SME1_2_C5lj3", "chain p and " + object_name)
            cmd.extract("SMX3_1_C5lj3", "chain f and " + object_name)
            cmd.extract("SMX3_2_C5lj3", "chain q and " + object_name)
            cmd.extract("SMX2_1_C5lj3", "chain g and " + object_name)
            cmd.extract("SMX2_2_C5lj3", "chain r and " + object_name)
            cmd.extract("SMD3_1_C5lj3", "chain d and " + object_name)
            cmd.extract("SMD3_2_C5lj3", "chain n and " + object_name)
            cmd.extract("SMD1_1_C5lj3", "chain h and " + object_name)
            cmd.extract("SMD1_2_C5lj3", "chain l and " + object_name)
            cmd.extract("SMD2_1_C5lj3", "chain j and " + object_name)
            cmd.extract("SMD2_2_C5lj3", "chain m and " + object_name)
            cmd.set_name(object_name, "unknown_other_C5lj3")
            cmd.group("C5lj3", "*_C5lj3")
            cmd.do("order *, yes")

        for n in cmd.get_names("all"):
            if '5mps' in n:
                object_name = n
                print(object_name)

        if '5mps' in name.lower():
            cmd.extract("PRP8_Cs5mps", "chain A and " + object_name)
            cmd.extract("BUD31_Cs5mps", "chain L and " + object_name)
            cmd.extract("CEF1_Cs5mps", "chain O and " + object_name)
            cmd.extract("CLF1_Cs5mps", "chain S and " + object_name)
            cmd.extract("CWC15_Cs5mps", "chain P and " + object_name)
            cmd.extract("CWC2_hRBM22_Cs5mps", "chain M and " + object_name)
            cmd.extract("CWC21_Cs5mps", "chain R and " + object_name)
            cmd.extract("CWC22_Cs5mps", "chain H and " + object_name)
            cmd.extract("PRP45_Cs5mps", "chain K and " + object_name)
            cmd.extract("CDC40_Cs5mps", "chain o and " + object_name)
            cmd.extract("PRP46_Cs5mps", "chain J and " + object_name)
            cmd.extract("SLT11/ECM2_Cs5mps", "chain N and " + object_name)
            cmd.extract("SNU114_Cs5mps", "chain C and " + object_name)
            cmd.extract("SYF2_Cs5mps", "chain y and " + object_name)
            cmd.extract("SYF1_Cs5mps", "chain T and " + object_name)
            cmd.extract("U2_Cs5mps", "chain 2 and " + object_name)
            cmd.extract("U5_Cs5mps", "chain 5 and " + object_name)
            cmd.extract("U6_Cs5mps", "chain 6 and " + object_name)
            cmd.extract("5EXON_Cs5mps", "chain E and " + object_name)
            cmd.extract("Intron_Cs5mps", "chain I and " + object_name)
            cmd.extract("Exon_Cs5mps", "chain E and " + object_name)
            cmd.extract("SMB1_Cs5mps", "chain b and " + object_name)
            cmd.extract("SME1_Cs5mps", "chain e and " + object_name)
            cmd.extract("SMX3_Cs5mps", "chain f and " + object_name)
            cmd.extract("SMX2_Cs5mps", "chain g and " + object_name)
            cmd.extract("SMD3_Cs5mps", "chain d and " + object_name)
            cmd.extract("SMD1_Cs5mps", "chain h and " + object_name)
            cmd.extract("SMD2_Cs5mps", "chain j and " + object_name)
            cmd.extract("PRP18_Cs5mps", "chain a and " + object_name)
            cmd.extract("SLU7_Cs5mps", "chain c and " + object_name)
            cmd.set_name(object_name, "unknown_other_Cs5mps")
            cmd.group("Cs5mps", "*_Cs5mps")
            cmd.do("order *, yes")

        for n in cmd.get_names("all"):
            if '6exn' in n:
                object_name = n
                print(object_name)

        if '6exn' in name.lower():
            cmd.extract("PRP8_P6exn", "chain A and " + object_name)
            cmd.extract("BUD31_P6exn", "chain L and " + object_name)
            cmd.extract("CEF1_P6exn", "chain O and " + object_name)
            cmd.extract("CLF1_P6exn", "chain S and " + object_name)
            cmd.extract("CWC15_P6exn", "chain P and " + object_name)
            cmd.extract("CWC16/YJU2_P6exn", "chain D and " + object_name)
            cmd.extract("CWC2_hRBM22_P6exn", "chain M and " + object_name)
            cmd.extract("CWC21_P6exn", "chain R and " + object_name)
            cmd.extract("CWC22_P6exn", "chain H and " + object_name)
            cmd.extract("LEA1_P6exn", "chain W and " + object_name)
            cmd.extract("Msl1_P6exn", "chain Y and " + object_name)
            cmd.extract("PRP45_P6exn", "chain K and " + object_name)
            cmd.extract("CDC40_P6exn", "chain o and " + object_name)
            cmd.extract("PRP19_1_P6exn", "chain t and " + object_name)
            cmd.extract("PRP19_2_P6exn", "chain u and " + object_name)
            cmd.extract("PRP19_3_P6exn", "chain v and " + object_name)
            cmd.extract("PRP19_4_P6exn", "chain w and " + object_name)
            cmd.extract("PRP46_P6exn", "chain J and " + object_name)
            cmd.extract("SLT11/ECM2_P6exn", "chain N and " + object_name)
            cmd.extract("SNU114_P6exn", "chain C and " + object_name)
            cmd.extract("SYF1_P6exn", "chain T and " + object_name)
            cmd.extract("U2_P6exn", "chain 2 and " + object_name)
            cmd.extract("U5_P6exn", "chain 5 and " + object_name)
            cmd.extract("U6_P6exn", "chain 6 and " + object_name)
            cmd.extract("Intron_P6exn", "chain I and " + object_name)
            cmd.extract("Exon_P6exn", "chain E and " + object_name)
            cmd.extract("SMB1_1_P6exn", "chain b and " + object_name)
            cmd.extract("SMB1_2_P6exn", "chain k and " + object_name)
            cmd.extract("SME1_1_P6exn", "chain e and " + object_name)
            cmd.extract("SME1_2_P6exn", "chain p and " + object_name)
            cmd.extract("SMX3_1_P6exn", "chain f and " + object_name)
            cmd.extract("SMX3_2_P6exn", "chain q and " + object_name)
            cmd.extract("SMX2_1_P6exn", "chain g and " + object_name)
            cmd.extract("SMX2_2_P6exn", "chain r and " + object_name)
            cmd.extract("SMD3_1_P6exn", "chain d and " + object_name)
            cmd.extract("SMD3_2_P6exn", "chain n and " + object_name)
            cmd.extract("SMD1_1_P6exn", "chain h and " + object_name)
            cmd.extract("SMD1_2_P6exn", "chain l and " + object_name)
            cmd.extract("SMD2_1_P6exn", "chain j and " + object_name)
            cmd.extract("SMD2_2_P6exn", "chain m and " + object_name)
            cmd.extract("PRP22_P6exn", "chain V and " + object_name)
            cmd.extract("PRP18_P6exn", "chain a and " + object_name)
            cmd.extract("SLU7_P6exn", "chain c and " + object_name)
            cmd.extract("unassigned_P6exn", "chain X and " + object_name)
            cmd.set_name(object_name, "unknown_other_P6exn")
            cmd.group("P6exn", "*_P6exn")
            cmd.do("order *, yes")

        for n in cmd.get_names("all"):
            if '5ylz' in n:
                object_name = n
                print(object_name)

        if '5ylz' in name.lower():
            cmd.extract("PRP8_P5ylz", "chain A and " + object_name)
            cmd.extract("BUD31_P5ylz", "chain L and " + object_name)
            cmd.extract("CEF1_P5ylz", "chain J and " + object_name)
            cmd.extract("CLF1_P5ylz", "chain I and " + object_name)
            cmd.extract("CWC15_P5ylz", "chain P and " + object_name)
            cmd.extract("CWC2_hRBM22_P5ylz", "chain N and " + object_name)
            cmd.extract("CWC21_P5ylz", "chain R and " + object_name)
            cmd.extract("CWC22_P5ylz", "chain S and " + object_name)
            cmd.extract("LEA1_P5ylz", "chain o and " + object_name)
            cmd.extract("Msl1_P5ylz", "chain p and " + object_name)
            cmd.extract("PRP45_P5ylz", "chain Q and " + object_name)
            cmd.extract("CDC40_P5ylz", "chain T and " + object_name)
            cmd.extract("PRP19_1_P5ylz", "chain q and " + object_name)
            cmd.extract("PRP19_2_P5ylz", "chain r and " + object_name)
            cmd.extract("PRP19_3_P5ylz", "chain s and " + object_name)
            cmd.extract("PRP19_4_P5ylz", "chain t and " + object_name)
            cmd.extract("PRP46_P5ylz", "chain O and " + object_name)
            cmd.extract("SLT11/ECM2_P5ylz", "chain M and " + object_name)
            cmd.extract("SNT309_P5ylz", "chain G and " + object_name)
            cmd.extract("SNU114_P5ylz", "chain C and " + object_name)
            cmd.extract("SYF2_P5ylz", "chain K and " + object_name)
            cmd.extract("SYF1_P5ylz", "chain H and " + object_name)
            cmd.extract("U2_P5ylz", "chain F and " + object_name)
            cmd.extract("U5_P5ylz", "chain B and " + object_name)
            cmd.extract("U6_P5ylz", "chain D and " + object_name)
            cmd.extract("Intron_P5ylz", "chain E and " + object_name)
            cmd.extract("SMB1_1_P5ylz", "chain a and " + object_name)
            cmd.extract("SMB1_2_P5ylz", "chain h and " + object_name)
            cmd.extract("SME1_1_P5ylz", "chain b and " + object_name)
            cmd.extract("SME1_2_P5ylz", "chain i and " + object_name)
            cmd.extract("SMX3_1_P5ylz", "chain c and " + object_name)
            cmd.extract("SMX3_2_P5ylz", "chain j and " + object_name)
            cmd.extract("SMX2_1_P5ylz", "chain d and " + object_name)
            cmd.extract("SMX2_2_P5ylz", "chain k and " + object_name)
            cmd.extract("SMD3_1_P5ylz", "chain e and " + object_name)
            cmd.extract("SMD3_2_P5ylz", "chain l and " + object_name)
            cmd.extract("SMD1_1_P5ylz", "chain f and " + object_name)
            cmd.extract("SMD1_2_P5ylz", "chain m and " + object_name)
            cmd.extract("SMD2_1_P5ylz", "chain g and " + object_name)
            cmd.extract("SMD2_2_P5ylz", "chain n and " + object_name)
            cmd.extract("PRP22_P5ylz", "chain W and " + object_name)
            cmd.extract("PRP18_P5ylz", "chain U and " + object_name)
            cmd.extract("SLU7_P5ylz", "chain V and " + object_name)
            cmd.set_name(object_name, "unknown_other_P5ylz")
            cmd.group("P5ylz", "*_P5ylz")
            cmd.do("order *, yes")

        for n in cmd.get_names("all"):
            if '5y88' in n:
                object_name = n
                print(object_name)

        if '5y88' in name.lower():
            cmd.extract("PRP8_I5y88", "chain A and " + object_name)
            cmd.extract("BUD31_I5y88", "chain L and " + object_name)
            cmd.extract("CLF1_I5y88", "chain I and " + object_name)
            cmd.extract("CWC15_I5y88", "chain P and " + object_name)
            cmd.extract("CWC16/YJU2_I5y88", "chain R and " + object_name)
            cmd.extract("CWC2_hRBM22_I5y88", "chain N and " + object_name)
            cmd.extract("CWC25_I5y88", "chain G and " + object_name)
            cmd.extract("Intron_2_I5y88", "chain E and " + object_name)
            cmd.extract("LEA1_I5y88", "chain o and " + object_name)
            cmd.extract("Msl1_I5y88", "chain p and " + object_name)
            cmd.extract("PRP45_I5y88", "chain Q and " + object_name)
            cmd.extract("CDC40_I5y88", "chain S and " + object_name)
            cmd.extract("PRP19_1_I5y88", "chain q and " + object_name)
            cmd.extract("PRP19_2_I5y88", "chain r and " + object_name)
            cmd.extract("PRP19_3_I5y88", "chain s and " + object_name)
            cmd.extract("PRP19_4_I5y88", "chain t and " + object_name)
            cmd.extract("PRP46_I5y88", "chain O and " + object_name)
            cmd.extract("SLT11/ECM2_I5y88", "chain M and " + object_name)
            cmd.extract("SNT309_I5y88", "chain G and " + object_name)
            cmd.extract("SNU114_I5y88", "chain C and " + object_name)
            cmd.extract("SYF2_I5y88", "chain K and " + object_name)
            cmd.extract("SYF1_I5y88", "chain H and " + object_name)
            cmd.extract("U2_I5y88", "chain F and " + object_name)
            cmd.extract("U5_I5y88", "chain B and " + object_name)
            cmd.extract("U6_I5y88", "chain D and " + object_name)
            cmd.extract("Intron_I5y88", "chain x and " + object_name)
            cmd.extract("RNA_I5y88", "chain x and " + object_name)
            cmd.extract("cwc23_I5y88", "chain T and " + object_name)
            cmd.extract("SPP382_I5y88", "chain U and " + object_name)
            cmd.extract("NTR2_I5y88", "chain V and " + object_name)
            cmd.extract("PRP43_I5y88", "chain W and " + object_name)
            cmd.extract("SMB1_1_I5y88", "chain a and " + object_name)
            cmd.extract("SMB1_2_I5y88", "chain h and " + object_name)
            cmd.extract("SME1_1_I5y88", "chain b and " + object_name)
            cmd.extract("SME1_2_I5y88", "chain i and " + object_name)
            cmd.extract("SMX3_1_I5y88", "chain c and " + object_name)
            cmd.extract("SMX3_2_I5y88", "chain j and " + object_name)
            cmd.extract("SMX2_1_I5y88", "chain d and " + object_name)
            cmd.extract("SMX2_2_I5y88", "chain k and " + object_name)
            cmd.extract("SMD3_1_I5y88", "chain e and " + object_name)
            cmd.extract("SMD3_2_I5y88", "chain l and " + object_name)
            cmd.extract("SMD1_1_I5y88", "chain f and " + object_name)
            cmd.extract("SMD1_2_I5y88", "chain m and " + object_name)
            cmd.extract("SMD2_1_I5y88", "chain g and " + object_name)
            cmd.extract("SMD2_2_I5y88", "chain n and " + object_name)
            cmd.set_name(object_name, "unknown_other_I5y88")
            cmd.group("I5y88", "*_I5y88")
            cmd.do("order *, yes")

        for n in cmd.get_names("all"):
            if '3jb9' in n:
                object_name = n
                print(object_name)

        if '3jb9' in name.lower():
            cmd.extract("U2_3jb9", "chain P and " + object_name)
            cmd.extract("U5_3jb9", "chain C and " + object_name)
            cmd.extract("U6_3jb9", "chain N and " + object_name)
            cmd.extract("Intron_1_3jb9", "chain O and " + object_name)
            cmd.extract("Intron_2_3jb9", "chain Q and " + object_name)
            cmd.extract("Spp42_yPrp8_3jb9", "chain A and " + object_name)
            cmd.extract("CWF15_yCWC15_3jb9", "chain h and " + object_name)
            cmd.set_name(object_name, "unknown_other_3jb9")
            cmd.group("3jb9", "*_3jb9")
            cmd.do("order *, yes")

        for n in cmd.get_names("all"):
            if '6icz' in n:
                object_name = n
                print(object_name)

        if '6icz' in name.lower():
            cmd.extract("CWC15_hP_6icz", "chain P and " + object_name)
            cmd.extract("U2_hP_6icz", "chain H and " + object_name)
            cmd.extract("U5_hP_6icz", "chain B and " + object_name)
            cmd.extract("U6_hP_6icz", "chain F and " + object_name)
            cmd.extract("Intron_hP_6icz", "chain G and " + object_name)
            cmd.extract("cwc23_hP_6icz", "chain 6ICZ and " + object_name)
            cmd.set_name(object_name, "unknown_other_hP_6icz")
            cmd.group("hP_6icz", "*_hP_6icz")
            cmd.do("order *, yes")

        for n in cmd.get_names("all"):
            if '6ff7' in n:
                object_name = n
                print(object_name)

        if '6ff7' in name.lower():
            cmd.extract("CWC15_hBa_6ff7", "chain R and " + object_name)
            cmd.extract("CWC2_hRBM22_hBa_6ff7", "chain P and " + object_name)
            cmd.extract("U2_hBa_6ff7", "chain 2 and " + object_name)
            cmd.extract("U5_hBa_6ff7", "chain 5 and " + object_name)
            cmd.extract("U6_hBa_6ff7", "chain 6 and " + object_name)
            cmd.extract("Intron_hBa_6ff7", "chain Z and " + object_name)
            cmd.set_name(object_name, "unknown_other_hBa_6ff7")
            cmd.group("hBa_6ff7", "*_hBa_6ff7")
            cmd.do("order *, yes")

        for n in cmd.get_names("all"):
            if '5yzg' in n:
                object_name = n
                print(object_name)

        if '5yzg' in name.lower():
            cmd.extract("CWC15_hC_5yzg", "chain P and " + object_name)
            cmd.extract("CWC2_hRBM22_hC_5yzg", "chain O and " + object_name)
            cmd.extract("CWC25_hC_5yzg", "chain X and " + object_name)
            cmd.extract("PRP16_hDHX38_hC_5yzg", "chain Z and " + object_name)
            cmd.extract("U2_hC_5yzg", "chain H and " + object_name)
            cmd.extract("U5_hC_5yzg", "chain B and " + object_name)
            cmd.extract("U6_hC_5yzg", "chain F and " + object_name)
            cmd.extract("Intron_hC_5yzg", "chain G and " + object_name)
            cmd.set_name(object_name, "unknown_other_hC_5yzg")
            cmd.group("hC_5yzg", "*_hC_5yzg")
            cmd.do("order *, yes")

        for n in cmd.get_names("all"):
            if '5xjc' in n:
                object_name = n
                print(object_name)

        if '5xjc' in name.lower():
            cmd.extract("CWC15_hX_5xjc", "chain P and " + object_name)
            cmd.extract("CWC25_hX_5xjc", "chain X and " + object_name)
            cmd.extract("U2_hX_5xjc", "chain H and " + object_name)
            cmd.extract("U5_hX_5xjc", "chain B and " + object_name)
            cmd.extract("U6_hX_5xjc", "chain F and " + object_name)
            cmd.extract("Intron_hX_5xjc", "chain G and " + object_name)
            cmd.extract("PRKRIP1_hX_5xjc", "chain X and " + object_name)
            cmd.set_name(object_name, "unknown_other_hX_5xjc")
            cmd.group("hX_5xjc", "*_hX_5xjc")
            cmd.do("order *, yes")

        for n in cmd.get_names("all"):
            if '5gan' in n:
                object_name = n
                print(object_name)

        if '5gan' in name.lower():
            cmd.extract("PRP8_y3_5gan", "chain A and " + object_name)
            cmd.extract("BRR2_y3_5gan", "chain B and " + object_name)
            cmd.extract("PRP45_y3_5gan", "chain H and " + object_name)
            cmd.extract("SNU114_y3_5gan", "chain C and " + object_name)
            cmd.extract("U5_y3_5gan", "chain U and " + object_name)
            cmd.extract("U6_y3_5gan", "chain W and " + object_name)
            cmd.extract("U4_y3_5gan", "chain V and " + object_name)
            cmd.extract("PRP31_y3_5gan", "chain F and " + object_name)
            cmd.extract("PRP6_y3_5gan", "chain J and " + object_name)
            cmd.extract("PRP3_y3_5gan", "chain G and " + object_name)
            cmd.extract("DIB1_y3_5gan", "chain D and " + object_name)
            cmd.extract("SNU13_y3_5gan", "chain K and " + object_name)
            cmd.extract("LSM8_y3_5gan", "chain 8 and " + object_name)
            cmd.extract("LSM2_y3_5gan", "chain 2 and " + object_name)
            cmd.extract("LSM3_y3_5gan", "chain 3 and " + object_name)
            cmd.extract("LSM6_y3_5gan", "chain 6 and " + object_name)
            cmd.extract("LSM5_y3_5gan", "chain 5 and " + object_name)
            cmd.extract("LSM7_y3_5gan", "chain 7 and " + object_name)
            cmd.extract("LSM4_y3_5gan", "chain 4 and " + object_name)
            cmd.extract("SNU66_y3_5gan", "chain E and " + object_name)
            cmd.extract("SMB1_1_y3_5gan", "chain b and " + object_name)
            cmd.extract("SMB1_2_y3_5gan", "chain k and " + object_name)
            cmd.extract("SME1_1_y3_5gan", "chain e and " + object_name)
            cmd.extract("SME1_2_y3_5gan", "chain p and " + object_name)
            cmd.extract("SMX3_1_y3_5gan", "chain f and " + object_name)
            cmd.extract("SMX3_2_y3_5gan", "chain q and " + object_name)
            cmd.extract("SMX2_1_y3_5gan", "chain g and " + object_name)
            cmd.extract("SMX2_2_y3_5gan", "chain r and " + object_name)
            cmd.extract("SMD3_1_y3_5gan", "chain d and " + object_name)
            cmd.extract("SMD3_2_y3_5gan", "chain n and " + object_name)
            cmd.extract("SMD1_1_y3_5gan", "chain h and " + object_name)
            cmd.extract("SMD1_2_y3_5gan", "chain l and " + object_name)
            cmd.extract("SMD2_1_y3_5gan", "chain j and " + object_name)
            cmd.extract("SMD2_2_y3_5gan", "chain m and " + object_name)
            cmd.extract("unassigned_y3_5gan", "chain X and " + object_name)
            cmd.set_name(object_name, "unknown_other_y3_5gan")
            cmd.group("y3_5gan", "*_y3_5gan")
            cmd.do("order *, yes")

        for n in cmd.get_names("all"):
            if '6qw6' in n:
                object_name = n
                print(object_name)

        if '6qw6' in name.lower():
            cmd.extract("PRP8_h3_6qw6", "chain 5A and " + object_name)
            cmd.extract("U5_h3_6qw6", "chain 5 and " + object_name)
            cmd.extract("U6_h3_6qw6", "chain 6 and " + object_name)
            cmd.extract("U4_h3_6qw6", "chain 4 and " + object_name)
            cmd.extract("Prp28_h3_6qw6", "chain 5X and " + object_name)
            cmd.set_name(object_name, "unknown_other_h3_6qw6")
            cmd.group("h3_6qw6", "*_h3_6qw6")
            cmd.do("order *, yes")

        for n in cmd.get_names("all"):
            if '3jcr' in n:
                object_name = n
                print(object_name)

        if '3jcr' in name.lower():
            cmd.extract("PRP8_h3_3jcr", "chain A and " + object_name)
            cmd.extract("BRR2_h3_3jcr", "chain C and " + object_name)
            cmd.extract("SNU114_h3_3jcr", "chain B and " + object_name)
            cmd.extract("U5_h3_3jcr", "chain H and " + object_name)
            cmd.extract("U6_h3_3jcr", "chain N and " + object_name)
            cmd.extract("U4_h3_3jcr", "chain M and " + object_name)
            cmd.extract("PRP4_h3_3jcr", "chain L and " + object_name)
            cmd.extract("PRP31_h3_3jcr", "chain J and " + object_name)
            cmd.extract("PRP6_h3_3jcr", "chain G and " + object_name)
            cmd.extract("PRP3_h3_3jcr", "chain K and " + object_name)
            cmd.extract("SNU13_h3_3jcr", "chain I and " + object_name)
            cmd.extract("LSM8_h3_3jcr", "chain 8 and " + object_name)
            cmd.extract("LSM2_h3_3jcr", "chain 2 and " + object_name)
            cmd.extract("LSM3_h3_3jcr", "chain 3 and " + object_name)
            cmd.extract("LSM5_h3_3jcr", "chain 5 and " + object_name)
            cmd.extract("LSM7_h3_3jcr", "chain 7 and " + object_name)
            cmd.extract("LSM4_h3_3jcr", "chain 4 and " + object_name)
            cmd.extract("SMD3_1_h3_3jcr", "chain R and " + object_name)
            cmd.extract("SMD3_2_h3_3jcr", "chain r and " + object_name)
            cmd.extract("SMD1_1_h3_3jcr", "chain P and " + object_name)
            cmd.extract("SMD1_2_h3_3jcr", "chain p and " + object_name)
            cmd.extract("SMD2_1_h3_3jcr", "chain Q and " + object_name)
            cmd.extract("SMD2_2_h3_3jcr", "chain q and " + object_name)
            cmd.extract("U5-40K_h3_3jcr", "chain D and " + object_name)
            cmd.extract("Dim1_h3_3jcr", "chain E and " + object_name)
            cmd.extract("Prp28_h3_3jcr", "chain F and " + object_name)
            cmd.extract("SmE_1_h3_3jcr", "chain S and " + object_name)
            cmd.extract("SmE_2_h3_3jcr", "chain s and " + object_name)
            cmd.extract("SmF_1_h3_3jcr", "chain T and " + object_name)
            cmd.extract("SmF_2_h3_3jcr", "chain t and " + object_name)
            cmd.extract("SmG_1_h3_3jcr", "chain U and " + object_name)
            cmd.extract("SmG_2_h3_3jcr", "chain u and " + object_name)
            cmd.extract("Sad1_h3_3jcr", "chain V and " + object_name)
            cmd.extract("SmB_1_h3_3jcr", "chain O and " + object_name)
            cmd.extract("SmB_2_h3_3jcr", "chain o and " + object_name)
            cmd.set_name(object_name, "unknown_other_h3_3jcr")
            cmd.group("h3_3jcr", "*_h3_3jcr")
            cmd.do("order *, yes")

        for n in cmd.get_names("all"):
            if '6qx9' in n:
                object_name = n
                print(object_name)

        if '6qx9' in name.lower():
            cmd.extract("PRP8_h3_6qx9", "chain 5A and " + object_name)
            cmd.extract("U2_h3_6qx9", "chain 2 and " + object_name)
            cmd.extract("U5_h3_6qx9", "chain 5 and " + object_name)
            cmd.extract("U6_h3_6qx9", "chain 6 and " + object_name)
            cmd.extract("U4_h3_6qx9", "chain 4 and " + object_name)
            cmd.extract("Intron_h3_6qx9", "chain I and " + object_name)
            cmd.extract("U1_h3_6qx9", "chain 1 and " + object_name)
            cmd.extract("Prp28_h3_6qx9", "chain 5X and " + object_name)
            cmd.set_name(object_name, "unknown_other_h3_6qx9")
            cmd.group("h3_6qx9", "*_h3_6qx9")
            cmd.do("order *, yes")

        for n in cmd.get_names("all"):
            if '6ah0' in n:
                object_name = n
                print(object_name)

        if '6ah0' in name.lower():
            cmd.extract("PRP8_h_Bp_6ah0", "chain A and " + object_name)
            cmd.extract("U2_h_Bp_6ah0", "chain H and " + object_name)
            cmd.extract("U5_h_Bp_6ah0", "chain B and " + object_name)
            cmd.extract("U6_h_Bp_6ah0", "chain F and " + object_name)
            cmd.extract("U4_h_Bp_6ah0", "chain I and " + object_name)
            cmd.extract("Intron_h_Bp_6ah0", "chain G and " + object_name)
            cmd.extract("Prp28_h_Bp_6ah0", "chain X and " + object_name)
            cmd.set_name(object_name, "unknown_other_h_Bp_6ah0")
            cmd.group("h_Bp_6ah0", "*_h_Bp_6ah0")
            cmd.do("order *, yes")
Ejemplo n.º 36
0
    def _add_vis(self, mymol, row, l_cgo):
        if (self.is_only_water_access and (not "WAT" in [row.rnm1, row.rnm2])):
            return None

        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 %s and not h." %
                (mymol, row.seg1, row.res1, self.bb2selstr[row.bb1]))
            cmd.select(
                "sel2", "/%s/%s and i. %d and %s and not h." %
                (mymol, row.seg2, row.res2, self.bb2selstr[row.bb2]))
        else:
            if "bb" in self.df_rgn_seg_res_bb:
                df_unique_rgnsegbb = self.df_rgn_seg_res_bb[[
                    "seg", "bb"
                ]].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' and bb == %d" %
                            (myrgn, srow.seg, srow.bb))
                        if df_sel.shape[0] > 0:
                            selstr += "(c. %s and i. %s and %s) or" % (
                                srow.seg, "+".join(
                                    [str(x)
                                     for x in df_sel.res.values[0]]), srow.bb)
                    selstr = selstr[:-3] + ")"
                    cmd.select("%s" % myrgn, selstr)
            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'" %
                            (row.rgn1, 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 count1 == 0:
            if count2 == 0:
                raise ValueError(
                    "counts of both %s.%d.%s.%d and %s.%d.%s.%d are zero!" %
                    (row.seg1, row.res1, row.rnm1, row.bb1, row.seg2, row.res2,
                     row.rnm2, row.bb2))
            else:
                if self.df_rgn_seg_res_bb is None:
                    cmd.show("sticks", "sel2")
                    #cmd.color(self.sgn2col[mycolind], "sel2")
                else:
                    com("sel2", state=1)
                    coord2 = cmd.get_model("sel2_COM", state=1).atom[0].coord
                    cmd.delete("sel2_COM")
                    cmd.color(self.sgn2col[mycolind], "sel2")
                    l_cgo += [ \
                        COLOR, self.l_r[mycolind], self.l_g[mycolind], self.l_b[mycolind], \
                        SPHERE,   coord2[0], coord2[1],coord2[2], self.sphererad \
                    ]
        elif count2 == 0:
            if self.df_rgn_seg_res_bb is None:
                cmd.show("sticks", "sel1")
                #cmd.color(self.sgn2col[mycolind], "sel1")
            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")
                l_cgo += [ \
                    COLOR, self.l_r[mycolind], self.l_g[mycolind], self.l_b[mycolind], \
                    SPHERE,   coord1[0], coord1[1],coord1[2], self.sphererad \
                ]
        else:
            com("sel1", state=1)
            coord1 = cmd.get_model("sel1_COM", state=1).atom[0].coord
            cmd.delete("sel1_COM")
            com("sel2", state=1)
            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 \
            ]
            if self.df_rgn_seg_res_bb is None:
                cmd.show("sticks", "sel1")
                cmd.show("sticks", "sel2")
                util.cbag("sel1")
                util.cbag("sel2")
            else:
                cmd.color(self.sgn2col[mycolind], "sel1")
                cmd.color(self.sgn2col[mycolind], "sel2")
        cmd.delete("sel1")
        cmd.delete("sel2")
Ejemplo n.º 37
0
def cyspka(molecule, chain, residue, SeeProgress='yes', pH=7.2, MoveSGatom='no', SGatom=str((0, 0, 0))):
    # If SeeProgress='yes', computation time will take 10-20% extra, but nice to follow.
    cmd.refresh()
    RotationRange = 360
    RotationDegree = 1
    # For error checking, the energies can be printed out
    printMC = 'no'
    printSC = 'no'
    # Parameters
    DieElecSpheDist = 7.0
    DieElecWaterDist = 1.4
    DieElecWater = 78.5
    DieElecCore = 4.0
    BornPenaltyB = 1.0
    AvogadroR = 8.31446216
    Temp = 298
    DeltapKMCSC = 0
    pK1 = 9.25
    pK2 = 8.0
    NotPopuDist = 2.4
    PopEnergyPenalty = 10000000
    # Side chain discrete charges
    DieElecSC = 40.0
    SCchargeASP = -1
    SCchargeGLU = -1
    SCchargeOXT = -1
    SCchargeARG = +1
    SCchargeHIS = +1
    SCchargeLYS = +1
    SCchargeMET1 = +1
    # Main chain partial charges
    NrMainchainNeighBours = 5
    DieElecMC = 22.0
    MCchargeC = +0.55
    MCchargeO = -0.55
    MCchargeN = -0.35
    MCchargeH = +0.35
    MCchargeProCA = +0.1
    MCchargeProCD = +0.1
    MCchargeProN = -0.2

    # Loading an Cys residue, give it a logic name, and aligning it. The oxygen atom can not be aligned in many cases, and are skipped.
    # We use only this molecule, to find the initial position of the SG atom, and to rotate the SG atom around the CA-CB bond. The molecule atom positions are not used for electric potential calculatons.
    Cysmolecule = str(molecule) + str(residue) + "Cys"
    cmd.fragment("cys")
    cmd.set_name('cys', Cysmolecule)
    # We use pair_fir, since align and super gets unstable with so few atoms
    pairfitCys(Cysmolecule, molecule, chain, residue)
    # Give nice representations quickly
    cmd.show("sticks", Cysmolecule)
    cmd.select(str(molecule) + str(residue) + "Res", "/" + molecule + "//" + chain + "/" + residue)
    print("/" + molecule + "//" + chain + "/" + residue)
    cmd.show("sticks", str(molecule) + str(residue) + "Res")
    cmd.disable(str(molecule) + str(residue) + "Res")
    # Find out what is the residuename we are investigating for
    Respdbstr = cmd.get_pdbstr(str(molecule) + str(residue) + "Res")
    Ressplit = Respdbstr.split()
    residueName = Ressplit[3]

    print("")
    print("# Hello, PyMOLers. It should take around 1 minute per residue.")
    print("# molecule: %s , chain: %s, residue: %s %s, pH: %s " % (molecule, chain, residueName, residue, pH))

    # Determine the range of neighbour residues possible.
    Maxresidues = cmd.count_atoms("/" + molecule + "//" + chain + " and name CA")
    for i in range(NrMainchainNeighBours + 1):
        if int(residue) - i >= 1:
            Minresidue = int(residue) - i
        else:
            break
    for i in range(NrMainchainNeighBours + 1):
        if int(residue) + i <= Maxresidues:
            Maxresidue = int(residue) + i
        else:
            break

    # Get the position and the vector for the CA->CB bond.
    dihedN = "/" + Cysmolecule + "//" + "/" + "/N"
    dihedCA = "/" + Cysmolecule + "//" + "/" + "/CA"
    dihedCB = "/" + Cysmolecule + "//" + "/" + "/CB"
    dihedSG = "/" + Cysmolecule + "//" + "/" + "/SG"
    dihedralPosCA = cmd.get_atom_coords(dihedCA)
    dihedralPosSG = cmd.get_atom_coords(dihedSG)
    dihedralVector = AtomVector(dihedCA, dihedCB)

    # To compare with article, we can move the SGatom to a starting position. The rotation is still determined around the CA-CB bond.
    if MoveSGatom == 'yes':
        SGatom = [float(SGatom[1:-1].split(",")[0]), float(SGatom[1:-1].split(",")[1]), float(SGatom[1:-1].split(",")[2])]
        Translate = [(SGatom[0] - dihedralPosSG[0]), (SGatom[1] - dihedralPosSG[1]), (SGatom[2] - dihedralPosSG[2])]
        cmd.translate(Translate, dihedSG, state=0, camera=0)
        dihedralPosSG = cmd.get_atom_coords(dihedSG)
    # Create a pymol molecule, that in the end will hold and show all SG atoms. Gives the representation of the rotameric states.
    SGName = str(molecule) + str(residue) + "SG"
    cmd.create(SGName, "None")
    # Create a pymol molecule, that in the end will hold and show all Amide protons. Gives a nice representation, and easy to delete.
    AmideName = str(molecule) + str(residue) + "NH"
    cmd.create(AmideName, "None")
    # Check if there are any nearby SG atoms, which could make a SG-SG dimer formation. The
    breakDimer = "no"
    breakDimer = CheckDimer(dihedSG, molecule, chain, residue)
    # Create a list for appending the calculated energies.
    ListofEnergies = []
    ListofRotamerDiscarded = []
    # print "Angle before rotation", cmd.get_dihedral(dihedN,dihedCA,dihedCB,dihedSG)
    # Enter into the loop of rotameric states
    for i in range(int(math.floor(RotationRange / RotationDegree))):
        Angle = i * RotationDegree
        # Create pymol molecule/SG atom for which we will calculate for.
        SGNameAngle = str(residue) + "SG" + str(Angle)
        cmd.create(SGNameAngle, dihedSG)
        # Calculate new coordinates for rotation around CA->CB bond. Then translate the created SG atom.
        SGNewPos = fRotateAroundLine(dihedralPosSG, dihedralPosCA, dihedralVector, Angle)
        Translate = [(SGNewPos[0] - dihedralPosSG[0]), (SGNewPos[1] - dihedralPosSG[1]), (SGNewPos[2] - dihedralPosSG[2])]
        cmd.translate(Translate, SGNameAngle, state=0, camera=0)
        # If one wants to "see it happen" while its making the states. But it will take extra computation time.
        if SeeProgress == 'yes':
            cmd.refresh()
        # Calculate number of neighbours within 2.4 Angstrom. Amide hydrogens are not considered, and are actually not build yet.
        nameselect = "(((/" + molecule + "//" + chain + " and not /" + molecule + "//" + chain + "/" + residue + ") or /" + molecule + "//" + chain + "/" + residue + "/N+CA+C+O)  within " + str(NotPopuDist) + " of /" + SGNameAngle + "//" + "/" + "/SG) and not resn HOH"
        # print nameselect
        cmd.select("NotPop", nameselect)
        NotPopNr = cmd.count_atoms("NotPop")
        # print Angle, NotPopNr, cmd.get_dihedral(dihedN,dihedCA,dihedCB,SGNameAngle)
        # If no neighbours, then proceed calculating
        if NotPopNr == 0:
            SumAllWMC = 0.0
            # Now calculate the electric potential due to the side chains.
            SumWSC = fSumWSC(molecule, SGNameAngle, chain, residue, DieElecSC, SCchargeASP, SCchargeGLU, SCchargeOXT, SCchargeARG, SCchargeHIS, SCchargeLYS, SCchargeMET1, printSC)
            # Now we calculate for the flanking 5 peptide groups on each side of the Cysteine CA atom.
            # For the first residue, only calculate for the tailing C,O atom in the peptide bond. No test for Proline.
            SumWMCFirst = fSumWMCFirst(molecule, SGNameAngle, chain, residue, Minresidue, DieElecMC, MCchargeC, MCchargeO, printMC)
            # For the residue itself, we dont test for PRO, since it should be a Cysteine.
            SumWMCresidue = fSumWMCresidue(molecule, SGNameAngle, chain, residue, int(residue), DieElecMC, MCchargeC, MCchargeO, MCchargeN, MCchargeH, AmideName, printMC)
            # For the last residue, we test for Proline. We only calculate for the N,H atom, or if Proline, N,CA and CD atom.
            SumWMCLast = fSumWMCLast(molecule, SGNameAngle, chain, residue, Maxresidue, DieElecMC, MCchargeN, MCchargeH, MCchargeProCA, MCchargeProCD, MCchargeProN, AmideName, printMC)
            # Then loop over rest of the residues in the chain.
            for j in (list(range(Minresidue + 1, int(residue))) + list(range(int(residue) + 1, Maxresidue))):
                MCNeighbour = j
                # print "Looking at neighbour", j
                SumWMC = fSumWMC(molecule, SGNameAngle, chain, residue, MCNeighbour, DieElecMC, MCchargeC, MCchargeO, MCchargeN, MCchargeH, MCchargeProCA, MCchargeProCD, MCchargeProN, AmideName, printMC)
                SumAllWMC = SumAllWMC + SumWMC
                # print "Rotation: %s Neighbour: %s " % (Angle, j)
            # Since the SG atom is negative, we multiply with -1.
            SumMCSC = -1 * (SumWSC + SumWMCFirst + SumWMCresidue + SumWMCLast + SumAllWMC)
            # Makes the neighbour count. Everything in 'molecule" within 7 ang of aligned SG atom. Not counting 'residue'. Adding 5 for 'residue' N,CA,C,O,CB
            ListNeighbourCount = fNeighbourCount(molecule, SGNameAngle, chain, residue, DieElecSpheDist)
            # Calculate the weighted electric potential and alter the b factor for coloring. Then add the rotated SG into bucket of SG atoms.
            SG_MCSC_Weight = fBoltzSingleState(SumMCSC, AvogadroR, Temp) * SumMCSC
            cmd.alter(SGNameAngle, 'b="%s"' % SG_MCSC_Weight)
            cmd.alter(SGNameAngle, 'name="S%s"' % Angle)
            cmd.create(SGName, SGName + " + " + SGNameAngle)
            # Then save the calculated values
            ListofEnergies.append([Angle, SumMCSC, ListNeighbourCount, NotPopNr, SG_MCSC_Weight, cmd.get_atom_coords(SGNameAngle)])
            cmd.delete(SGNameAngle)
        else:
            SumMCSCPenalty = PopEnergyPenalty
            ListNeighbourCount = fNeighbourCount(molecule, SGNameAngle, chain, residue, DieElecSpheDist)
            ListofRotamerDiscarded.append([Angle, SumMCSCPenalty, ListNeighbourCount, NotPopNr, 0, cmd.get_atom_coords(SGNameAngle)])
            cmd.delete(SGNameAngle)
    # Now show all the SG atoms as the available rotameric states.
    cmd.show("nb_spheres", SGName)
    cmd.delete("NotPop")
    cmd.spectrum("b", selection=SGName)
    AvailRotStates = len(ListofEnergies)
    # print "Available Rotational States: ", AvailRotStates

    # Do the calculations according to eq 5.
    # Find the partition function
    BoltzPartition = 0.0
    for i in range(len(ListofEnergies)):
        Boltz = fBoltzSingleState(ListofEnergies[i][1], AvogadroR, Temp)
        BoltzPartition = BoltzPartition + Boltz
    # Find the summed function
    BoltzSumNi = 0.0
    for i in range(len(ListofEnergies)):
        BoltzNi = fBoltzSingleState(ListofEnergies[i][1], AvogadroR, Temp) * ListofEnergies[i][1]
        BoltzSumNi = BoltzSumNi + BoltzNi

    # Check if there was any possible rotamers

    nostates = "no"
    if len(ListofEnergies) == 0:
        print("####################################################")
        print("########### WARNING: No states available ###########")
        print("########### Did you mutate a Glycine?    ###########")
        print("####################################################")
        BoltzSumNi = 0
        BoltzPartition = 0
        BoltzMCSC = 0
        DeltapKMCSC = 99
        NeighbourCount = 0
        nostates = "yes"
    else:
        # Final calculation
        BoltzMCSC = (BoltzSumNi) / (BoltzPartition)
        DeltapKMCSC = fDeltapK(BoltzMCSC, AvogadroR, Temp)

    # Find average number of neighbours
    NCSum = 0.0
    NCWeightedSum = 0.0
    for i in range(len(ListofEnergies)):
        NCi = ListofEnergies[i][2]
        NCSum = NCSum + NCi
        NCWeightedi = fBoltzSingleState(ListofEnergies[i][1], AvogadroR, Temp) * ListofEnergies[i][2] / BoltzPartition
        NCWeightedSum = NCWeightedSum + NCWeightedi
    # print "Weighted neighbour", int(round(NCWeightedSum))
    #NeighbourCount = int(round(NCSum/len(ListofEnergies)))
        NeighbourCount = round(NCWeightedSum, 1)
    # If we found dimers
    if breakDimer == "yes":
        print("####################################################")
        print("########### WARNING: Dimer formation?    ###########")
        print("####################################################")
        BoltzSumNi = 0
        BoltzPartition = 0
        BoltzMCSC = 0
        DeltapKMCSC = 99
        NeighbourCount = 0

    # Calculate the BornPenalty based on the neighbour count. It's a wrapper script for equation 13, 12, 11.
    EnergyBornPenalty = fEnergyBornPenalty(DieElecSpheDist, DieElecWaterDist, NeighbourCount, DieElecWater, DieElecCore, BornPenaltyB)
    DeltapKB = fDeltapK(EnergyBornPenalty, AvogadroR, Temp)

    # Do the calculations according to eq 3 and 9.
    pKm1 = fpKm1(DeltapKMCSC, pK1)
    pKm2 = fpKm2(DeltapKMCSC, DeltapKB, pK2)
    FracCysm1 = fFracCys(pKm1, pH)
    FracCysm2 = fFracCys(pKm2, pH)

    # Lets make a result file, and write out the angle, the SumMCSC, and the number of neighbours for this state.
    Currentdir = os.getcwd()
    Newdir = os.path.join(os.getcwd(), "Results")
    if not os.path.exists(Newdir):
        os.makedirs(Newdir)
    filename = os.path.join(".", "Results", "Result_" + molecule + "_" + chain + "_" + residue + ".txt")
    filenamelog = os.path.join(".", "Results", "Result_log.log")
    logfile = open(filenamelog, "a")
    outfile = open(filename, "w")
    timeforlog = strftime("%Y %b %d %a %H:%M:%S", localtime())
    logfile.write("# " + timeforlog + "\n")
    logfile.write("# molecule: %s , chain: %s, residue: %s %s, pH: %s " % (molecule, chain, residueName, residue, pH) + "\n")
    logfile.write("# BoltzSumNi:  BoltzPartition:  BoltzMCSC" + "\n")
    logfile.write(("# %.4f  %.4f  %.4f" + '\n') % (BoltzSumNi, BoltzPartition, BoltzMCSC))
    logfile.write("#    Res  NC    States  pKmcsc  pK1   pKB     pK2  pKm1     pKm2    f(C-)m1   f(C-)m2" + "\n")
    logfile.write(("; %s %s   %s  %s     %.4f  %s  %.4f  %s  %.4f  %.4f  %.6f  %.6f" + '\n') % (residueName, residue, NeighbourCount, AvailRotStates, DeltapKMCSC, pK1, DeltapKB, pK2, pKm1, pKm2, FracCysm1, FracCysm2))
    if nostates == "yes":
        logfile.write("##### ERROR; No states available ###" + "\n")
    if breakDimer == "yes":
        logfile.write("##### ERROR; Dimer formation ###" + "\n")
    logfile.write('\n')
    outfile.write("# molecule: %s , chain: %s, residue: %s %s, pH: %s " % (molecule, chain, residueName, residue, pH) + "\n")
    outfile.write("# BoltzSumNi:  BoltzPartition:  BoltzMCSC" + "\n")
    outfile.write(("# %.4f  %.4f  %.4f" + '\n') % (BoltzSumNi, BoltzPartition, BoltzMCSC))
    outfile.write("#    Res  NC    States  pKmcsc  pK1   pKB     pK2  pKm1     pKm2    f(C-)m1   f(C-)m2" + "\n")
    outfile.write(("; %s %s   %s  %s     %.4f  %s  %.4f  %s  %.4f  %.4f  %.6f  %.6f" + '\n') % (residueName, residue, NeighbourCount, AvailRotStates, DeltapKMCSC, pK1, DeltapKB, pK2, pKm1, pKm2, FracCysm1, FracCysm2))
    if nostates == "yes":
        outfile.write("##### ERROR; No states available ###" + "\n")
    if breakDimer == "yes":
        outfile.write("##### ERROR; Dimer formation ###" + "\n")
    outfile.write('\n')
    outfile.write("#Ang  SumMCSC   NC rNC MCSC_Weight       SG[X,Y,Z]" + "\n")
    for i in range(len(ListofEnergies)):
        outfile.write("%4.1d %10.3f %2.1d %1.1d %10.3f [%8.3f, %8.3f, %8.3f]" % (ListofEnergies[i][0], ListofEnergies[i][1], ListofEnergies[i][2], ListofEnergies[i][3], ListofEnergies[i][4], ListofEnergies[i][5][0], ListofEnergies[i][5][1], ListofEnergies[i][5][2]) + '\n')
    for i in range(len(ListofRotamerDiscarded)):
        outfile.write("%4.1d %10.3f %2.1d %1.1d %10.3f [%8.3f, %8.3f, %8.3f]" % (ListofRotamerDiscarded[i][0], ListofRotamerDiscarded[i][1], ListofRotamerDiscarded[i][2], ListofRotamerDiscarded[i][3], ListofRotamerDiscarded[i][4], ListofRotamerDiscarded[i][5][0], ListofRotamerDiscarded[i][5][1], ListofRotamerDiscarded[i][5][2]) + '\n')
    outfile.close()

    # Now, we are done. Just print out. The ; is for a grep command to select these lines in the output.
    print("# residue: %s %s. Average NeighbourCount NC= %s " % (residueName, residue, NeighbourCount))
    print("# From residue %s to residue %s" % (Minresidue, Maxresidue))
    print("# BoltzSumNi:  BoltzPartition:  BoltzMCSC")
    print("# %.4f  %.4f  %.4f" % (BoltzSumNi, BoltzPartition, BoltzMCSC))
    print("# Result written in file: %s" % (filename))
    print("#    Res  NC    States  pKmcsc  pK1   pKB     pK2  pKm1     pKm2    f(C-)m1   f(C-)m2")
    print("; %s %s   %s  %s     %.4f  %s  %.4f  %s  %.4f  %.4f  %.6f  %.6f" % (residueName, residue, NeighbourCount, AvailRotStates, DeltapKMCSC, pK1, DeltapKB, pK2, pKm1, pKm2, FracCysm1, FracCysm2))
    if nostates == "yes":
        print("##### ERROR; No states available ###")
    if breakDimer == "yes":
        print("##### ERROR; Dimer formation ###")
Ejemplo n.º 38
0
    def Btn_Save_Clefts(self):
        
        if self.TempBindingSite.Count_Cleft() > 0:
            
            DefaultPath = os.path.join(self.top.CleftProject_Dir,self.LastdefaultOption.upper())
            if not os.path.isdir(DefaultPath):
                os.makedirs(DefaultPath)
            
            SaveFile = tkFileDialog.asksaveasfilename(initialdir=DefaultPath, title='Choose the Cleft base filename',
                                                      initialfile=self.LastdefaultOption)
            
            if SaveFile:

                SaveFile = os.path.normpath(SaveFile)
                
                if DefaultPath not in SaveFile:
                    self.DisplayMessage("  ERROR: The file can only be saved at its default location", 2)
                    return
                
                if glob(SaveFile + "_sph_*.nrgclf"):
                    message = "The Cleft base filename you selected is already taken. " + \
                              "Are you sure you want to overwrite the files?\n" + \
                              "This may result in unexpected errors as the files may be used in saved session."
                
                    answer = tkMessageBox.askquestion("Question",
                                                      message=message,
                                                      icon='warning')
                    if str(answer) == 'no':
                        self.top.DisplayMessage("  The saving of clefts was cancelled.", 2)
                        return
            
                self.Update_TempBindingSite()
                self.top.Manage.save_Temp()
                
                for CleftName in self.TempBindingSite.Get_SortedCleftNames():
                    
                    Cleft = self.TempBindingSite.Get_CleftName(CleftName)
                    #CleftPath = os.path.join(self.top.CleftProject_Dir,Cleft.UTarget)
                    
                    m = re.match('(\S+)(_sph_(\d+)(_pt)?)', CleftName)
                    if m:
                        CleftNamePrefix = m.group(1)
                        CleftNameSuffix = m.group(2)
                    else:
                        continue
                    
                    #if not os.path.isdir(CleftPath):
                    #    os.makedirs(CleftPath)
                    
                    NewCleftNamePrefix = os.path.split(SaveFile)[1]
                    CleftSaveFile = SaveFile + CleftNameSuffix + '.nrgclf'

                    # rename cleft objects in pymol also if renamed
                    if NewCleftNamePrefix != CleftNamePrefix:
                        
                        try:
                            cmd.set_name(CleftName, NewCleftNamePrefix + CleftNameSuffix)
                        except:
                            self.top.DisplayMessage("  ERROR: Failed to rename cleft '" + Cleft.CleftName + "'", 2)
                            continue

                    Cleft.CleftName = NewCleftNamePrefix + CleftNameSuffix
                    
                    try:
                        out = open(CleftSaveFile, 'wb')
                        pickle.dump(Cleft, out)
                        out.close()
                    
                        #self.top.DisplayMessage("  Successfully saved '" + CleftSaveFile + "'", 0)
                    except:
                        self.top.DisplayMessage("  ERROR: Could not save binding-site '" + CleftSaveFile + "'", 1)
                        continue
                                                        
            else:
                self.top.DisplayMessage("  No clefts to save.", 2)
Ejemplo n.º 39
0
import pymol
from pymol import cmd

# Input variables
structure = '5VN3'

# Clear pymol, get structure, and remove non-Env chains
# gp41 = chain A, B, D
# gp120 = chain G, I, J
# CD4 = chains C, E, F
# 17b = chains H, K, M and L, N, O
cmd.delete('all')
cmd.fetch(structure)  #, type='pdb1')
cmd.remove('c;C,E,F,H,K,M,L,N,O')
cmd.set_name(structure, '5VN3_trimer')
cmd.select('gp160', 'c;A,G')
cmd.create(structure, 'gp160')

# Read in RSA values from file
d = {}
with open('5VN3_RSA_and_SS.txt') as f:
    for (i, line) in enumerate(f):
        line = line.strip().split(',')
        site = line[0]
        RSA = line[3]
        if i == 0:
            assert site == 'site'
            assert RSA == 'RSA'
        else:
            site = int(site)
Ejemplo n.º 40
0
 def test_set_name(self):
     cmd.pseudoatom('m1')
     cmd.set_name('m1', 'm2')
     self.assertEqual(['m2'], cmd.get_names())
Ejemplo n.º 41
0
    def ce_align(self,
                 elements_to_align,
                 output_file_name=None,
                 use_seq_info=False):
        """
        Actually performs the structural alignment.
        """

        #----------------------------------------------------
        # Run CE-alignment using the PyMOL built-in module. -
        #----------------------------------------------------

        retain_order = True
        if retain_order:
            cmd.set("retain_order", 1)

        sel1 = elements_to_align[0].get_pymol_selector()
        sel2 = elements_to_align[1].get_pymol_selector()

        # Sets temporary names.
        tsel1 = "t" + elements_to_align[0].get_unique_index_header()
        tsel2 = "t" + elements_to_align[1].get_unique_index_header()

        cmd.set_name(sel1, tsel1)
        cmd.set_name(sel2, tsel2)

        # Actually performs the alignment.
        a = cmd.cealign(target=tsel1,
                        mobile=tsel2,
                        object="pymod_temp_cealign")
        # cmd.center('%s and %s' % (tsel1, tsel2))
        # cmd.zoom('%s and %s' % (tsel1, tsel2))

        # Updates the names of the chains PDB files and saves these new files.
        saved_file1 = sel1 + "_aligned.pdb"
        saved_file2 = sel2 + "_aligned.pdb"
        # elements_to_align[0].structure.chain_pdb_file_name = saved_file1
        # elements_to_align[1].structure.chain_pdb_file_name = saved_file2
        cmd.save(os.path.join(self.pymod.structures_dirpath, saved_file1),
                 tsel1)
        cmd.save(os.path.join(self.pymod.structures_dirpath, saved_file2),
                 tsel2)

        # Finally saves the structural alignment between the sequences.
        cmd.save(
            os.path.join(self.pymod.alignments_dirpath,
                         output_file_name + ".aln"), "pymod_temp_cealign")
        cmd.delete("pymod_temp_cealign")

        # Converts it in .aln format.
        recs = SeqIO.parse(
            os.path.join(self.pymod.alignments_dirpath,
                         output_file_name + ".aln"), "clustal")
        new_recs = []
        for rec, pymod_element in zip(
                recs, (elements_to_align[0], elements_to_align[1])):
            new_rec_id = "_".join(rec.id[1:].split("_")[0:3])
            new_rec_seq = str(rec.seq).replace(
                "?", "X")  # Replaces modified residues.

            new_recs.append(SeqRecord(Seq(new_rec_seq), id=new_rec_id))

        SeqIO.write(
            new_recs,
            os.path.join(self.pymod.alignments_dirpath,
                         output_file_name + ".aln"), "clustal")

        # Sets the names of the objects back to original ones.
        cmd.set_name(tsel1, sel1)
        cmd.set_name(tsel2, sel2)

        if retain_order:
            cmd.set("retain_order", 0)
Ejemplo n.º 42
0
    def Btn_Save_Clefts(self):

        if self.TempBindingSite.Count_Cleft() > 0:

            DefaultPath = os.path.join(self.top.CleftProject_Dir,
                                       self.LastdefaultOption.upper())
            if not os.path.isdir(DefaultPath):
                os.makedirs(DefaultPath)

            SaveFile = tkFileDialog.asksaveasfilename(
                initialdir=DefaultPath,
                title='Choose the Cleft base filename',
                initialfile=self.LastdefaultOption)

            if SaveFile:

                SaveFile = os.path.normpath(SaveFile)

                if DefaultPath not in SaveFile:
                    self.DisplayMessage(
                        "  ERROR: The file can only be saved at its default location",
                        2)
                    return

                if glob(SaveFile + "_sph_*.nrgclf"):
                    message = "The Cleft base filename you selected is already taken. " + \
                              "Are you sure you want to overwrite the files?\n" + \
                              "This may result in unexpected errors as the files may be used in saved session."

                    answer = tkMessageBox.askquestion("Question",
                                                      message=message,
                                                      icon='warning')
                    if str(answer) == 'no':
                        self.top.DisplayMessage(
                            "  The saving of clefts was cancelled.", 2)
                        return

                self.Update_TempBindingSite()
                self.top.Manage.save_Temp()

                for CleftName in self.TempBindingSite.Get_SortedCleftNames():

                    Cleft = self.TempBindingSite.Get_CleftName(CleftName)
                    #CleftPath = os.path.join(self.top.CleftProject_Dir,Cleft.UTarget)

                    m = re.match('(\S+)(_sph_(\d+)(_pt)?)', CleftName)
                    if m:
                        CleftNamePrefix = m.group(1)
                        CleftNameSuffix = m.group(2)
                    else:
                        continue

                    #if not os.path.isdir(CleftPath):
                    #    os.makedirs(CleftPath)

                    NewCleftNamePrefix = os.path.split(SaveFile)[1]
                    CleftSaveFile = SaveFile + CleftNameSuffix + '.nrgclf'

                    # rename cleft objects in pymol also if renamed
                    if NewCleftNamePrefix != CleftNamePrefix:

                        try:
                            cmd.set_name(CleftName,
                                         NewCleftNamePrefix + CleftNameSuffix)
                        except:
                            self.top.DisplayMessage(
                                "  ERROR: Failed to rename cleft '" +
                                Cleft.CleftName + "'", 2)
                            continue

                    Cleft.CleftName = NewCleftNamePrefix + CleftNameSuffix

                    try:
                        out = open(CleftSaveFile, 'wb')
                        pickle.dump(Cleft, out)
                        out.close()

                        #self.top.DisplayMessage("  Successfully saved '" + CleftSaveFile + "'", 0)
                    except:
                        self.top.DisplayMessage(
                            "  ERROR: Could not save binding-site '" +
                            CleftSaveFile + "'", 1)
                        continue

            else:
                self.top.DisplayMessage("  No clefts to save.", 2)
Ejemplo n.º 43
0
from pymol import cmd

pymol.finish_launching()

if len(sys.argv) != 6:
    print("Usage: %s pdb-file align-sele save-sele align-atoms frame-pdb")
    sys.exit(1)

struct_path = sys.argv[1]
struct_name = os.path.splitext(os.path.basename(struct_path))[0]
cmd.load(struct_path, struct_name)

cmd.split_states(struct_name, 1, 1, "temp")
cmd.delete(struct_name)
# cmd.save('%s_debug.pse' % struct_name)
cmd.set_name("temp0001", struct_name)

frame_bname = "frame"
sys
# frame_path = './aa_frames/ile_frame.pdb'
frame_path = sys.argv[5]
cmd.load(frame_path, frame_bname)

# target_sele = 'resn asp'
target_sele = sys.argv[2]
# dist = 6
# dist = sys.argv[3]
user_sele = sys.argv[3]

# 1) find residue number of all residues in the selection
# 2) align residue to the frame