Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
libcifpp
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
libcifpp
Commits
34bdc505
Unverified
Commit
34bdc505
authored
Feb 20, 2021
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix parsing PDB files containing carriage returns
parent
9402fd5c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
4 deletions
+65
-4
GNUmakefile.in
+2
-2
src/PDB2Cif.cpp
+5
-2
test/pdb2cif-test.cpp
+58
-0
No files found.
GNUmakefile.in
View file @
34bdc505
...
@@ -215,7 +215,7 @@ $(1)_OBJECTS = $$(OBJDIR)/$(1)-test.o
...
@@ -215,7 +215,7 @@ $(1)_OBJECTS = $$(OBJDIR)/$(1)-test.o
test/$(1)-test
:
$(LIB_TARGET) $$($(1)_OBJECTS)
test/$(1)-test
:
$(LIB_TARGET) $$($(1)_OBJECTS)
@
echo
">>> building
$
(1)-test"
@
echo
">>> building
$
(1)-test"
$(CXX)
$(CXXFLAGS)
$(LDFLAGS)
-o
$$
@
$$
(
$
(
1
)
_OBJECTS
)
-L
.libs
-lcifpp
$(LIBS)
$(CXX)
$(CXXFLAGS)
$(LDFLAGS)
-o
$$
@
$$
(
$
(
1
)
_OBJECTS
)
-L
.libs
-lcifpp
-lboost_program_options
$(LIBS)
.PHONY
:
$(1)-test
.PHONY
:
$(1)-test
$(1)-test
:
test/$(1)-test
$(1)-test
:
test/$(1)-test
...
@@ -223,7 +223,7 @@ $(1)-test: test/$(1)-test
...
@@ -223,7 +223,7 @@ $(1)-test: test/$(1)-test
endef
endef
TESTS
=
unit
TESTS
=
unit
pdb2cif
$(foreach
part,$(TESTS),$(eval
$(call
TEST_template,$(part))))
$(foreach
part,$(TESTS),$(eval
$(call
TEST_template,$(part))))
...
...
src/PDB2Cif.cpp
View file @
34bdc505
...
@@ -1124,6 +1124,9 @@ void PDBFileParser::PreParseInput(std::istream& is)
...
@@ -1124,6 +1124,9 @@ void PDBFileParser::PreParseInput(std::istream& is)
uint32_t
lineNr
=
1
;
uint32_t
lineNr
=
1
;
getline
(
is
,
lookahead
);
getline
(
is
,
lookahead
);
if
(
lookahead
.
back
()
==
'\r'
)
lookahead
.
pop_back
();
// if (ba::starts_with(lookahead, "HEADER") == false)
// if (ba::starts_with(lookahead, "HEADER") == false)
// throw std::runtime_error("This does not look like a PDB file, should start with a HEADER line");
// throw std::runtime_error("This does not look like a PDB file, should start with a HEADER line");
...
@@ -1284,7 +1287,7 @@ void PDBFileParser::PreParseInput(std::istream& is)
...
@@ -1284,7 +1287,7 @@ void PDBFileParser::PreParseInput(std::istream& is)
stoi
(
lookahead
.
substr
(
7
,
3
))
==
compNr
and
stoi
(
lookahead
.
substr
(
7
,
3
))
==
compNr
and
contNr
(
16
,
2
)
==
n
)
contNr
(
16
,
2
)
==
n
)
{
{
value
+=
lookahead
.
substr
(
19
)
;
value
+=
ba
::
trim_right_copy
(
lookahead
.
substr
(
19
));
;
getline
(
is
,
lookahead
);
getline
(
is
,
lookahead
);
++
lineNr
;
++
lineNr
;
++
n
;
++
n
;
...
@@ -1308,7 +1311,7 @@ void PDBFileParser::PreParseInput(std::istream& is)
...
@@ -1308,7 +1311,7 @@ void PDBFileParser::PreParseInput(std::istream& is)
int
n
=
2
;
int
n
=
2
;
while
(
lookahead
.
substr
(
0
,
6
)
==
type
and
contNr
(
8
,
2
)
==
n
)
while
(
lookahead
.
substr
(
0
,
6
)
==
type
and
contNr
(
8
,
2
)
==
n
)
{
{
value
+=
lookahead
.
substr
(
16
)
;
value
+=
ba
::
trim_right_copy
(
lookahead
.
substr
(
16
));
;
getline
(
is
,
lookahead
);
getline
(
is
,
lookahead
);
++
lineNr
;
++
lineNr
;
++
n
;
++
n
;
...
...
test/pdb2cif-test.cpp
0 → 100644
View file @
34bdc505
#include "../src/Config.hpp"
#include "../include/cif++/Cif++.hpp"
#include "../include/cif++/PDB2Cif.hpp"
#include <iostream>
#include <fstream>
#include <boost/program_options.hpp>
// #include "pdb2cif.h"
namespace
po
=
boost
::
program_options
;
int
main
(
int
argc
,
char
*
argv
[])
{
using
namespace
std
::
literals
;
po
::
options_description
desc
(
"pdb2cif-test "
s
+
PACKAGE_VERSION
+
" options"
);
desc
.
add_options
()
(
"input,i"
,
po
::
value
<
std
::
string
>
(),
"Input file"
)
(
"help,h"
,
"Display help message"
)
(
"version"
,
"Print version"
)
(
"verbose,v"
,
"Verbose output"
)
(
"debug,d"
,
po
::
value
<
int
>
(),
"Debug level (for even more verbose output)"
);
po
::
positional_options_description
p
;
p
.
add
(
"input"
,
1
);
po
::
variables_map
vm
;
po
::
store
(
po
::
command_line_parser
(
argc
,
argv
).
options
(
desc
).
positional
(
p
).
run
(),
vm
);
po
::
notify
(
vm
);
if
(
vm
.
count
(
"version"
))
{
std
::
cout
<<
argv
[
0
]
<<
" version "
PACKAGE_VERSION
<<
std
::
endl
;
exit
(
0
);
}
if
(
vm
.
count
(
"help"
)
or
vm
.
count
(
"input"
)
==
0
)
{
std
::
cerr
<<
desc
<<
std
::
endl
;
exit
(
1
);
}
cif
::
VERBOSE
=
vm
.
count
(
"verbose"
)
!=
0
;
if
(
vm
.
count
(
"debug"
))
cif
::
VERBOSE
=
vm
[
"debug"
].
as
<
int
>
();
std
::
ifstream
is
(
vm
[
"input"
].
as
<
std
::
string
>
());
if
(
not
is
.
is_open
())
throw
std
::
runtime_error
(
"Could not open file "
+
vm
[
"input"
].
as
<
std
::
string
>
());
cif
::
File
f
;
ReadPDBFile
(
is
,
f
);
// f.write(std::cout);
return
0
;
}
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