can you please give me an advice how to convert .cif files into .pdb preferably using python?

Thanks in advance! Best, Balint Biro

  • 1
    $\begingroup$ Its certainly doable and PyMol will also do this. A number of site members hold this expertise. What I think is that the format you are downloading in is cif rather than what you want which is pdb. If that is the case please modify your question $\endgroup$
    – M__
    Oct 15, 2020 at 16:13
  • $\begingroup$ Dear Michael,yes, that is the case but I cant see how should I modify my question... $\endgroup$ Oct 15, 2020 at 22:07
  • $\begingroup$ Using the edit button :-) $\endgroup$ Oct 16, 2020 at 10:20

1 Answer 1


As @Michael said PyMOL can do this. PyMOL is not only an app, but also a python package —installed via conda not via the regular download (you can have both).

import pymol2
with pymol2.PyMOL() as pymol:
     pymol.cmd.save(infile.replace('.cif', '.pdb'), selection='myprotein')

This runs the parallelisable instance, so you can have that context manager block running on how many threads or processes you fancy.

  • $\begingroup$ Dear Matteo, thanks for that. Unfortunately it gives me back the error that 'name 'infile' is not defined'. $\endgroup$ Oct 15, 2020 at 22:08
  • $\begingroup$ @BalintBiro You need to change that part so that it matches the name of the file you are using. $\endgroup$
    – user438383
    Oct 15, 2020 at 22:16
  • 1
    $\begingroup$ Hi @BalintBiro please upvote or mark 'accepted'. This is the answer. You need to define the location of the infile before the with statement starts, thats why you have the error. You need a certain degree of coding proficiency. $\endgroup$
    – M__
    Oct 15, 2020 at 22:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.