Skip to content
Snippets Groups Projects
Commit ee8101a8 authored by Bienchen's avatar Bienchen Committed by BIOPZ-Johner Niklaus
Browse files

Checked test_raw_modeling.py

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