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
cc671b80
Unverified
Commit
cc671b80
authored
Nov 01, 2022
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes in numeric conversions
parent
96a67b23
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
26 deletions
+42
-26
include/cif++/model.hpp
+7
-1
src/file.cpp
+2
-2
src/pdb/cif2pdb.cpp
+7
-6
src/pdb/pdb2cif.cpp
+20
-13
src/pdb/pdb2cif_remark_3.cpp
+6
-4
No files found.
include/cif++/model.hpp
View file @
cc671b80
...
...
@@ -608,7 +608,13 @@ class sugar : public residue
sugar
(
sugar
&&
rhs
);
sugar
&
operator
=
(
sugar
&&
rhs
);
int
num
()
const
{
return
std
::
stoi
(
m_auth_seq_id
);
}
int
num
()
const
{
int
result
;
auto
r
=
std
::
from_chars
(
m_auth_seq_id
.
data
(),
m_auth_seq_id
.
data
()
+
m_auth_seq_id
.
length
(),
result
);
if
(
r
.
ec
!=
std
::
errc
())
throw
std
::
runtime_error
(
"The auth_seq_id should be a number for a sugar"
);
return
result
;
}
std
::
string
name
()
const
;
/// \brief Return the atom the C1 is linked to
...
...
src/file.cpp
View file @
cc671b80
...
...
@@ -115,8 +115,8 @@ void file::load_dictionary()
}
}
if
(
not
m_validator
)
load_dictionary
(
"mmcif_pdbx.dic"
);
// TODO: maybe incorrect? Perhaps improve?
//
if (not m_validator)
//
load_dictionary("mmcif_pdbx.dic"); // TODO: maybe incorrect? Perhaps improve?
}
void
file
::
load_dictionary
(
std
::
string_view
name
)
...
...
src/pdb/cif2pdb.cpp
View file @
cc671b80
...
...
@@ -704,16 +704,17 @@ class Ff : public FBase
else
{
std
::
string
s
{
text
()
};
try
{
os
<<
std
::
stod
(
s
);
}
catch
(
const
std
::
exception
&
ex
)
double
d
=
0
;
auto
r
=
cif
::
from_chars
(
s
.
data
(),
s
.
data
()
+
s
.
length
(),
d
);
if
(
r
.
ec
!=
std
::
errc
())
{
if
(
VERBOSE
>
=
0
)
if
(
VERBOSE
>
0
)
std
::
cerr
<<
"Failed to write '"
<<
s
<<
"' as a double, this indicates an error in the code for writing PDB files"
<<
std
::
endl
;
os
<<
s
;
}
else
os
<<
d
;
}
}
};
...
...
src/pdb/pdb2cif.cpp
View file @
cc671b80
...
...
@@ -1136,16 +1136,15 @@ void PDBFileParser::PreParseInput(std::istream &is)
{
std
::
string
cs
=
lookahead
.
substr
(
offset
,
len
);
cif
::
trim
(
cs
);
int
result
;
int
result
=
0
;
try
{
result
=
cs
.
empty
()
?
0
:
stoi
(
cs
);
}
catch
(...)
if
(
not
cs
.
empty
())
{
throw
std
::
runtime_error
(
"Continuation std::string '"
+
cs
+
"' is not valid"
);
auto
r
=
std
::
from_chars
(
cs
.
data
(),
cs
.
data
()
+
cs
.
length
(),
result
);
if
(
r
.
ec
!=
std
::
errc
())
throw
std
::
runtime_error
(
"Continuation std::string '"
+
cs
+
"' is not valid"
);
}
return
result
;
};
...
...
@@ -1402,7 +1401,12 @@ void PDBFileParser::PreParseInput(std::istream &is)
link
.
symOpB
=
cur
->
vS
(
67
,
72
);
// 67 - 72 SymOP sym2 Symmetry operator atom 2.
if
(
type
==
"LINK"
)
// 1 - 6 Record name "LINK "
link
.
distance
=
std
::
stof
(
cur
->
vF
(
74
,
78
));
{
auto
f
=
cur
->
vF
(
74
,
78
);
auto
r
=
cif
::
from_chars
(
f
.
data
(),
f
.
data
()
+
f
.
length
(),
link
.
distance
);
if
(
r
.
ec
!=
std
::
errc
()
and
cif
::
VERBOSE
>
0
)
std
::
cerr
<<
"Error parsing link distance at line "
<<
cur
->
mLineNr
<<
std
::
endl
;
}
// 74 – 78 Real(5.2) Length Link distance
mLinks
.
push_back
(
link
);
...
...
@@ -5107,11 +5111,10 @@ void PDBFileParser::ParseConnectivtyAnnotation()
if
(
mRec
->
is
(
"LINK "
))
{
distance
=
vS
(
74
,
78
);
try
{
stod
(
distance
);
}
catch
(
const
std
::
invalid_argument
&
)
double
d
;
auto
r
=
cif
::
from_chars
(
distance
.
data
(),
distance
.
data
()
+
distance
.
length
(),
d
);
if
(
r
.
ec
!=
std
::
errc
())
{
if
(
cif
::
VERBOSE
>
0
)
std
::
cerr
<<
"Distance value '"
<<
distance
<<
"' is not a valid float in LINK record"
<<
std
::
endl
;
...
...
@@ -6211,6 +6214,10 @@ file read(std::istream &is)
result
.
load
(
is
);
}
// Must be a PDB like file, right?
if
(
result
.
get_validator
()
==
nullptr
)
result
.
load_dictionary
(
"mmcif_pdbx.dic"
);
return
result
;
}
...
...
src/pdb/pdb2cif_remark_3.cpp
View file @
cc671b80
...
...
@@ -1207,13 +1207,15 @@ void Remark3Parser::storeCapture(const char *category, std::initializer_list<con
}
else
if
(
iequals
(
category
,
"pdbx_refine_tls_group"
))
{
std
::
string
tls
Group
ID
;
std
::
string
tlsID
;
if
(
not
mDb
[
"pdbx_refine_tls"
].
empty
())
tlsGroupID
=
mDb
[
"pdbx_refine_tls"
].
back
()[
"id"
].
as
<
std
::
string
>
();
tlsID
=
mDb
[
"pdbx_refine_tls"
].
back
()[
"id"
].
as
<
std
::
string
>
();
std
::
string
tlsGroupID
=
cat
.
get_unique_id
(
""
);
cat
.
emplace
({
{
"pdbx_refine_id"
,
mExpMethod
},
cat
.
emplace
({
{
"pdbx_refine_id"
,
mExpMethod
},
{
"id"
,
tlsGroupID
},
{
"refine_tls_id"
,
tls
Group
ID
}
});
{
"refine_tls_id"
,
tlsID
}
});
}
else
if
(
iequals
(
category
,
"pdbx_refine_tls"
))
{
...
...
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