2
$\begingroup$

Is there a way write a script in python to use "super" to align proteins from a 2D array? Each row of the array has 2 columns, and for each row, I want to "super" the two proteins (one in each column)

$\endgroup$
2
  • $\begingroup$ Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. $\endgroup$
    – Community Bot
    Aug 26, 2022 at 2:08
  • $\begingroup$ What do you mean by super? Is it this? $\endgroup$
    – gringer
    Aug 27, 2022 at 9:41

1 Answer 1

1
$\begingroup$

You can use Python "normally" and import the pymol module. In the script that holds the proteins in your matrix, you can add a function that does the super alignment.

To use it, in your console type pymol -cq this_script_name.py.

You need to have pymol installed and accessed via console. Easiest way I found to manage it is to create a new environment via conda and install pymol there.

import pymol


def super_prots(prot_1, prot_2):
    pymol.cmd.fetch(prot_1, 'prot_1')
    pymol.cmd.fetch(prot_2, 'prot_2')

    # If you are using already downloaded pdb files, use load instead:
    # pymol.cmd.load(prot_1, 'prot_1')
    # pymol.cmd.load(prot_2, 'prot_2')

    pymol.cmd.hide('all')
    pymol.cmd.set('ray_opaque_background', 0)

    # Show cartoon and paint them different
    pymol.cmd.show('cartoon', 'prot_1')
    pymol.cmd.color('orange', 'prot_1')
    pymol.cmd.show('cartoon', 'prot_2')
    pymol.cmd.color('lightblue', 'prot_2')

    # Align both proteins
    pymol.cmd.super('prot_1', 'prot_2')

    # Improve image quality, and get png.
    pymol.cmd.set('depth_cue', 0)
    pymol.cmd.set('spec_reflect', 0)
    pymol.cmd.set('cartoon_sampling', 15)
    pymol.cmd.set('ribbon_sampling', 15)
    pymol.cmd.set('antialias', 2)
    pymol.cmd.space('cmyk')

    # This creates high-quality images, but might take a long time to
    # process. Adjust parameters accordingly.
    pymol.cmd.png(f'{prot_1}_{prot_2}.png',
                  width=2000,
                  dpi=300,
                  ray=1
                  )
    pymol.cmd.reinitialize()

if __name__ == '__main__':
    # These are entries from PDB. It can work with already downloaded
    # files, but you have to change the function accordingly
    protein_matrix = [['1EWL', '4W5B'],
                      ['4E2D', '3ATZ'],
                      ]
    for prot_1, prot_2 in protein_matrix:
        super_prots(prot_1, prot_2)

This will generate .png images of the alignment, but you can also ask it to save the alignment into .pdb files adding pymol.cmd.save(f'{prot_1}_{prot_2}.pdb')

The commands' documentation can be found here.

$\endgroup$

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.