Hi all, I am trying to import my pdb files from different files in a file in local computer to pymol software, and then to align all these pdb. I just downloaded a script (load_files) online from pymol wiki, but I don't know how to modify it to enable the import. Could you give me any suggestions? Thank you very much!
The script is as follows:
# Copyright (c) 2004 Robert L. Campbell
from pymol import cmd
import glob
def load_files(files):
"""
load_files <files>
loads multiple files (using filename globbing)
into a multiple objects named as the files are (e.g. collection of
downloaded PDB files).
e.g. load_files prot_*.pdb
"""
file_list = glob.glob(files)
if file_list:
file_list.sort()
for i in file_list:
#obj_name = i.replace('.pdb','')
#cmd.load(file_list[i],obj_name)
cmd.load(i)
else:
print("No files found for pattern %s" % files)
cmd.extend('load_files',load_files)
Bests,
Yaohui
Hi Dlakic, Thank you very much! That works! So here comes another question: now I am trying to align all these pdb files to one of the pdb, let's say proteinA. So I typed in the following command lines: align all(target=proteinA,mobile_selection='name ca',target_selection='name ca',cutoff=2, cycles=5,cgo_object=0,method='align'). But it didn't work, and gave me a warning: Parsing-Error: missing required argument in function align : target. How shall I revise these commands? Thank you very much for help! The script used here is as follows:
I think it would be more useful if you provide a link to the script rather than trying to paste the contents. It may be a good idea to delete the second posting of the same message as it clutters this page.
You are trying to mimic the formatting of the
def
line from that script, while the proper way to do it is without parentheses, as demonstrated in the script itself on theExample:
line:align_all target=proteinA, mobile_selection=(name ca), target_selection=(name ca), cutoff=2, cycles=5, cgo_object=0, method=align
I am assuming that the use of parentheses was your mistake, but it could also be that you mis-typed the name of your target (proteinA) since that is what error message indicates. Also, the exact selection formatting in PyMol can be difficult to understand, and I suggest you read about it here and here.
On a different note: PyMol does not have the greatest algorithm for structural alignment. Unless your proteins are very similar structurally, I would consider aligning them externally and loading the aligned structures into PyMol. Some links for that in case you don't have a stand-alone aligner available:
https://zhanglab.ccmb.med.umich.edu/TM-align/
http://pwp.gatech.edu/cssb/fr-tm-align/
http://matt.cs.tufts.edu/
https://theobald.brandeis.edu/theseus/
Finally, if this is helpful to you, you should consider upvoting my answer(s) and marking it as accepted.
Hi Dlakic, Thank you very much! Your suggestion again works! I think I have already upvoted your answer and also accepted it. If there is anything wrong, just tell me. Thank you very much again!