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
2d3c4594
Commit
2d3c4594
authored
5 years ago
by
Gerardo Tauriello
Browse files
Options
Downloads
Patches
Plain Diff
SCHWED-4368: Extend MMCifInfo to handle revision version numbers.
parent
85ca368f
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/doc/mmcif.rst
+32
-2
32 additions, 2 deletions
modules/io/doc/mmcif.rst
modules/io/src/mol/mmcif_info.hh
+27
-48
27 additions, 48 deletions
modules/io/src/mol/mmcif_info.hh
modules/io/tests/test_mmcif_info.cc
+15
-4
15 additions, 4 deletions
modules/io/tests/test_mmcif_info.cc
with
74 additions
and
54 deletions
modules/io/doc/mmcif.rst
+
32
−
2
View file @
2d3c4594
...
...
@@ -281,7 +281,7 @@ of the annotation available.
:type cif_chain_id: :class:`str`
:returns: atom_site.label_entity_id as :class:`str` (empty if no mapping)
.. method:: AddRevision(num, date, status)
.. method:: AddRevision(num, date, status
, major=-1, minor=-1
)
Add a new iteration to the revision history.
See :meth:`MMCifInfoRevisions.AddRevision`.
...
...
@@ -1089,7 +1089,7 @@ of the annotation available.
:type: :class:`int`
.. method:: AddRevision(num, date, status)
.. method:: AddRevision(num, date, status
, major=-1, minor=-1
)
Add a new iteration to the history.
...
...
@@ -1099,6 +1099,10 @@ of the annotation available.
:type date: :class:`str`
:param status: See :meth:`GetStatus`
:type status: :class:`str`
:param major: See :meth:`GetMajor`
:type major: :class:`int`
:param minor: See :meth:`GetMinor`
:type minor: :class:`int`
:raises: Exception if *num* is <= the last added iteration.
...
...
@@ -1131,11 +1135,37 @@ of the annotation available.
:rtype: :class:`str`
:raises: Exception if *i* out of bounds.
.. method:: GetMajor(i)
:param i: Index of revision
:type i: :class:`int`
:return: The major version of this revision (-1 if not set).
:rtype: :class:`int`
:raises: Exception if *i* out of bounds.
.. method:: GetMinor(i)
:param i: Index of revision
:type i: :class:`int`
:return: The minor version of this revision (-1 if not set).
:rtype: :class:`int`
:raises: Exception if *i* out of bounds.
.. method:: GetLastDate()
:return: Date of the latest revision ('?' if no revision set).
:rtype: :class:`str`
.. method:: GetLastMajor()
:return: Major version of the latest revision (-1 if not set).
:rtype: :class:`int`
.. method:: GetLastMinor()
:return: Minor version of the latest revision (-1 if not set).
:rtype: :class:`int`
.. method:: SetDateOriginal(date)
GetDateOriginal()
...
...
This diff is collapsed.
Click to expand it.
modules/io/src/mol/mmcif_info.hh
+
27
−
48
View file @
2d3c4594
...
...
@@ -760,28 +760,19 @@ private:
};
/// \brief Container class for information on file revisions
///
///
See Python doc
class
DLLEXPORT_OST_IO
MMCifInfoRevisions
{
public:
/// \brief Start recording a revision process.
MMCifInfoRevisions
()
:
date_original_
(
"?"
),
first_release_
(
0
)
{};
/// \brief Set date the entry entered PDB.
///
/// \param date
// original depositon date
void
SetDateOriginal
(
String
date
)
{
date_original_
=
date
;
}
/// \brief Get date the entry entered PDB.
///
/// \return date
String
GetDateOriginal
()
const
{
return
date_original_
;
}
/// \brief Add a revision to history
///
/// \param num unique identifier
/// \param date date of revision
/// \param status status of the revision
void
AddRevision
(
int
num
,
String
date
,
String
status
)
// revision history
void
AddRevision
(
int
num
,
String
date
,
String
status
,
int
major
=
-
1
,
int
minor
=
-
1
)
{
if
(
num_
.
size
()
&&
(
num_
.
back
()
>=
num
))
{
std
::
stringstream
ss
;
...
...
@@ -792,6 +783,8 @@ public:
num_
.
push_back
(
num
);
date_
.
push_back
(
date
);
status_
.
push_back
(
status
);
major_
.
push_back
(
major
);
minor_
.
push_back
(
minor
);
// set first release date if not already occupied
if
(
first_release_
==
0
)
{
if
(
status
==
"full release"
||
status
==
"Initial release"
)
{
...
...
@@ -800,51 +793,39 @@ public:
}
}
/// \brief Get number of revisions stored.
///
/// \return number
// revision history getters
size_t
GetSize
()
const
{
return
num_
.
size
();
}
/// \brief Get revision date by index in list.
///
/// \param i position in list
/// \return date
String
GetDate
(
size_t
i
)
const
{
return
date_
.
at
(
i
);
}
/// \brief Get revision num by index in list.
///
/// \param i position in list
/// \return num
int
GetNum
(
size_t
i
)
const
{
return
num_
.
at
(
i
);
}
/// \brief Get revision status by index in list.
///
/// \param i position in list
/// \return status
String
GetStatus
(
size_t
i
)
const
{
return
status_
.
at
(
i
);
}
int
GetMajor
(
size_t
i
)
const
{
return
major_
.
at
(
i
);
}
int
GetMinor
(
size_t
i
)
const
{
return
minor_
.
at
(
i
);
}
/// \brief Get date of last revision.
///
/// \return date
// get info of first and last revision
String
GetLastDate
()
const
{
if
(
date_
.
empty
())
return
"?"
;
else
return
date_
.
back
();
}
/// \brief Get the index of the full release revision.
///
/// \return index
size_t
GetFirstRelease
()
const
{
int
GetLastMajor
()
const
{
if
(
major_
.
empty
())
return
-
1
;
else
return
major_
.
back
();
}
int
GetLastMinor
()
const
{
if
(
minor_
.
empty
())
return
-
1
;
else
return
minor_
.
back
();
}
size_t
GetFirstRelease
()
const
{
return
first_release_
;
}
private
:
String
date_original_
;
///< first time seen in PDB
size_t
first_release_
;
///< index of full release revision
size_t
first_release_
;
///< index of full release revision
std
::
vector
<
int
>
num_
;
///< sequential id of revision (gets larger)
std
::
vector
<
String
>
date_
;
///< date of revision
std
::
vector
<
String
>
status_
;
///< ststus phrase for this revision
std
::
vector
<
int
>
major_
;
///< major version of revision
std
::
vector
<
int
>
minor_
;
///< minor version of revision
};
...
...
@@ -1131,13 +1112,11 @@ public:
}
/// \brief Add a revision to history
///
/// \param num unique identifier
/// \param date date of revision
/// \param status status of the revision
void
AddRevision
(
int
num
,
String
date
,
String
status
)
/// \see MMCifInfoRevisions::AddRevision
void
AddRevision
(
int
num
,
String
date
,
String
status
,
int
major
=
-
1
,
int
minor
=
-
1
)
{
revisions_
.
AddRevision
(
num
,
date
,
status
);
revisions_
.
AddRevision
(
num
,
date
,
status
,
major
,
minor
);
}
/// \brief Get history
...
...
This diff is collapsed.
Click to expand it.
modules/io/tests/test_mmcif_info.cc
+
15
−
4
View file @
2d3c4594
...
...
@@ -243,26 +243,37 @@ BOOST_AUTO_TEST_CASE(mmcif_info_revisions)
BOOST_CHECK
(
rev
.
GetFirstRelease
()
==
0
);
BOOST_CHECK
(
rev
.
GetSize
()
==
0
);
BOOST_CHECK
(
rev
.
GetLastDate
()
==
"?"
);
BOOST_CHECK
(
rev
.
GetLastMajor
()
==
-
1
);
BOOST_CHECK
(
rev
.
GetLastMinor
()
==
-
1
);
BOOST_CHECK_THROW
(
rev
.
GetDate
(
0
),
std
::
out_of_range
);
BOOST_CHECK_THROW
(
rev
.
GetNum
(
0
),
std
::
out_of_range
);
BOOST_CHECK_THROW
(
rev
.
GetStatus
(
0
),
std
::
out_of_range
);
rev
.
SetDateOriginal
(
"2012-05-0
4
"
);
rev
.
SetDateOriginal
(
"2012-05-0
3
"
);
rev
.
AddRevision
(
1
,
"2012-05-04"
,
"in preparation"
);
rev
.
AddRevision
(
2
,
"2012-05-05"
,
"full release"
);
rev
.
AddRevision
(
2
,
"2012-05-05"
,
"full release"
,
1
,
2
);
BOOST_CHECK
(
rev
.
GetSize
()
==
2
);
BOOST_CHECK
(
rev
.
GetDateOriginal
()
==
"2012-05-0
4
"
);
BOOST_CHECK
(
rev
.
GetDateOriginal
()
==
"2012-05-0
3
"
);
BOOST_CHECK
(
rev
.
GetDate
(
0
)
==
"2012-05-04"
);
BOOST_CHECK
(
rev
.
GetNum
(
0
)
==
1
);
BOOST_CHECK
(
rev
.
GetStatus
(
0
)
==
"in preparation"
);
BOOST_CHECK
(
rev
.
GetMajor
(
0
)
==
-
1
);
BOOST_CHECK
(
rev
.
GetMinor
(
0
)
==
-
1
);
BOOST_CHECK
(
rev
.
GetDate
(
1
)
==
"2012-05-05"
);
BOOST_CHECK
(
rev
.
GetDate
(
1
)
==
rev
.
GetLastDate
());
BOOST_CHECK
(
rev
.
GetFirstRelease
()
==
2
);
BOOST_CHECK
(
rev
.
GetNum
(
1
)
==
2
);
BOOST_CHECK
(
rev
.
GetStatus
(
1
)
==
"full release"
);
BOOST_CHECK
(
rev
.
GetStatus
(
1
)
==
"full release"
);
BOOST_CHECK
(
rev
.
GetMajor
(
1
)
==
1
);
BOOST_CHECK
(
rev
.
GetMinor
(
1
)
==
2
);
BOOST_CHECK
(
rev
.
GetMajor
(
1
)
==
rev
.
GetLastMajor
());
BOOST_CHECK
(
rev
.
GetMinor
(
1
)
==
rev
.
GetLastMinor
());
BOOST_CHECK_THROW
(
rev
.
GetDate
(
2
),
std
::
out_of_range
);
BOOST_CHECK_THROW
(
rev
.
GetNum
(
2
),
std
::
out_of_range
);
BOOST_CHECK_THROW
(
rev
.
GetStatus
(
2
),
std
::
out_of_range
);
BOOST_CHECK_THROW
(
rev
.
GetMajor
(
2
),
std
::
out_of_range
);
BOOST_CHECK_THROW
(
rev
.
GetMinor
(
2
),
std
::
out_of_range
);
BOOST_TEST_MESSAGE
(
" done."
);
}
...
...
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