Skip to content
Snippets Groups Projects
Commit 42efd978 authored by Bienchen's avatar Bienchen
Browse files

Added attributes for handling books in citations to the mmCIF info component

parent 378e71de
No related branches found
No related tags found
No related merge requests found
......@@ -78,6 +78,10 @@ void export_mmcif_io()
.def("GetYear", &MMCifInfoCitation::GetYear)
.def("SetTitle", &MMCifInfoCitation::SetTitle)
.def("GetTitle", &MMCifInfoCitation::GetTitle)
.def("SetBookPublisher", &MMCifInfoCitation::SetBookPublisher)
.def("GetBookPublisher", &MMCifInfoCitation::GetBookPublisher)
.def("SetBookPublisherCity", &MMCifInfoCitation::SetBookPublisherCity)
.def("GetBookPublisherCity", &MMCifInfoCitation::GetBookPublisherCity)
.def("SetCitationType", &MMCifInfoCitation::SetCitationType)
.def("SetCitationTypeJournal", &MMCifInfoCitation::SetCitationTypeJournal)
.def("SetCitationTypeBook", &MMCifInfoCitation::SetCitationTypeBook)
......@@ -108,6 +112,11 @@ void export_mmcif_io()
&MMCifInfoCitation::SetYear)
.add_property("title", &MMCifInfoCitation::GetTitle,
&MMCifInfoCitation::SetTitle)
.add_property("book_publisher", &MMCifInfoCitation::GetBookPublisher,
&MMCifInfoCitation::SetBookPublisher)
.add_property("book_publisher_city",
&MMCifInfoCitation::GetBookPublisherCity,
&MMCifInfoCitation::SetBookPublisherCity)
.add_property("citation_type", &MMCifInfoCitation::GetCitationType,
&MMCifInfoCitation::SetCitationType)
.add_property("authors", make_function(&MMCifInfoCitation::GetAuthorList,
......
......@@ -400,8 +400,7 @@ public:
/// \brief Create a citation.
MMCifInfoCitation(): id_(""), where_(UNKNOWN), cas_(""), published_in_(""),
volume_(""), page_first_(""), page_last_(""), doi_(""), pubmed_(0),
year_(0), title_("") {};
year_(0), title_(""), book_publisher_(""), book_publisher_city_("") {};
/// \brief Set ID
///
/// \param id ID
......@@ -470,12 +469,35 @@ public:
/// \return last page
String GetPageLast() const { return page_last_; }
/// \brief Set the publisher for a book
///
/// \param publisher
void SetBookPublisher(String publisher) { book_publisher_ = publisher; }
/// \brief Get the publisher of a book
///
/// \return publisher
String GetBookPublisher() const { return book_publisher_; }
/// \brief Set the publisher city for a book
///
/// \param publisher_city
void SetBookPublisherCity(String publisher_city) {
book_publisher_city_ = publisher_city;
}
/// \brief Get the publisher city of a book
///
/// \return publisher_city
String GetBookPublisherCity() const { return book_publisher_city_; }
//book_publisher_city_
/// \brief Set the DOI of a document
///
/// \param doi
void SetDOI(String doi) { doi_ = doi; }
/// \brief Get the DOI of a document
///
/// \return DOI
......@@ -617,6 +639,18 @@ public:
StringRef(cit.title_.c_str(), cit.title_.length())) {
return false;
}
if (StringRef(this->book_publisher_.c_str(),
this->book_publisher_.length()) !=
StringRef(cit.book_publisher_.c_str(),
cit.book_publisher_.length())) {
return false;
}
if (StringRef(this->book_publisher_city_.c_str(),
this->book_publisher_city_.length()) !=
StringRef(cit.book_publisher_city_.c_str(),
cit.book_publisher_city_.length())) {
return false;
}
if (this->authors_ != cit.authors_) {
return false;
}
......@@ -629,19 +663,21 @@ public:
}
private:
String id_; ///< internal identifier
MMCifInfoCType where_; ///< journal or book?
String cas_; ///< CAS identifier
String isbn_; ///< ISBN no. of medium
String published_in_; ///< book title or full journal name
String volume_; ///< journal volume
String page_first_; ///< first page
String page_last_; ///< last page
String doi_; ///< DOI identifier
int pubmed_; ///< accession no.
int year_; ///< year of publication
String title_; ///< title of the publication
std::vector<String> authors_; ///< author information
String id_; ///< internal identifier
MMCifInfoCType where_; ///< journal or book?
String cas_; ///< CAS identifier
String isbn_; ///< ISBN no. of medium
String published_in_; ///< book title or journal name
String volume_; ///< journal volume
String page_first_; ///< first page
String page_last_; ///< last page
String doi_; ///< DOI identifier
int pubmed_; ///< accession no.
int year_; ///< year of publication
String title_; ///< title of the publication
String book_publisher_; ///< name of publisher
String book_publisher_city_; ///< location of publisher
std::vector<String> authors_; ///< author information
};
/// \brief container class for information on obsolete entries
......
......@@ -40,6 +40,12 @@ class TestMMCifInfo(unittest.TestCase):
# test title setting/ getting
c.SetTitle('Foo')
self.assertEquals(c.GetTitle(), 'Foo')
# test book_publisher set & get
c.SetBookPublisher("Hugo")
self.assertEquals(c.GetBookPublisher(), "Hugo")
# test book_publisher_city set & get
c.SetBookPublisherCity("Basel")
self.assertEquals(c.book_publisher_city, "Basel")
# test citation type
self.assertTrue(c.IsCitationTypeUnknown())
self.assertEquals(c.citation_type, io.MMCifInfoCType.Unknown)
......
......@@ -72,6 +72,8 @@ BOOST_AUTO_TEST_CASE(mmcif_info_citation)
cit.SetPubMed(815);
cit.SetYear(815);
cit.SetTitle("Foo");
cit.SetBookPublisher("Brackelmann and Sons");
cit.SetBookPublisherCity("Stenkelfeld");
cit.SetAuthorList(author_list);
cit.SetCitationType(MMCifInfoCitation::JOURNAL);
author_list.clear();
......@@ -87,6 +89,8 @@ BOOST_AUTO_TEST_CASE(mmcif_info_citation)
BOOST_CHECK(cit.GetPubMed() == 815);
BOOST_CHECK(cit.GetYear() == 815);
BOOST_CHECK(cit.GetTitle() == "Foo");
BOOST_CHECK(cit.GetBookPublisher() == "Brackelmann and Sons");
BOOST_CHECK(cit.GetBookPublisherCity() == "Stenkelfeld");
BOOST_CHECK(cit.GetCitationType() == MMCifInfoCitation::JOURNAL);
BOOST_CHECK(cit.IsCitationTypeJournal() == true);
BOOST_CHECK(cit.IsCitationTypeBook() == false);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment