text: user16041: 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)
  
  user10254: 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.
  
original_text: 16041: <p>Is there a way write a script in python to use &quot;super&quot; to align proteins from a 2D array? Each row of the array has 2 columns, and for each row, I want to &quot;super&quot; the two proteins (one in each column)</p>
   10254: <p>You can use Python &quot;normally&quot; and import the <code>pymol</code> module. In the script that holds the proteins in your matrix, you can add a function that does the super alignment.</p>
  <p>To use it, in your console type <code>pymol -cq this_script_name.py</code>.</p>
  <p>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.</p>
  <pre><code>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)
  </code></pre>
  <p>This will generate .png images of the alignment, but you can also ask it to save the alignment into .pdb files adding <code>pymol.cmd.save(f'{prot_1}_{prot_2}.pdb')</code></p>
  <p>The commands' documentation can be found <a href="https://pymol.org/pymol-command-ref.html" rel="nofollow noreferrer">here</a>.</p>
  