Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openstructure
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
schwede
openstructure
Commits
b5ddb1e5
Commit
b5ddb1e5
authored
14 years ago
by
Tobias Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
sdf reader complains if file cannot be opened
parent
e708cb1f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
modules/io/src/mol/sdf_reader.cc
+12
-8
12 additions, 8 deletions
modules/io/src/mol/sdf_reader.cc
modules/io/src/mol/sdf_reader.hh
+1
-1
1 addition, 1 deletion
modules/io/src/mol/sdf_reader.hh
modules/io/tests/test_io_sdf.cc
+7
-0
7 additions, 0 deletions
modules/io/tests/test_io_sdf.cc
with
20 additions
and
9 deletions
modules/io/src/mol/sdf_reader.cc
+
12
−
8
View file @
b5ddb1e5
...
...
@@ -36,18 +36,21 @@ namespace ost { namespace io {
using
boost
::
format
;
SDFReader
::
SDFReader
(
const
String
&
filename
)
:
infile_
(
filename
),
instream_
(
infile_
)
{
this
->
ClearState
();
:
infile_
(
filename
),
instream_
(
infile_
)
{
this
->
ClearState
(
boost
::
filesystem
::
path
(
filename
));
}
SDFReader
::
SDFReader
(
const
boost
::
filesystem
::
path
&
loc
)
:
infile_
(
loc
),
instream_
(
infile_
)
{
this
->
ClearState
();
:
infile_
(
loc
),
instream_
(
infile_
)
{
this
->
ClearState
(
loc
);
}
SDFReader
::
SDFReader
(
std
::
istream
&
instream
)
:
infile_
(),
instream_
(
instream
)
{
this
->
ClearState
();
:
infile_
(),
instream_
(
instream
)
{
this
->
ClearState
(
boost
::
filesystem
::
path
(
""
));
}
// import data from provided stream
...
...
@@ -82,7 +85,7 @@ void SDFReader::Import(mol::EntityHandle& ent)
}
curr_chain_
.
SetStringProp
(
data_header
,
data_value
);
}
else
if
(
boost
::
iequals
(
line
,
"$$$$"
))
{
LOG_
INFO
(
"MOLECULE "
<<
curr_chain_
.
GetName
()
<<
" ("
<<
chain_count_
<<
") added."
)
LOG_
VERBOSE
(
"MOLECULE "
<<
curr_chain_
.
GetName
()
<<
" ("
<<
chain_count_
<<
") added."
)
NextMolecule
();
}
}
...
...
@@ -91,8 +94,9 @@ void SDFReader::Import(mol::EntityHandle& ent)
<<
" residues, "
<<
atom_count_
<<
" atoms"
);
}
void
SDFReader
::
ClearState
()
void
SDFReader
::
ClearState
(
const
boost
::
filesystem
::
path
&
loc
)
{
if
(
!
infile_
)
throw
IOException
(
"could not open "
+
loc
.
string
());
curr_chain_
=
mol
::
ChainHandle
();
curr_residue_
=
mol
::
ResidueHandle
();
chain_count_
=
0
;
...
...
This diff is collapsed.
Click to expand it.
modules/io/src/mol/sdf_reader.hh
+
1
−
1
View file @
b5ddb1e5
...
...
@@ -39,7 +39,7 @@ public:
void
Import
(
mol
::
EntityHandle
&
ent
);
private:
void
ClearState
();
void
ClearState
(
const
boost
::
filesystem
::
path
&
loc
);
void
NextMolecule
();
void
ParseAndAddHeader
(
const
String
&
line
,
int
line_num
,
mol
::
EntityHandle
&
ent
,
...
...
This diff is collapsed.
Click to expand it.
modules/io/tests/test_io_sdf.cc
+
7
−
0
View file @
b5ddb1e5
...
...
@@ -151,6 +151,13 @@ BOOST_AUTO_TEST_CASE(write_sdf)
"testfiles/sdf/compound-out.sdf"
));
}
BOOST_AUTO_TEST_CASE
(
nonexisting_file
)
{
mol
::
EntityHandle
eh
=
mol
::
CreateEntity
();
EntityIOSDFHandler
sdfh
;
BOOST_CHECK_THROW
(
sdfh
.
Import
(
eh
,
"non-existing-file.sdf"
),
IOException
);
}
BOOST_AUTO_TEST_CASE
(
wrong_atomcount_error_sdf
)
{
mol
::
EntityHandle
eh
=
mol
::
CreateEntity
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment