Skip to content
Snippets Groups Projects
Select Git revision
  • d97d8f5058634a91c05e885def553548abd3abf5
  • master default protected
  • develop protected
  • cmake_boost_refactor
  • ubuntu_ci
  • mmtf
  • non-orthogonal-maps
  • no_boost_filesystem
  • data_viewer
  • 2.11.1
  • 2.11.0
  • 2.10.0
  • 2.9.3
  • 2.9.2
  • 2.9.1
  • 2.9.0
  • 2.8.0
  • 2.7.0
  • 2.6.1
  • 2.6.0
  • 2.6.0-rc4
  • 2.6.0-rc3
  • 2.6.0-rc2
  • 2.6.0-rc
  • 2.5.0
  • 2.5.0-rc2
  • 2.5.0-rc
  • 2.4.0
  • 2.4.0-rc2
29 results

test_aligntoseqres.py

Blame
  • user avatar
    Marco Biasini authored
    Unit tests are working, except the ones relying on the
    HeuristicProcessor, which is currently only a stub.
    e66b086f
    History
    test_aligntoseqres.py 3.43 KiB
    import unittest
    from ost import *
    from ost import settings
    from ost import seq
    from ost import io
    
    class TestAlignToSeqRes(unittest.TestCase):
      def testAlignWorking(self):
        ent, seqres = io.LoadMMCIF("testfiles/align_to_seqres.mmcif", seqres = True)
        chain =  ent.FindChain("A")
        sequence = seqres.FindSequence(chain.GetName());
        seqres_aln = seq.alg.AlignToSEQRES(chain, sequence, try_resnum_first=False)
        self.assertEqual(str(sequence), "MYTNSDFVVIKALEDGVNVIGLTRGADTRFHHSEKLDKGEV"+
                         "LIAQFTEHTSAIKVRGKAYIQTRHGVIESEGKK")
        self.assertEqual(str(seqres_aln.sequences[1]), "----SDFVVIKALEDGVNVIGLTR--"+
                         "-TRFHHSEKLDKGEVLIAQFTEHTSAIKVRGKAYIQTRHGVIESEGK-")
    
        seqres_aln = seq.alg.AlignToSEQRES(chain, sequence, try_resnum_first=True)
        self.assertEqual(str(seqres_aln.sequences[1]), "----SDFVVIKALEDGVNVIGLTR--"+
                         "-TRFHHSEKLDKGEVLIAQFTEHTSAIKVRGKAYIQTRHGVIESEGK-")
    
      def testAlignFail(self):
        ent, seqres = io.LoadMMCIF("testfiles/align_to_seqres_valueerror.mmcif",
                                   seqres = True)
        chain =  ent.FindChain("A")
        sequence = seqres.FindSequence(chain.GetName());
        ost.PushVerbosityLevel(0)
        self.assertRaises(ValueError, seq.alg.AlignToSEQRES, chain, sequence, True)
        ost.PopVerbosityLevel()
    
      def testValidateWorking(self):
        ent, seqres = io.LoadMMCIF("testfiles/align_to_seqres.mmcif", seqres = True)
        chain =  ent.FindChain("A")
        sequence = seqres.FindSequence(chain.GetName());
        seqres_aln = seq.alg.AlignToSEQRES(chain, sequence, try_resnum_first=False)
        self.assertEqual(seq.alg.ValidateSEQRESAlignment(seqres_aln, chain), True)
    
      def testValidateWorkingOnAttachedView(self):
        ent, seqres = io.LoadMMCIF("testfiles/align_to_seqres.mmcif", seqres = True)
        chain =  ent.FindChain("A")
        sequence = seqres.FindSequence(chain.GetName());
        seqres_aln = seq.alg.AlignToSEQRES(chain, sequence, try_resnum_first=False)
        seqres_aln.AttachView(1, chain.Select(''))
        self.assertEqual(seq.alg.ValidateSEQRESAlignment(seqres_aln), True)
    
      def testValidateEmptySequenceWorking(self):
        alignment = seq.CreateAlignment(seq.CreateSequence('SEQRES', ''), 
                                        seq.CreateSequence('atoms', ''))
        chain = mol.ChainHandle()
        self.assertEqual(seq.alg.ValidateSEQRESAlignment(alignment, chain), True)
    
      def testValidateStrandBreakageFail(self):
        ent, seqres = io.LoadMMCIF("testfiles/validate_segres_aln_breakage.mmcif",
                                   seqres = True)
        chain = ent.FindChain("A")
        sequence = seqres.FindSequence(chain.GetName());
        seqres_aln = seq.alg.AlignToSEQRES(chain, sequence, try_resnum_first = True,
                                           validate = False)
        self.assertEqual(seq.alg.ValidateSEQRESAlignment(seqres_aln, chain), False)
    
      def testValidateGapConnectedFail(self):
        ent, seqres = io.LoadMMCIF("testfiles/validate_seqres_aln_connected.mmcif",
                                   seqres = True,)
        chain = ent.FindChain("A")
        sequence = seqres.FindSequence(chain.GetName());
        seqres_aln = seq.alg.AlignToSEQRES(chain, sequence, try_resnum_first = True,
                                           validate = False)
        self.assertEqual(seq.alg.ValidateSEQRESAlignment(seqres_aln, chain), False)
    
    if __name__ == "__main__":
      if not conop.GetDefaultLib():
        print 'No compound library available. Ignoring unit tests'
      else:
        from ost import testutils
        testutils.RunTests()