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
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
25 deletions
+41
-25
include/cif++/model.hpp
+7
-1
src/file.cpp
+2
-2
src/pdb/cif2pdb.cpp
+7
-6
src/pdb/pdb2cif.cpp
+19
-12
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
...
@@ -608,7 +608,13 @@ class sugar : public residue
sugar
(
sugar
&&
rhs
);
sugar
(
sugar
&&
rhs
);
sugar
&
operator
=
(
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
;
std
::
string
name
()
const
;
/// \brief Return the atom the C1 is linked to
/// \brief Return the atom the C1 is linked to
...
...
src/file.cpp
View file @
cc671b80
...
@@ -115,8 +115,8 @@ void file::load_dictionary()
...
@@ -115,8 +115,8 @@ void file::load_dictionary()
}
}
}
}
if
(
not
m_validator
)
//
if (not m_validator)
load_dictionary
(
"mmcif_pdbx.dic"
);
// TODO: maybe incorrect? Perhaps improve?
//
load_dictionary("mmcif_pdbx.dic"); // TODO: maybe incorrect? Perhaps improve?
}
}
void
file
::
load_dictionary
(
std
::
string_view
name
)
void
file
::
load_dictionary
(
std
::
string_view
name
)
...
...
src/pdb/cif2pdb.cpp
View file @
cc671b80
...
@@ -704,16 +704,17 @@ class Ff : public FBase
...
@@ -704,16 +704,17 @@ class Ff : public FBase
else
else
{
{
std
::
string
s
{
text
()
};
std
::
string
s
{
text
()
};
try
{
double
d
=
0
;
os
<<
std
::
stod
(
s
);
auto
r
=
cif
::
from_chars
(
s
.
data
(),
s
.
data
()
+
s
.
length
(),
d
);
}
if
(
r
.
ec
!=
std
::
errc
())
catch
(
const
std
::
exception
&
ex
)
{
{
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
;
std
::
cerr
<<
"Failed to write '"
<<
s
<<
"' as a double, this indicates an error in the code for writing PDB files"
<<
std
::
endl
;
os
<<
s
;
os
<<
s
;
}
}
else
os
<<
d
;
}
}
}
}
};
};
...
...
src/pdb/pdb2cif.cpp
View file @
cc671b80
...
@@ -1136,16 +1136,15 @@ void PDBFileParser::PreParseInput(std::istream &is)
...
@@ -1136,16 +1136,15 @@ void PDBFileParser::PreParseInput(std::istream &is)
{
{
std
::
string
cs
=
lookahead
.
substr
(
offset
,
len
);
std
::
string
cs
=
lookahead
.
substr
(
offset
,
len
);
cif
::
trim
(
cs
);
cif
::
trim
(
cs
);
int
result
;
int
result
=
0
;
try
if
(
not
cs
.
empty
())
{
result
=
cs
.
empty
()
?
0
:
stoi
(
cs
);
}
catch
(...)
{
{
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"
);
throw
std
::
runtime_error
(
"Continuation std::string '"
+
cs
+
"' is not valid"
);
}
}
return
result
;
return
result
;
};
};
...
@@ -1402,7 +1401,12 @@ void PDBFileParser::PreParseInput(std::istream &is)
...
@@ -1402,7 +1401,12 @@ void PDBFileParser::PreParseInput(std::istream &is)
link
.
symOpB
=
cur
->
vS
(
67
,
72
);
// 67 - 72 SymOP sym2 Symmetry operator atom 2.
link
.
symOpB
=
cur
->
vS
(
67
,
72
);
// 67 - 72 SymOP sym2 Symmetry operator atom 2.
if
(
type
==
"LINK"
)
// 1 - 6 Record name "LINK "
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
// 74 – 78 Real(5.2) Length Link distance
mLinks
.
push_back
(
link
);
mLinks
.
push_back
(
link
);
...
@@ -5107,11 +5111,10 @@ void PDBFileParser::ParseConnectivtyAnnotation()
...
@@ -5107,11 +5111,10 @@ void PDBFileParser::ParseConnectivtyAnnotation()
if
(
mRec
->
is
(
"LINK "
))
if
(
mRec
->
is
(
"LINK "
))
{
{
distance
=
vS
(
74
,
78
);
distance
=
vS
(
74
,
78
);
try
{
double
d
;
stod
(
distance
);
auto
r
=
cif
::
from_chars
(
distance
.
data
(),
distance
.
data
()
+
distance
.
length
(),
d
);
}
if
(
r
.
ec
!=
std
::
errc
())
catch
(
const
std
::
invalid_argument
&
)
{
{
if
(
cif
::
VERBOSE
>
0
)
if
(
cif
::
VERBOSE
>
0
)
std
::
cerr
<<
"Distance value '"
<<
distance
<<
"' is not a valid float in LINK record"
<<
std
::
endl
;
std
::
cerr
<<
"Distance value '"
<<
distance
<<
"' is not a valid float in LINK record"
<<
std
::
endl
;
...
@@ -6211,6 +6214,10 @@ file read(std::istream &is)
...
@@ -6211,6 +6214,10 @@ file read(std::istream &is)
result
.
load
(
is
);
result
.
load
(
is
);
}
}
// Must be a PDB like file, right?
if
(
result
.
get_validator
()
==
nullptr
)
result
.
load_dictionary
(
"mmcif_pdbx.dic"
);
return
result
;
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
...
@@ -1207,13 +1207,15 @@ void Remark3Parser::storeCapture(const char *category, std::initializer_list<con
}
}
else
if
(
iequals
(
category
,
"pdbx_refine_tls_group"
))
else
if
(
iequals
(
category
,
"pdbx_refine_tls_group"
))
{
{
std
::
string
tls
Group
ID
;
std
::
string
tlsID
;
if
(
not
mDb
[
"pdbx_refine_tls"
].
empty
())
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
},
{
"id"
,
tlsGroupID
},
{
"refine_tls_id"
,
tls
Group
ID
}
});
{
"refine_tls_id"
,
tlsID
}
});
}
}
else
if
(
iequals
(
category
,
"pdbx_refine_tls"
))
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