diff --git a/modules/io/doc/mmcif.rst b/modules/io/doc/mmcif.rst index fd7b214fb3653d463b7792562ecd1dca00af45a2..0572ce2b9f34d6dd332b131273cd7460cfb80cca 100644 --- a/modules/io/doc/mmcif.rst +++ b/modules/io/doc/mmcif.rst @@ -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() diff --git a/modules/io/src/mol/mmcif_info.hh b/modules/io/src/mol/mmcif_info.hh index 68d60318f9fe1328eca94b7fc33daca14236749e..22e3e33a8be233e92a4dc118aa059f6b24581cbe 100644 --- a/modules/io/src/mol/mmcif_info.hh +++ b/modules/io/src/mol/mmcif_info.hh @@ -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 diff --git a/modules/io/tests/test_mmcif_info.cc b/modules/io/tests/test_mmcif_info.cc index 19c091f350254bd2fb47d88bd65551c007de8197..ecd3e3f6706700225a686e6036021461ce6aa5f3 100644 --- a/modules/io/tests/test_mmcif_info.cc +++ b/modules/io/tests/test_mmcif_info.cc @@ -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-04"); + rev.SetDateOriginal("2012-05-03"); 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-04"); + BOOST_CHECK(rev.GetDateOriginal() == "2012-05-03"); 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."); }