Difference between revisions of "Get raw alignment"

From PyMOLWiki
Jump to: navigation, search
(EXAMPLE)
(2.3)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
'''get_raw_alignment''' is an API only function that returns a list of lists of (object,index) tuples containing the raw per-atom alignment relationships. Alignment objects can be created by passing the "object" argument to [[align]] or [[super]].
 
'''get_raw_alignment''' is an API only function that returns a list of lists of (object,index) tuples containing the raw per-atom alignment relationships. Alignment objects can be created by passing the "object" argument to [[align]] or [[super]].
  
''Please note: The order of the atom tuples are not necessarily in the order in which the two (or more) selections were passed to [[Align|cmd.align]].''
+
''Please note:''
 +
* ''The order of the atom tuples are not necessarily in the order in which the two (or more) selections were passed to [[Align|cmd.align]].''
 +
* ''Will not return atom tuples of hidden objects (see also [[hide_underscore_names]])''
 +
* ''Reimplemented in PyMOL 2.3, order of returned atom tuples can differ to previous versions''
  
 
== PYMOL API ==
 
== PYMOL API ==
Line 20: Line 23:
 
raw_aln = cmd.get_raw_alignment('aln')
 
raw_aln = cmd.get_raw_alignment('aln')
  
# print residue pairs
+
# print residue pairs (atom index)
 
for idx1, idx2 in raw_aln:
 
for idx1, idx2 in raw_aln:
     print '%s`%d -> %s`%d' % tuple(idx1 + idx2)
+
     print('%s`%d -> %s`%d' % tuple(idx1 + idx2))
  
 
#end the python block
 
#end the python block
 +
python end
 +
</source>
 +
 +
To print residue numbers instead of atom indices:
 +
 +
<source lang="python">
 +
# continued from previous example
 +
python
 +
 +
idx2resi = {}
 +
cmd.iterate('aln', 'idx2resi[model, index] = resi', space={'idx2resi': idx2resi})
 +
 +
# print residue pairs (residue number)
 +
for idx1, idx2 in raw_aln:
 +
    print('%s -> %s' % (idx2resi[idx1], idx2resi[idx2]))
 +
 
python end
 
python end
 
</source>
 
</source>
Line 32: Line 51:
 
* [[align]]
 
* [[align]]
 
* [[find_pairs]] returns a list of lists of (object,index) tuples as well
 
* [[find_pairs]] returns a list of lists of (object,index) tuples as well
 +
* [[set_raw_alignment]]
  
 
[[Category:Scripting]]
 
[[Category:Scripting]]
 
[[Category:Structure_Alignment]]
 
[[Category:Structure_Alignment]]

Latest revision as of 08:49, 17 December 2018

get_raw_alignment is an API only function that returns a list of lists of (object,index) tuples containing the raw per-atom alignment relationships. Alignment objects can be created by passing the "object" argument to align or super.

Please note:

  • The order of the atom tuples are not necessarily in the order in which the two (or more) selections were passed to cmd.align.
  • Will not return atom tuples of hidden objects (see also hide_underscore_names)
  • Reimplemented in PyMOL 2.3, order of returned atom tuples can differ to previous versions

PYMOL API

cmd.get_raw_alignment(string name)

EXAMPLE

# start a python block
python

# get two structures
cmd.fetch('2xwu 2x19', async=0)

# align and get raw alignment
cmd.align('/2xwu//B//CA', '/2x19//B//CA', cycles=0, transform=0, object='aln')
raw_aln = cmd.get_raw_alignment('aln')

# print residue pairs (atom index)
for idx1, idx2 in raw_aln:
    print('%s`%d -> %s`%d' % tuple(idx1 + idx2))

#end the python block
python end

To print residue numbers instead of atom indices:

# continued from previous example
python

idx2resi = {}
cmd.iterate('aln', 'idx2resi[model, index] = resi', space={'idx2resi': idx2resi})

# print residue pairs (residue number)
for idx1, idx2 in raw_aln:
    print('%s -> %s' % (idx2resi[idx1], idx2resi[idx2]))

python end

SEE ALSO