Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dssp
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
dssp
Commits
e92eb4a7
Unverified
Commit
e92eb4a7
authored
Aug 17, 2022
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename unit-test
parent
0e8aeec8
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
97 additions
and
131 deletions
+97
-131
CMakeLists.txt
+6
-8
test/dssp-test.cpp
+0
-112
test/dssp-unit-test.cpp
+91
-11
No files found.
CMakeLists.txt
View file @
e92eb4a7
...
...
@@ -159,29 +159,27 @@ endif()
# test
add_executable
(
unit-test
${
PROJECT_SOURCE_DIR
}
/test/
unit-test.cpp
${
PROJECT_SOURCE_DIR
}
/src/dssp_wrapper.cpp
)
add_executable
(
dssp-unit-test
${
PROJECT_SOURCE_DIR
}
/test/dssp-
unit-test.cpp
${
PROJECT_SOURCE_DIR
}
/src/dssp_wrapper.cpp
)
if
(
USE_RSRC
)
mrc_target_resources
(
unit-test
${
CIFPP_SHARE_DIR
}
/mmcif_pdbx.dic
)
mrc_target_resources
(
dssp-
unit-test
${
CIFPP_SHARE_DIR
}
/mmcif_pdbx.dic
)
endif
()
target_include_directories
(
unit-test PRIVATE
target_include_directories
(
dssp-
unit-test PRIVATE
${
CMAKE_CURRENT_SOURCE_DIR
}
/src
${
CMAKE_CURRENT_SOURCE_DIR
}
/include
)
target_link_libraries
(
unit-test dssp_library cifpp::cifpp Boost::date_time
)
target_link_libraries
(
dssp-
unit-test dssp_library cifpp::cifpp Boost::date_time
)
if
(
MSVC
)
# Specify unwind semantics so that MSVC knowns how to handle exceptions
target_compile_options
(
unit-test PRIVATE /EHsc
)
target_compile_options
(
dssp-
unit-test PRIVATE /EHsc
)
endif
()
enable_testing
()
add_test
(
NAME unit-test
COMMAND $<TARGET_FILE:unit-test>
WORKING_DIRECTORY
${
CMAKE_SOURCE_DIR
}
/test
)
add_test
(
NAME dssp-unit-test COMMAND $<TARGET_FILE:dssp-unit-test> --
${
PROJECT_SOURCE_DIR
}
/test
)
option
(
DSSP_BUILD_INSTALLER
"Build an installer"
OFF
)
if
(
DSSP_BUILD_INSTALLER
)
...
...
test/dssp-test.cpp
deleted
100644 → 0
View file @
0e8aeec8
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2022 NKI/AVL, Netherlands Cancer Institute
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define BOOST_TEST_ALTERNATIVE_INIT_API
#include <boost/test/included/unit_test.hpp>
#include <charconv>
#include <stdexcept>
#include <cif++/cif.hpp>
#include <cif++/dssp/DSSP.hpp>
namespace
tt
=
boost
::
test_tools
;
std
::
filesystem
::
path
gTestDir
=
std
::
filesystem
::
current_path
();
// filled in first test
// --------------------------------------------------------------------
cif
::
file
operator
""
_cf
(
const
char
*
text
,
size_t
length
)
{
struct
membuf
:
public
std
::
streambuf
{
membuf
(
char
*
text
,
size_t
length
)
{
this
->
setg
(
text
,
text
,
text
+
length
);
}
}
buffer
(
const_cast
<
char
*>
(
text
),
length
);
std
::
istream
is
(
&
buffer
);
return
cif
::
file
(
is
);
}
// --------------------------------------------------------------------
bool
init_unit_test
()
{
cif
::
VERBOSE
=
1
;
// not a test, just initialize test dir
if
(
boost
::
unit_test
::
framework
::
master_test_suite
().
argc
==
2
)
gTestDir
=
boost
::
unit_test
::
framework
::
master_test_suite
().
argv
[
1
];
// do this now, avoids the need for installing
cif
::
add_file_resource
(
"mmcif_pdbx.dic"
,
gTestDir
/
".."
/
"rsrc"
/
"mmcif_pdbx.dic"
);
// initialize CCD location
cif
::
add_file_resource
(
"components.cif"
,
gTestDir
/
".."
/
"data"
/
"ccd-subset.cif"
);
return
true
;
}
// --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE
(
dssp_1
)
{
cif
::
file
f
(
gTestDir
/
"1cbs.cif"
);
BOOST_ASSERT
(
f
.
is_valid
());
std
::
ifstream
t
(
gTestDir
/
"1cbs-dssp-test.tsv"
);
dssp
::
DSSP
dssp
(
f
.
front
(),
1
,
3
,
true
);
for
(
auto
residue
:
dssp
)
{
std
::
string
line
;
getline
(
t
,
line
);
std
::
cout
<<
line
<<
std
::
endl
;
auto
f
=
cif
::
split
(
line
,
"
\t
"
);
BOOST_CHECK_EQUAL
(
f
.
size
(),
3
);
if
(
f
.
size
()
!=
3
)
continue
;
int
seqID
;
std
::
from_chars
(
f
[
0
].
begin
(),
f
[
0
].
end
(),
seqID
);
std
::
string
asymID
{
f
[
1
]
};
std
::
string
secstr
{
f
[
2
]
};
if
(
secstr
==
"_"
)
secstr
=
" "
;
BOOST_CHECK_EQUAL
(
residue
.
asym_id
(),
asymID
);
BOOST_CHECK_EQUAL
(
residue
.
seq_id
(),
seqID
);
BOOST_CHECK_EQUAL
((
char
)
residue
.
type
(),
secstr
.
front
());
}
}
\ No newline at end of file
test/unit-test.cpp
→
test/
dssp-
unit-test.cpp
View file @
e92eb4a7
...
...
@@ -24,17 +24,58 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define BOOST_TEST_MODULE DSSP_Test
#include <boost/test/included/unit_test.hpp>
#include <boost/algorithm/string.hpp>
#include <stdexcept>
#include "DSSP.hpp"
#define BOOST_TEST_ALTERNATIVE_INIT_API
#include <boost/algorithm/string.hpp>
#include <boost/test/included/unit_test.hpp>
#include "DSSP.hpp"
#include "dssp_wrapper.hpp"
namespace
ba
=
boost
::
algorithm
;
namespace
fs
=
std
::
filesystem
;
// --------------------------------------------------------------------
cif
::
file
operator
""
_cf
(
const
char
*
text
,
size_t
length
)
{
struct
membuf
:
public
std
::
streambuf
{
membuf
(
char
*
text
,
size_t
length
)
{
this
->
setg
(
text
,
text
,
text
+
length
);
}
}
buffer
(
const_cast
<
char
*>
(
text
),
length
);
std
::
istream
is
(
&
buffer
);
return
cif
::
file
(
is
);
}
// --------------------------------------------------------------------
fs
::
path
gTestDir
=
fs
::
current_path
();
bool
init_unit_test
()
{
cif
::
VERBOSE
=
1
;
// not a test, just initialize test dir
if
(
boost
::
unit_test
::
framework
::
master_test_suite
().
argc
==
2
)
{
gTestDir
=
boost
::
unit_test
::
framework
::
master_test_suite
().
argv
[
1
];
cif
::
add_data_directory
(
gTestDir
/
".."
/
"rsrc"
);
}
// // do this now, avoids the need for installing
// cif::add_file_resource("mmcif_pdbx.dic", gTestDir / ".." / "rsrc" / "mmcif_pdbx.dic");
// // initialize CCD location
// cif::add_file_resource("components.cif", gTestDir / ".." / "data" / "ccd-subset.cif");
return
true
;
}
// --------------------------------------------------------------------
...
...
@@ -42,7 +83,7 @@ BOOST_AUTO_TEST_CASE(ut_dssp)
{
using
namespace
std
::
literals
;
cif
::
file
f
(
"1cbs.cif.gz"
);
cif
::
file
f
(
gTestDir
/
"1cbs.cif.gz"
);
BOOST_ASSERT
(
f
.
is_valid
());
dssp
::
DSSP
dssp
(
f
.
front
(),
1
,
3
,
true
);
...
...
@@ -51,18 +92,18 @@ BOOST_AUTO_TEST_CASE(ut_dssp)
writeDSSP
(
dssp
,
test
);
std
::
ifstream
reference
(
"1cbs.dssp"
);
std
::
ifstream
reference
(
gTestDir
/
"1cbs.dssp"
);
BOOST_CHECK
(
reference
.
is_open
());
std
::
string
line_t
,
line_r
;
BOOST_CHECK
(
std
::
getline
(
test
,
line_t
)
and
std
::
getline
(
reference
,
line_r
));
const
char
*
kHeaderLineStart
=
"==== Secondary Structure Definition by the program DSSP, NKI version 4.0 ===="
;
const
char
*
kHeaderLineStart
=
"==== Secondary Structure Definition by the program DSSP, NKI version 4.0 ===="
;
BOOST_CHECK
(
line_t
.
compare
(
0
,
std
::
strlen
(
kHeaderLineStart
),
kHeaderLineStart
)
==
0
);
BOOST_CHECK
(
line_r
.
compare
(
0
,
std
::
strlen
(
kHeaderLineStart
),
kHeaderLineStart
)
==
0
);
for
(
int
line_nr
=
2
;
;
++
line_nr
)
for
(
int
line_nr
=
2
;;
++
line_nr
)
{
bool
done_t
=
not
std
::
getline
(
test
,
line_t
);
bool
done_r
=
not
std
::
getline
(
reference
,
line_r
);
...
...
@@ -88,7 +129,7 @@ BOOST_AUTO_TEST_CASE(ut_mmcif_2)
using
namespace
std
::
literals
;
using
namespace
cif
::
literals
;
cif
::
file
f
(
"1cbs.cif.gz"
);
cif
::
file
f
(
gTestDir
/
"1cbs.cif.gz"
);
BOOST_ASSERT
(
f
.
is_valid
());
dssp
::
DSSP
dssp
(
f
.
front
(),
1
,
3
,
true
);
...
...
@@ -97,7 +138,7 @@ BOOST_AUTO_TEST_CASE(ut_mmcif_2)
annotateDSSP
(
f
.
front
(),
dssp
,
true
,
test
);
cif
::
file
rf
(
"1cbs-dssp.cif"
);
cif
::
file
rf
(
gTestDir
/
"1cbs-dssp.cif"
);
// structure.datablock()["software"].erase("name"_key == "dssp");
// rs.datablock()["software"].erase("name"_key == "dssp");
...
...
@@ -107,3 +148,41 @@ BOOST_AUTO_TEST_CASE(ut_mmcif_2)
// BOOST_CHECK(f.front() == rf.front());
}
// --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE
(
dssp_1
)
{
cif
::
file
f
(
gTestDir
/
"1cbs.cif"
);
BOOST_ASSERT
(
f
.
is_valid
());
std
::
ifstream
t
(
gTestDir
/
"1cbs-dssp-test.tsv"
);
dssp
::
DSSP
dssp
(
f
.
front
(),
1
,
3
,
true
);
for
(
auto
residue
:
dssp
)
{
std
::
string
line
;
getline
(
t
,
line
);
std
::
cout
<<
line
<<
std
::
endl
;
auto
f
=
cif
::
split
(
line
,
"
\t
"
);
BOOST_CHECK_EQUAL
(
f
.
size
(),
3
);
if
(
f
.
size
()
!=
3
)
continue
;
int
seqID
;
std
::
from_chars
(
f
[
0
].
begin
(),
f
[
0
].
end
(),
seqID
);
std
::
string
asymID
{
f
[
1
]
};
std
::
string
secstr
{
f
[
2
]
};
if
(
secstr
==
"_"
)
secstr
=
" "
;
BOOST_CHECK_EQUAL
(
residue
.
asym_id
(),
asymID
);
BOOST_CHECK_EQUAL
(
residue
.
seq_id
(),
seqID
);
BOOST_CHECK_EQUAL
((
char
)
residue
.
type
(),
secstr
.
front
());
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment