luna.align.tmalign module

class TMAlignment(score, records, **kwargs)[source]

Bases: Bio.Align.MultipleSeqAlignment

Store TM-align results, including sequence alignment and TM-score.

Parameters
align_structures(pdb_to_align, ref_pdb, output_path=None, tmalign=None)[source]

Align two PDB files with TM-align.

Warning

TM-align performs pair-wise structural alignments. Therefore, if your PDB file contains multiple structures, it is recommended you extract the chains first and align them separately, otherwise the alignment may not produce the expected results.

To extract chains you can use Extractor.

Parameters
  • pdb_to_align (str) – The PDB structure that will be aligned to ref_pdb.

  • ref_pdb (str) – Reference PDB file, i.e., align pdb_to_align to ref_pdb.

  • output_path (str) – Where to save TM-align output structures.

  • tmalign (str) – Pathname to TM-align binary. The default value is ‘/bin/tmalign’.

Returns

  • TMAlignment

  • Results of TM-align, including sequence alignment and TM-score.

Examples

>>> from luna.util.default_values import LUNA_PATH
>>> from luna.align.tmalign import align_structures
>>> pdb1 = "{LUNA_PATH}/tutorial/inputs/3QQF.pdb"
>>> pdb2 = "{LUNA_PATH}/tutorial/inputs/3QQK.pdb"
>>> alignment = align_structures(pdb1, pdb2, "./", tmalign="/media/data/Workspace/Softwares/TMalignc/TMalign")
>>> print(alignment.score)
0.98582
extract_chain_from_sup(sup_file, extract_chain, output_file, new_chain_id=None, QUIET=True)[source]

Extract a chain from the superposition file generated by TM-align.

Warning

TM-align modifies the id of the original chains, so it is highly recommended to rename it to match the original chain id. To do so, use the parameter new_chain_id.

Parameters
  • sup_file (str) – A superposition file generated by TM-align.

  • extract_chain ({‘A’, ‘B’}) – Target chain id to be extracted. TM-align performs pair-wise structural alignment, so the output file will always contain two chains ‘A’ and ‘B’, where ‘A’ and ‘B’ are the aligned and reference structures, respectively.

  • output_file (str) – Save the extracted chain to this file.

  • new_chain_id (str, optional) – The new chain id of the extracted chain. If not provided, the chain ids will be maintained as it is in the TM-align output.

  • QUIET (bool) – If True (the default), mute warning messages generated by Biopython.

get_seq_records(tm_output, aligned_pdb_id, ref_pdb_id)[source]

Create a pair of Bio.SeqRecord.SeqRecord from a TM-align output.

Parameters
  • tm_output (str) – The output produced by TM-align.

  • aligned_pdb_id (str) – An identifier for the aligned PDB file.

  • ref_pdb_id (str) – An identifier for the reference PDB file.

remove_sup_files(path)[source]

Remove all superposition files created by TM-align at a defined directory path.