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

Merge branch 'hotfix-1.7.1'

parents 9c6bd69b 07c3773d
Branches
Tags 1.7.1
No related merge requests found
Changes in Release 1.7.1
--------------------------------------------------------------------------------
* Fixed an issue that could cause the star format parser (mmCIF, chemical
components dictionary) to enter an infinite loop
* Chemical components dictionary was extended by new chemical classes
introduced by PDB
* Fixed unit tests
* Improved documentation
Changes in Release 1.7 Changes in Release 1.7
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
......
...@@ -7,7 +7,7 @@ project(OpenStructure CXX C) ...@@ -7,7 +7,7 @@ project(OpenStructure CXX C)
set (CMAKE_EXPORT_COMPILE_COMMANDS 1) set (CMAKE_EXPORT_COMPILE_COMMANDS 1)
set (OST_VERSION_MAJOR 1) set (OST_VERSION_MAJOR 1)
set (OST_VERSION_MINOR 7) set (OST_VERSION_MINOR 7)
set (OST_VERSION_PATCH 0) set (OST_VERSION_PATCH 1)
set (OST_VERSION_STRING ${OST_VERSION_MAJOR}.${OST_VERSION_MINOR}.${OST_VERSION_PATCH} ) set (OST_VERSION_STRING ${OST_VERSION_MAJOR}.${OST_VERSION_MINOR}.${OST_VERSION_PATCH} )
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake_support) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake_support)
include(OST) include(OST)
......
:mod:`conop.cleanup <ost.conop.cleanup>` -- Sanitize structures :mod:`conop.cleanup <ost.conop.cleanup>` -- Sanitize structures
================================================================================ ================================================================================
.. module:: ost.conop.ceanup .. module:: ost.conop.cleanup
:synopsis: Contains functions to sanitize (cleanup) structures by using :synopsis: Contains functions to sanitize (cleanup) structures by using
information from the compound library. information from the compound library.
......
...@@ -195,17 +195,18 @@ void ChemdictParser::InitTypeMap() ...@@ -195,17 +195,18 @@ void ChemdictParser::InitTypeMap()
tm_["DNA LINKING"]=mol::ChemClass(mol::ChemClass::DNA_LINKING); tm_["DNA LINKING"]=mol::ChemClass(mol::ChemClass::DNA_LINKING);
tm_["RNA LINKING"]=mol::ChemClass(mol::ChemClass::RNA_LINKING); tm_["RNA LINKING"]=mol::ChemClass(mol::ChemClass::RNA_LINKING);
tm_["L-DNA LINKING"]=mol::ChemClass(mol::ChemClass::DNA_LINKING); tm_["L-DNA LINKING"]=mol::ChemClass(mol::ChemClass::DNA_LINKING);
tm_["L-RNA LINKING"]=mol::ChemClass(mol::ChemClass::RNA_LINKING); tm_["L-RNA LINKING"]=mol::ChemClass(mol::ChemClass::RNA_LINKING);
tm_["R-DNA LINKING"]=mol::ChemClass(mol::ChemClass::DNA_LINKING); tm_["R-DNA LINKING"]=mol::ChemClass(mol::ChemClass::DNA_LINKING);
tm_["R-RNA LINKING"]=mol::ChemClass(mol::ChemClass::RNA_LINKING); tm_["R-RNA LINKING"]=mol::ChemClass(mol::ChemClass::RNA_LINKING);
tm_["DNA OH 3 PRIME TERMINUS"]=mol::ChemClass(mol::ChemClass::DNA_LINKING); tm_["DNA OH 3 PRIME TERMINUS"]=mol::ChemClass(mol::ChemClass::DNA_LINKING);
tm_["DNA OH 5 PRIME TERMINUS"]=mol::ChemClass(mol::ChemClass::DNA_LINKING);
tm_["PEPTIDE-LIKE"]=mol::ChemClass(mol::ChemClass::PEPTIDE_LINKING); tm_["PEPTIDE-LIKE"]=mol::ChemClass(mol::ChemClass::PEPTIDE_LINKING);
tm_["PEPTIDE LINKING"]=mol::ChemClass(mol::ChemClass::PEPTIDE_LINKING); tm_["PEPTIDE LINKING"]=mol::ChemClass(mol::ChemClass::PEPTIDE_LINKING);
tm_["PEPTIDE-LINKING"]=mol::ChemClass(mol::ChemClass::PEPTIDE_LINKING); tm_["PEPTIDE-LINKING"]=mol::ChemClass(mol::ChemClass::PEPTIDE_LINKING);
tm_["NON-POLYMER"]=mol::ChemClass(mol::ChemClass::NON_POLYMER); tm_["NON-POLYMER"]=mol::ChemClass(mol::ChemClass::NON_POLYMER);
tm_["RNA OH 3 PRIME TERMINUS"]=mol::ChemClass(mol::ChemClass::RNA_LINKING); tm_["RNA OH 3 PRIME TERMINUS"]=mol::ChemClass(mol::ChemClass::RNA_LINKING);
tm_["RNA OH 5 PRIME TERMINUS"]=mol::ChemClass(mol::ChemClass::RNA_LINKING); tm_["RNA OH 5 PRIME TERMINUS"]=mol::ChemClass(mol::ChemClass::RNA_LINKING);
tm_["?"]=mol::ChemClass(mol::ChemClass::UNKNOWN); tm_["?"]=mol::ChemClass(mol::ChemClass::UNKNOWN);
tm_["WATER"]=mol::ChemClass(mol::ChemClass::WATER); tm_["WATER"]=mol::ChemClass(mol::ChemClass::WATER);
} }
......
...@@ -550,11 +550,15 @@ void StarParser::Parse() ...@@ -550,11 +550,15 @@ void StarParser::Parse()
case 'd': case 'd':
if (tline.length()>=5 && StringRef("data_", 5)==tline.substr(0, 5)) { if (tline.length()>=5 && StringRef("data_", 5)==tline.substr(0, 5)) {
this->ParseData(); this->ParseData();
} else {
throw IOException("Missing 'data_' control structure");
} }
break; break;
case 'g': case 'g':
if (tline.length()>=7 && StringRef("global_", 7)==tline.substr(0, 7)) { if (tline.length()>=7 && StringRef("global_", 7)==tline.substr(0, 7)) {
this->ParseGlobal(); this->ParseGlobal();
} else {
throw IOException("Missing 'global_' control structure");
} }
break; break;
case '#': case '#':
......
...@@ -389,6 +389,20 @@ BOOST_AUTO_TEST_CASE(star_items_as_row) ...@@ -389,6 +389,20 @@ BOOST_AUTO_TEST_CASE(star_items_as_row)
BOOST_TEST_MESSAGE(" done."); BOOST_TEST_MESSAGE(" done.");
} }
BOOST_AUTO_TEST_CASE(star_broken_data)
{
std::ifstream s("testfiles/broken_data.cif");
LoopTestParser star_p(s);
BOOST_CHECK_THROW(star_p.Parse(), IOException);
}
BOOST_AUTO_TEST_CASE(star_broken_global)
{
std::ifstream s("testfiles/broken_global.cif");
LoopTestParser star_p(s);
BOOST_CHECK_THROW(star_p.Parse(), IOException);
}
BOOST_AUTO_TEST_CASE(star_missing_data) BOOST_AUTO_TEST_CASE(star_missing_data)
{ {
std::ifstream s("testfiles/missing_data.cif"); std::ifstream s("testfiles/missing_data.cif");
......
d lines starting with a 'd' kicked the parser into an infinite loop.
g lines starting with a 'g' kicked the parser into an infinite loop.
...@@ -56,6 +56,8 @@ class QSscorer: ...@@ -56,6 +56,8 @@ class QSscorer:
qs_scorer = qsscoring.QSscorer(ent_1, ent_2) qs_scorer = qsscoring.QSscorer(ent_1, ent_2)
ost.LogScript('QSscore:', str(qs_scorer.global_score)) ost.LogScript('QSscore:', str(qs_scorer.global_score))
ost.LogScript('Chain mapping used:', str(qs_scorer.chain_mapping)) ost.LogScript('Chain mapping used:', str(qs_scorer.chain_mapping))
# commonly you want the QS global score as output
qs_score = qs_scorer.global_score
except qsscoring.QSscoreError as ex: except qsscoring.QSscoreError as ex:
# default handling: report failure and set score to 0 # default handling: report failure and set score to 0
ost.LogError('QSscore failed:', str(ex)) ost.LogError('QSscore failed:', str(ex))
......
...@@ -17,7 +17,7 @@ set(OST_MOL_BASE_UNIT_TESTS ...@@ -17,7 +17,7 @@ set(OST_MOL_BASE_UNIT_TESTS
) )
if (USE_NUMPY) if (USE_NUMPY)
set(OST_MOST_BASE_UNIT_TESTS "${OST_MOST_BASE_UNIT_TESTS}" test_numpy.py) list(APPEND OST_MOL_BASE_UNIT_TESTS test_numpy.py)
endif (USE_NUMPY) endif (USE_NUMPY)
ost_unittest(MODULE mol SOURCES "${OST_MOL_BASE_UNIT_TESTS}") ost_unittest(MODULE mol SOURCES "${OST_MOL_BASE_UNIT_TESTS}")
......
...@@ -5,6 +5,7 @@ if __name__== '__main__': ...@@ -5,6 +5,7 @@ if __name__== '__main__':
sys.path.insert(0,"../../../../stage/lib/openstructure/") sys.path.insert(0,"../../../../stage/lib/openstructure/")
import ost import ost
from ost import geom, mol
if ost.WITH_NUMPY: if ost.WITH_NUMPY:
has_numpy=True has_numpy=True
...@@ -16,10 +17,10 @@ else: ...@@ -16,10 +17,10 @@ else:
has_numpy=False has_numpy=False
def v2v(v): def v2v(v):
return ost.geom.Vec3(float(v[0]),float(v[1]),float(v[2])) return geom.Vec3(float(v[0]),float(v[1]),float(v[2]))
def dd(v1,v2): def dd(v1,v2):
return ost.geom.Distance(v1,v2)<1e-8 return geom.Distance(v1,v2)<1e-8
class TestNumpy(unittest.TestCase): class TestNumpy(unittest.TestCase):
def setUp(self): def setUp(self):
...@@ -28,46 +29,46 @@ class TestNumpy(unittest.TestCase): ...@@ -28,46 +29,46 @@ class TestNumpy(unittest.TestCase):
def test_(self): def test_(self):
if not has_numpy: if not has_numpy:
return return
entity=ost.mol.CreateEntity() entity=mol.CreateEntity()
ed=entity.EditXCS() ed=entity.EditXCS()
ch=ed.InsertChain("X") ch=ed.InsertChain("X")
re=ed.AppendResidue(ch,"ALA") re=ed.AppendResidue(ch,"ALA")
a0=ed.InsertAtom(re,"A",ost.geom.Vec3(0,0,0)) a0=ed.InsertAtom(re,"A",geom.Vec3(0,0,0))
self.assertEqual(a0.GetIndex(),0) self.assertEqual(a0.GetIndex(),0)
a1=ed.InsertAtom(re,"B",ost.geom.Vec3(1,0,0)) a1=ed.InsertAtom(re,"B",geom.Vec3(1,0,0))
self.assertEqual(a1.GetIndex(),1) self.assertEqual(a1.GetIndex(),1)
a2=ed.InsertAtom(re,"C",ost.geom.Vec3(2,0,0)) a2=ed.InsertAtom(re,"C",geom.Vec3(2,0,0))
self.assertEqual(a2.GetIndex(),2) self.assertEqual(a2.GetIndex(),2)
a3=ed.InsertAtom(re,"D",ost.geom.Vec3(3,0,0)) a3=ed.InsertAtom(re,"D",geom.Vec3(3,0,0))
self.assertEqual(a3.GetIndex(),3) self.assertEqual(a3.GetIndex(),3)
self.assertTrue(dd(a0.pos,ost.geom.Vec3(0,0,0))) self.assertTrue(dd(a0.pos,geom.Vec3(0,0,0)))
self.assertTrue(dd(a1.pos,ost.geom.Vec3(1,0,0))) self.assertTrue(dd(a1.pos,geom.Vec3(1,0,0)))
self.assertTrue(dd(a2.pos,ost.geom.Vec3(2,0,0))) self.assertTrue(dd(a2.pos,geom.Vec3(2,0,0)))
self.assertTrue(dd(a3.pos,ost.geom.Vec3(3,0,0))) self.assertTrue(dd(a3.pos,geom.Vec3(3,0,0)))
ed.SetAtomTransformedPos(entity.GetAtomList(), ed.SetAtomTransformedPos(entity.GetAtomList(),
numpy.array([[0,1,0],[0,2,0],[0,3,0],[0,4,0]], dtype=numpy.float32)) numpy.array([[0,1,0],[0,2,0],[0,3,0],[0,4,0]], dtype=numpy.float32))
self.assertTrue(dd(a0.pos,ost.geom.Vec3(0,1,0))) self.assertTrue(dd(a0.pos,geom.Vec3(0,1,0)))
self.assertTrue(dd(a1.pos,ost.geom.Vec3(0,2,0))) self.assertTrue(dd(a1.pos,geom.Vec3(0,2,0)))
self.assertTrue(dd(a2.pos,ost.geom.Vec3(0,3,0))) self.assertTrue(dd(a2.pos,geom.Vec3(0,3,0)))
self.assertTrue(dd(a3.pos,ost.geom.Vec3(0,4,0))) self.assertTrue(dd(a3.pos,geom.Vec3(0,4,0)))
na=entity.positions na=entity.positions
self.assertTrue(dd(v2v(na[0]),ost.geom.Vec3(0,1,0))) self.assertTrue(dd(v2v(na[0]),geom.Vec3(0,1,0)))
self.assertTrue(dd(v2v(na[1]),ost.geom.Vec3(0,2,0))) self.assertTrue(dd(v2v(na[1]),geom.Vec3(0,2,0)))
self.assertTrue(dd(v2v(na[2]),ost.geom.Vec3(0,3,0))) self.assertTrue(dd(v2v(na[2]),geom.Vec3(0,3,0)))
self.assertTrue(dd(v2v(na[3]),ost.geom.Vec3(0,4,0))) self.assertTrue(dd(v2v(na[3]),geom.Vec3(0,4,0)))
ed.SetAtomTransformedPos([3,99,2], ed.SetAtomTransformedPos([3,99,2],
numpy.array([[0,0,-3],[-1,-1,-1],[0,0,-2]], dtype=numpy.float32)) numpy.array([[0,0,-3],[-1,-1,-1],[0,0,-2]], dtype=numpy.float32))
self.assertTrue(dd(a0.pos,ost.geom.Vec3(0,1,0))) self.assertTrue(dd(a0.pos,geom.Vec3(0,1,0)))
self.assertTrue(dd(a1.pos,ost.geom.Vec3(0,2,0))) self.assertTrue(dd(a1.pos,geom.Vec3(0,2,0)))
self.assertTrue(dd(a2.pos,ost.geom.Vec3(0,0,-2))) self.assertTrue(dd(a2.pos,geom.Vec3(0,0,-2)))
self.assertTrue(dd(a3.pos,ost.geom.Vec3(0,0,-3))) self.assertTrue(dd(a3.pos,geom.Vec3(0,0,-3)))
if __name__== '__main__': if __name__== '__main__':
unittest.main() unittest.main()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment