Skip to content
Snippets Groups Projects
Commit 45567687 authored by Bienchen's avatar Bienchen
Browse files

Checked test_raw_modeling.py

parent a0431985
Branches
Tags
No related merge requests found
......@@ -8,8 +8,11 @@ gap.hh
model.hh
)
module(NAME meld HEADERS ${MELD_HEADERS} SOURCES ${MELD_SOURCES} DEPENDS_ON
promod3_core LINK ${OPENGL_LIBRARIES} ${OST_LIBRARIES} ${BOOST_LIBRARIES})
module(NAME meld
HEADERS ${MELD_HEADERS}
SOURCES ${MELD_SOURCES}
DEPENDS_ON promod3_core
LINK ${OPENGL_LIBRARIES} ${OST_LIBRARIES} ${BOOST_LIBRARIES})
if (QMEAN_ROOT)
target_link_libraries(promod3_meld ${QMEAN_LIBRARIES})
......
......@@ -20,4 +20,3 @@ set(MELD_TEST_DATA
promod3_unittest(MODULE meld
SOURCES "${MELD_UNIT_TESTS}"
DATA "${MELD_TEST_DATA}")
"""
Unit tests for meld.
"""
import unittest
from promod3 import meld
from ost import conop, seq, io, mol
class RawModelingTests(unittest.TestCase):
def setUp(self):
compound_lib=conop.CompoundLib.Load('data/raw-modeling/compounds.chemlib')
conop.SetDefaultLib(compound_lib)
io.profiles['DEFAULT'].processor = conop.RuleBasedProcessor(compound_lib)
def setUp(self):
compound_lib = conop.CompoundLib.Load(
'data/raw-modeling/compounds.chemlib')
conop.SetDefaultLib(compound_lib)
io.profiles['DEFAULT'].processor = conop.RuleBasedProcessor(
compound_lib)
def testRaiseNoAttachedView(self):
# test that BuildRawModel throws exception when no view is attached
aln=seq.CreateAlignment(seq.CreateSequence('A', 'acdef'),
seq.CreateSequence('B', 'ac-ef'))
self.assertRaises(RuntimeError, meld.BuildRawModel, aln)
def testModeledSequence(self):
# test if the model has the sequence we want.
tpl=io.LoadPDB('data/raw-modeling/gly.pdb')
aln=io.LoadAlignment('data/raw-modeling/seq.fasta')
aln.AttachView(1, tpl.CreateFullView())
result=meld.BuildRawModel(aln)
seq1=seq.SequenceFromChain('MODEL', result.model.chains[0])
self.assertEqual(seq1.string, aln.sequences[0].string)
def testRaiseNoAttachedView(self):
# test that BuildRawModel throws exception when no view is attached
aln = seq.CreateAlignment(seq.CreateSequence('A', 'acdef'),
seq.CreateSequence('B', 'ac-ef'))
self.assertRaises(RuntimeError, meld.BuildRawModel, aln)
def testDeletion(self):
# test if the result contains a "deletion" gap at the right spot.
tpl=io.LoadPDB('data/raw-modeling/gly.pdb')
aln=io.LoadAlignment('data/raw-modeling/del.fasta')
aln.AttachView(1, tpl.CreateFullView())
result=meld.BuildRawModel(aln)
residues=result.model.residues
self.assertEqual(len(result.gaps), 1)
self.assertEqual(result.gaps[0].before, residues[2])
self.assertEqual(result.gaps[0].after, residues[3])
self.assertEqual(result.gaps[0].seq, '')
def testModeledSequence(self):
# test if the model has the sequence we want.
tpl = io.LoadPDB('data/raw-modeling/gly.pdb')
aln = io.LoadAlignment('data/raw-modeling/seq.fasta')
aln.AttachView(1, tpl.CreateFullView())
result = meld.BuildRawModel(aln)
seq1 = seq.SequenceFromChain('MODEL', result.model.chains[0])
self.assertEqual(seq1.string, aln.sequences[0].string)
def testInsertion(self):
# test if the result contains an "insertion" gap at the right spot.
tpl=io.LoadPDB('data/raw-modeling/gly.pdb')
aln=io.LoadAlignment('data/raw-modeling/ins.fasta')
aln.AttachView(1, tpl.CreateFullView())
result=meld.BuildRawModel(aln)
residues=result.model.residues
self.assertEqual(len(result.gaps), 1)
self.assertEqual(result.gaps[0].before, residues[1])
self.assertEqual(result.gaps[0].after, residues[2])
self.assertEqual(result.gaps[0].seq, 'AV')
def testTer(self):
# test if the result contains two terminal gaps, one at the beginning,
# one at the end
tpl=io.LoadPDB('data/raw-modeling/gly.pdb')
aln=io.LoadAlignment('data/raw-modeling/ter.fasta')
aln.AttachView(1, tpl.CreateFullView())
result=meld.BuildRawModel(aln)
residues=result.model.residues
self.assertEqual(len(result.gaps), 2)
self.assertEqual(result.gaps[0].before, mol.ResidueHandle())
self.assertEqual(result.gaps[0].after, residues[0])
self.assertEqual(result.gaps[0].seq, 'G')
self.assertEqual(result.gaps[1].before, residues[-1])
self.assertEqual(result.gaps[1].after, mol.ResidueHandle())
self.assertEqual(result.gaps[1].seq, 'G')
def testDeletion(self):
# test if the result contains a "deletion" gap at the right spot.
tpl = io.LoadPDB('data/raw-modeling/gly.pdb')
aln = io.LoadAlignment('data/raw-modeling/del.fasta')
aln.AttachView(1, tpl.CreateFullView())
result = meld.BuildRawModel(aln)
residues = result.model.residues
self.assertEqual(len(result.gaps), 1)
self.assertEqual(result.gaps[0].before, residues[2])
self.assertEqual(result.gaps[0].after, residues[3])
self.assertEqual(result.gaps[0].seq, '')
def testModified(self):
# test if we correctly strip off modifications
tpl=io.LoadPDB('data/raw-modeling/sep.pdb')
aln=io.LoadAlignment('data/raw-modeling/sep.fasta')
aln.AttachView(1, tpl.CreateFullView())
result=meld.BuildRawModel(aln)
residues=result.model.residues
self.assertEqual(len(residues), 1)
self.assertEqual(len(residues[0].atoms), 6)
self.assertTrue(residues[0].FindAtom("N"))
self.assertTrue(residues[0].FindAtom("CA"))
self.assertTrue(residues[0].FindAtom("C"))
self.assertTrue(residues[0].FindAtom("O"))
self.assertTrue(residues[0].FindAtom("CB"))
self.assertTrue(residues[0].FindAtom("OG"))
def testInsertion(self):
# test if the result contains an "insertion" gap at the right spot.
tpl = io.LoadPDB('data/raw-modeling/gly.pdb')
aln = io.LoadAlignment('data/raw-modeling/ins.fasta')
aln.AttachView(1, tpl.CreateFullView())
result = meld.BuildRawModel(aln)
residues = result.model.residues
self.assertEqual(len(result.gaps), 1)
self.assertEqual(result.gaps[0].before, residues[1])
self.assertEqual(result.gaps[0].after, residues[2])
self.assertEqual(result.gaps[0].seq, 'AV')
def testInsertCBeta(self):
# test if the dst residues contain cbeta, unless they are glycines
tpl=io.LoadPDB('data/raw-modeling/cbeta.pdb')
aln=io.LoadAlignment('data/raw-modeling/cbeta.fasta')
aln.AttachView(1, tpl.CreateFullView())
result=meld.BuildRawModel(aln)
residues=result.model.residues
assert not residues[0].FindAtom("CB").IsValid()
assert not residues[1].FindAtom("CB").IsValid()
assert residues[2].FindAtom("CB").IsValid()
assert residues[3].FindAtom("CB").IsValid()
def testTer(self):
# test if the result contains two terminal gaps, one at the beginning,
# one at the end
tpl = io.LoadPDB('data/raw-modeling/gly.pdb')
aln = io.LoadAlignment('data/raw-modeling/ter.fasta')
aln.AttachView(1, tpl.CreateFullView())
result = meld.BuildRawModel(aln)
residues = result.model.residues
self.assertEqual(len(result.gaps), 2)
self.assertEqual(result.gaps[0].before, mol.ResidueHandle())
self.assertEqual(result.gaps[0].after, residues[0])
self.assertEqual(result.gaps[0].seq, 'G')
self.assertEqual(result.gaps[1].before, residues[-1])
self.assertEqual(result.gaps[1].after, mol.ResidueHandle())
self.assertEqual(result.gaps[1].seq, 'G')
def testModified(self):
# test if we correctly strip off modifications
tpl = io.LoadPDB('data/raw-modeling/sep.pdb')
aln = io.LoadAlignment('data/raw-modeling/sep.fasta')
aln.AttachView(1, tpl.CreateFullView())
result = meld.BuildRawModel(aln)
residues = result.model.residues
self.assertEqual(len(residues), 1)
self.assertEqual(len(residues[0].atoms), 6)
self.assertTrue(residues[0].FindAtom("N"))
self.assertTrue(residues[0].FindAtom("CA"))
self.assertTrue(residues[0].FindAtom("C"))
self.assertTrue(residues[0].FindAtom("O"))
self.assertTrue(residues[0].FindAtom("CB"))
self.assertTrue(residues[0].FindAtom("OG"))
def testInsertCBeta(self):
# test if the dst residues contain cbeta, unless they are glycines
tpl = io.LoadPDB('data/raw-modeling/cbeta.pdb')
aln = io.LoadAlignment('data/raw-modeling/cbeta.fasta')
aln.AttachView(1, tpl.CreateFullView())
result = meld.BuildRawModel(aln)
residues = result.model.residues
self.assertFalse(residues[0].FindAtom("CB").IsValid())
self.assertFalse(residues[1].FindAtom("CB").IsValid())
self.assertTrue(residues[2].FindAtom("CB").IsValid())
self.assertTrue(residues[3].FindAtom("CB").IsValid())
if __name__ == "__main__":
from ost import testutils
testutils.RunTests()
from ost import testutils
testutils.RunTests()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment