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
0fecfca9
Commit
0fecfca9
authored
13 years ago
by
Marco Biasini
Browse files
Options
Downloads
Patches
Plain Diff
check for end of file more often
parent
a978edb0
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/io/src/mol/dcd_io.cc
+22
-8
22 additions, 8 deletions
modules/io/src/mol/dcd_io.cc
with
22 additions
and
8 deletions
modules/io/src/mol/dcd_io.cc
+
22
−
8
View file @
0fecfca9
...
@@ -153,7 +153,7 @@ bool read_frame(std::istream& istream, const DCDHeader& header,
...
@@ -153,7 +153,7 @@ bool read_frame(std::istream& istream, const DCDHeader& header,
if
(
!
istream
)
{
if
(
!
istream
)
{
/* premature EOF */
/* premature EOF */
LOG_ERROR
(
"LoadCHARMMTraj: premature end of file while trying to read frame "
LOG_ERROR
(
"LoadCHARMMTraj: premature end of file while trying to read frame "
<<
frame_num
);
<<
frame_num
<<
"Nothing left to be read"
);
return
false
;
return
false
;
}
}
// x coord
// x coord
...
@@ -164,7 +164,12 @@ bool read_frame(std::istream& istream, const DCDHeader& header,
...
@@ -164,7 +164,12 @@ bool read_frame(std::istream& istream, const DCDHeader& header,
for
(
uint
j
=
0
;
j
<
frame
.
size
();
++
j
)
{
for
(
uint
j
=
0
;
j
<
frame
.
size
();
++
j
)
{
frame
[
j
].
x
=
xlist
[
j
];
frame
[
j
].
x
=
xlist
[
j
];
}
}
if
(
!
istream
)
{
/* premature EOF */
LOG_ERROR
(
"LoadCHARMMTraj: premature end of file while trying to read frame "
<<
frame_num
<<
". No y coordinates"
);
return
false
;
}
// y coord
// y coord
if
(
gap_flag
)
istream
.
read
(
dummy
,
sizeof
(
dummy
));
if
(
gap_flag
)
istream
.
read
(
dummy
,
sizeof
(
dummy
));
istream
.
read
(
reinterpret_cast
<
char
*>
(
&
xlist
[
0
]),
sizeof
(
float
)
*
xlist
.
size
());
istream
.
read
(
reinterpret_cast
<
char
*>
(
&
xlist
[
0
]),
sizeof
(
float
)
*
xlist
.
size
());
...
@@ -173,7 +178,12 @@ bool read_frame(std::istream& istream, const DCDHeader& header,
...
@@ -173,7 +178,12 @@ bool read_frame(std::istream& istream, const DCDHeader& header,
for
(
uint
j
=
0
;
j
<
frame
.
size
();
++
j
)
{
for
(
uint
j
=
0
;
j
<
frame
.
size
();
++
j
)
{
frame
[
j
].
y
=
xlist
[
j
];
frame
[
j
].
y
=
xlist
[
j
];
}
}
if
(
!
istream
)
{
/* premature EOF */
LOG_ERROR
(
"LoadCHARMMTraj: premature end of file while trying to read frame "
<<
frame_num
<<
". No z coordinates"
);
return
false
;
}
// z coord
// z coord
if
(
gap_flag
)
istream
.
read
(
dummy
,
sizeof
(
dummy
));
if
(
gap_flag
)
istream
.
read
(
dummy
,
sizeof
(
dummy
));
istream
.
read
(
reinterpret_cast
<
char
*>
(
&
xlist
[
0
]),
sizeof
(
float
)
*
xlist
.
size
());
istream
.
read
(
reinterpret_cast
<
char
*>
(
&
xlist
[
0
]),
sizeof
(
float
)
*
xlist
.
size
());
...
@@ -182,6 +192,12 @@ bool read_frame(std::istream& istream, const DCDHeader& header,
...
@@ -182,6 +192,12 @@ bool read_frame(std::istream& istream, const DCDHeader& header,
for
(
uint
j
=
0
;
j
<
frame
.
size
();
++
j
)
{
for
(
uint
j
=
0
;
j
<
frame
.
size
();
++
j
)
{
frame
[
j
].
z
=
xlist
[
j
];
frame
[
j
].
z
=
xlist
[
j
];
}
}
if
(
!
istream
)
{
/* premature EOF */
LOG_ERROR
(
"LoadCHARMMTraj: premature end of file while trying to read frame "
<<
frame_num
);
return
false
;
}
return
true
;
return
true
;
}
}
...
@@ -201,10 +217,6 @@ mol::CoordGroupHandle load_dcd(const mol::AtomHandleList& alist, // this atom li
...
@@ -201,10 +217,6 @@ mol::CoordGroupHandle load_dcd(const mol::AtomHandleList& alist, // this atom li
DCDHeader
header
;
DCDHeader
header
;
bool
swap_flag
=
false
,
skip_flag
=
false
,
gap_flag
=
false
;
bool
swap_flag
=
false
,
skip_flag
=
false
,
gap_flag
=
false
;
read_dcd_header
(
istream
,
header
,
swap_flag
,
skip_flag
,
gap_flag
);
read_dcd_header
(
istream
,
header
,
swap_flag
,
skip_flag
,
gap_flag
);
LOG_DEBUG
(
"LoadCHARMMTraj: "
<<
header
.
num
<<
" trajectories with "
<<
header
.
atom_count
<<
" atoms ("
<<
header
.
f_atom_count
<<
" fixed) each"
);
if
(
alist
.
size
()
!=
static_cast
<
size_t
>
(
header
.
t_atom_count
))
{
if
(
alist
.
size
()
!=
static_cast
<
size_t
>
(
header
.
t_atom_count
))
{
LOG_ERROR
(
"LoadCHARMMTraj: atom count missmatch: "
<<
alist
.
size
()
LOG_ERROR
(
"LoadCHARMMTraj: atom count missmatch: "
<<
alist
.
size
()
<<
" in coordinate file, "
<<
header
.
t_atom_count
<<
" in coordinate file, "
<<
header
.
t_atom_count
...
@@ -218,6 +230,7 @@ mol::CoordGroupHandle load_dcd(const mol::AtomHandleList& alist, // this atom li
...
@@ -218,6 +230,7 @@ mol::CoordGroupHandle load_dcd(const mol::AtomHandleList& alist, // this atom li
size_t
frame_size
=
calc_frame_size
(
skip_flag
,
gap_flag
,
xlist
.
size
());
size_t
frame_size
=
calc_frame_size
(
skip_flag
,
gap_flag
,
xlist
.
size
());
int
i
=
0
;
int
i
=
0
;
for
(;
i
<
header
.
num
;
i
+=
stride
)
{
for
(;
i
<
header
.
num
;
i
+=
stride
)
{
std
::
cout
<<
i
<<
" "
<<
header
.
num
<<
std
::
endl
;
if
(
!
read_frame
(
istream
,
header
,
frame_size
,
skip_flag
,
gap_flag
,
if
(
!
read_frame
(
istream
,
header
,
frame_size
,
skip_flag
,
gap_flag
,
swap_flag
,
xlist
,
clist
,
i
))
{
swap_flag
,
xlist
,
clist
,
i
))
{
break
;
break
;
...
@@ -234,7 +247,8 @@ mol::CoordGroupHandle load_dcd(const mol::AtomHandleList& alist, // this atom li
...
@@ -234,7 +247,8 @@ mol::CoordGroupHandle load_dcd(const mol::AtomHandleList& alist, // this atom li
<<
istream
.
tellg
());
<<
istream
.
tellg
());
}
}
LOG_VERBOSE
(
"Loaded "
<<
cg
.
GetFrameCount
()
<<
" frames with "
<<
cg
.
GetAtomCount
()
<<
" atoms each"
);
LOG_VERBOSE
(
"Loaded "
<<
cg
.
GetFrameCount
()
<<
" frames with "
<<
cg
.
GetAtomCount
()
<<
" atoms each"
);
return
cg
;
return
cg
;
}
}
...
...
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