File: test_PDB_StructureAlignment.py

package info (click to toggle)
python-biopython 1.78%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 65,756 kB
  • sloc: python: 221,141; xml: 178,777; ansic: 13,369; sql: 1,208; makefile: 131; sh: 70
file content (48 lines) | stat: -rw-r--r-- 1,734 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Copyright 2017 by Francesco Gastaldello. All rights reserved.
#
# Converted by Francesco Gastaldello from an older unit test copyright 2004
# by Thomas Hamelryck.
#
# This file is part of the Biopython distribution and governed by your
# choice of the "Biopython License Agreement" or the "BSD 3-Clause License".
# Please see the LICENSE file that should have been included as part of this
# package.
"""Unit tests for the Bio.PDB.StructureAlignment module."""

import unittest

from Bio.PDB import StructureAlignment
from Bio.PDB import PDBParser
from Bio import AlignIO


class StructureAlignTests(unittest.TestCase):
    """Test module StructureAlignment."""

    def test_StructAlign(self):
        """Tests on module to align two proteins according to a FASTA alignment file."""
        p = PDBParser(QUIET=1)

        al_file = "PDB/alignment_file.fa"
        with open(al_file) as handle:
            records = AlignIO.read(handle, "fasta")

        s1 = p.get_structure("1", "PDB/2XHE.pdb")
        s2 = p.get_structure("2", "PDB/1A8O.pdb")
        m1 = s1[0]
        m2 = s2[0]
        al = StructureAlignment(records, m1, m2)
        self.assertNotEqual(al.map12, al.map21)
        self.assertTrue(len(al.map12), 566)
        self.assertTrue(len(al.map21), 70)
        chain1_A = m1["A"]
        chain2_A = m2["A"]
        self.assertEqual(chain1_A[202].get_resname(), "ILE")
        self.assertEqual(chain2_A[202].get_resname(), "LEU")
        self.assertEqual(chain1_A[291].get_resname(), chain2_A[180].get_resname())
        self.assertNotEqual(chain1_A[291].get_resname(), chain2_A[181].get_resname())


if __name__ == "__main__":
    runner = unittest.TextTestRunner(verbosity=2)
    unittest.main(testRunner=runner)