wwpdb.apps.msgmodule 0.181__tar.gz → 0.182__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/PKG-INFO +1 -1
  2. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/wwpdb/apps/msgmodule/__init__.py +1 -1
  3. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/wwpdb/apps/msgmodule/db/Models.py +5 -5
  4. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/wwpdb/apps/msgmodule/depict/MessagingDepict.py +39 -1
  5. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/wwpdb/apps/msgmodule/depict/MessagingTemplates.py +42 -1
  6. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/wwpdb/apps/msgmodule/io/MessagingIo.py +151 -11
  7. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/wwpdb/apps/msgmodule/webapp/MessagingWebApp.py +49 -26
  8. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/wwpdb.apps.msgmodule.egg-info/PKG-INFO +1 -1
  9. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/README.md +0 -0
  10. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/setup.cfg +0 -0
  11. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/setup.py +0 -0
  12. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/wwpdb/__init__.py +0 -0
  13. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/wwpdb/apps/__init__.py +0 -0
  14. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/wwpdb/apps/msgmodule/db/DataAccessLayer.py +0 -0
  15. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/wwpdb/apps/msgmodule/db/LockFile.py +0 -0
  16. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/wwpdb/apps/msgmodule/db/MessagingDataExport.py +0 -0
  17. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/wwpdb/apps/msgmodule/db/MessagingDataImport.py +0 -0
  18. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/wwpdb/apps/msgmodule/db/PdbxMessage.py +0 -0
  19. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/wwpdb/apps/msgmodule/db/PdbxMessageIo.py +0 -0
  20. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/wwpdb/apps/msgmodule/db/__init__.py +0 -0
  21. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/wwpdb/apps/msgmodule/depict/__init__.py +0 -0
  22. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/wwpdb/apps/msgmodule/io/CompatIo.py +0 -0
  23. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/wwpdb/apps/msgmodule/io/DateUtil.py +0 -0
  24. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/wwpdb/apps/msgmodule/io/EmHeaderUtils.py +0 -0
  25. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/wwpdb/apps/msgmodule/io/MessagingDataExport.py +0 -0
  26. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/wwpdb/apps/msgmodule/io/MessagingDataImport.py +0 -0
  27. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/wwpdb/apps/msgmodule/io/__init__.py +0 -0
  28. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/wwpdb/apps/msgmodule/models/Message.py +0 -0
  29. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/wwpdb/apps/msgmodule/models/__init__.py +0 -0
  30. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/wwpdb/apps/msgmodule/util/AutoMessage.py +0 -0
  31. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/wwpdb/apps/msgmodule/util/DaInternalDb.py +0 -0
  32. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/wwpdb/apps/msgmodule/util/ExtractMessage.py +0 -0
  33. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/wwpdb/apps/msgmodule/util/MessagingDataRouter.py +0 -0
  34. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/wwpdb/apps/msgmodule/util/__init__.py +0 -0
  35. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/wwpdb/apps/msgmodule/util/dump_db_to_cif.py +0 -0
  36. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/wwpdb/apps/msgmodule/util/list_recent_messages.py +0 -0
  37. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/wwpdb/apps/msgmodule/webapp/__init__.py +0 -0
  38. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/wwpdb/apps/msgmodule/webapp/wsgi.py +0 -0
  39. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/wwpdb.apps.msgmodule.egg-info/SOURCES.txt +0 -0
  40. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/wwpdb.apps.msgmodule.egg-info/dependency_links.txt +0 -0
  41. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/wwpdb.apps.msgmodule.egg-info/not-zip-safe +0 -0
  42. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/wwpdb.apps.msgmodule.egg-info/requires.txt +0 -0
  43. {wwpdb_apps_msgmodule-0.181 → wwpdb_apps_msgmodule-0.182}/wwpdb.apps.msgmodule.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wwpdb.apps.msgmodule
3
- Version: 0.181
3
+ Version: 0.182
4
4
  Summary: wwPDB messaging module
5
5
  Home-page: https://github.com/rcsb/py-wwpdb_apps_ann_tasks_v2
6
6
  Author: Ezra Peisach
@@ -2,4 +2,4 @@ __docformat__ = "restructuredtext en"
2
2
  __author__ = "Ezra Peisach"
3
3
  __email__ = "ezra.peisach@rcsb.org"
4
4
  __license__ = "Apache 2.0"
5
- __version__ = "0.181"
5
+ __version__ = "0.182"
@@ -71,8 +71,8 @@ class MessageInfo(Base):
71
71
  message_type = Column(String(20), nullable=True, default='text')
72
72
  send_status = Column(CHAR(1), nullable=True, default='Y')
73
73
  content_type = Column(Enum('messages-to-depositor', 'messages-from-depositor', 'notes-from-annotator', name='content_type_enum'), nullable=False, index=True)
74
- created_at = Column(DateTime, nullable=True, default=func.current_timestamp(), index=True)
75
- updated_at = Column(DateTime, nullable=True, default=func.current_timestamp(), onupdate=func.current_timestamp())
74
+ created_at = Column(DateTime, nullable=True, default=func.current_timestamp(), index=True) # pylint: disable=not-callable
75
+ updated_at = Column(DateTime, nullable=True, default=func.current_timestamp(), onupdate=func.current_timestamp()) # pylint: disable=not-callable
76
76
 
77
77
  # Relationships
78
78
  status = relationship("MessageStatus", back_populates="message", uselist=False, cascade="all, delete-orphan")
@@ -120,7 +120,7 @@ class MessageFileReference(Base):
120
120
  version_id = Column(Integer, nullable=True, default=1)
121
121
  storage_type = Column(String(20), nullable=True, default='archive', index=True)
122
122
  upload_file_name = Column(String(255), nullable=True)
123
- created_at = Column(DateTime, nullable=True, default=func.current_timestamp())
123
+ created_at = Column(DateTime, nullable=True, default=func.current_timestamp()) # pylint: disable=not-callable
124
124
 
125
125
  # Add unique constraint to ensure idempotent inserts
126
126
  __table_args__ = (
@@ -167,8 +167,8 @@ class MessageStatus(Base):
167
167
  read_status = Column(CHAR(1), nullable=True, default='N', index=True)
168
168
  action_reqd = Column(CHAR(1), nullable=True, default='N', index=True)
169
169
  for_release = Column(CHAR(1), nullable=True, default='N', index=True)
170
- created_at = Column(DateTime, nullable=True, default=func.current_timestamp())
171
- updated_at = Column(DateTime, nullable=True, default=func.current_timestamp(), onupdate=func.current_timestamp())
170
+ created_at = Column(DateTime, nullable=True, default=func.current_timestamp()) # pylint: disable=not-callable
171
+ updated_at = Column(DateTime, nullable=True, default=func.current_timestamp(), onupdate=func.current_timestamp()) # pylint: disable=not-callable
172
172
 
173
173
  # Relationships
174
174
  message = relationship("MessageInfo", back_populates="status")
@@ -38,6 +38,8 @@
38
38
  # 2016-09-14 ZF In doRender() function, introducing support for group deposition
39
39
  # 2022-02-28 CS add processs to deal with map_only withdrawn template
40
40
  # 2023-10-20 CS Further separate scenarios in choosing template for EM model-map, map-only, model-only, and whether this entry supersedes others.
41
+ # 2026-10-20 DAOTHER-10694 Add 3-month and 6-month hold extension templates.
42
+ # 2026-11-18 DH DAOTHER-10694 Extension letters quote the hold date saved in the status module.
41
43
  ##
42
44
  ##
43
45
  """
@@ -65,6 +67,33 @@ import logging
65
67
  logger = logging.getLogger(__name__)
66
68
 
67
69
 
70
+ def _usable_letter_date(value):
71
+ """True when value is a date we can quote, rather than a missing-date placeholder."""
72
+ text = str(value or "").strip()
73
+ return bool(text) and not text.startswith("[") and text not in (".", "?")
74
+
75
+
76
+ def extension_letter_date(param_dict, is_em):
77
+ """Date quoted by the 3-month and 6-month extension letters.
78
+
79
+ The status module stores an extended hold on date_hold_coordinates and,
80
+ for an EM map, on em_admin.map_hold_date. The Approval expire date stays
81
+ one year from deposition for HPUB and EM entries, so it does not move
82
+ when that hold date is extended.
83
+ """
84
+ if is_em:
85
+ if _usable_letter_date(param_dict.get("hold_date_em_map")):
86
+ return param_dict["hold_date_em_map"]
87
+ # Model-only EM has no map hold. The extended date is the PDB hold date.
88
+ if param_dict.get("modelonly") == "true" and _usable_letter_date(param_dict.get("hold_date")):
89
+ return param_dict["hold_date"]
90
+ if _usable_letter_date(param_dict.get("expire_date_em_map")):
91
+ return param_dict["expire_date_em_map"]
92
+ if _usable_letter_date(param_dict.get("hold_date")):
93
+ return param_dict["hold_date"]
94
+ return param_dict.get("expire_date") or ""
95
+
96
+
68
97
  class MessagingDepict(object):
69
98
  """Base class for HTML depictions contain definitions of common constructs."""
70
99
 
@@ -249,7 +278,9 @@ class MessagingDepict(object):
249
278
  # if self.__verbose:
250
279
  # logger.info("CStrack+++ call MessagingIo class from MessagingDepict.getMsgTmplts()")
251
280
  msgingIo = MessagingIo(p_reqObj, self.__verbose, self.__lfh)
252
- msgingIo.initializeDataStore() # THIS CALL MUST BE MADE HERE TO SUPPORT ALL DOWNSTREAM PROCESSING IN NEED OF DATA PARSED FROM THE COORDINATE FILE
281
+ # Reread the archive model. The session snapshot otherwise stays at the
282
+ # first open, so a hold date saved later in the status module is missed.
283
+ msgingIo.refreshDataStore()
253
284
  msgingIo.getMsgTmpltDataItems(strParamDict)
254
285
  starterMsgBody = msgingIo.getStarterMsgBody()
255
286
  #
@@ -263,6 +294,13 @@ class MessagingDepict(object):
263
294
  # ) # noqa: E501
264
295
  strParamDict["msg_tmplt_reminder"] = (MessagingTemplates.msgTmplt_reminder_em % strParamDict) if b_em else (MessagingTemplates.msgTmplt_reminder % strParamDict)
265
296
 
297
+ # DAOTHER-10694. Quote the hold date saved by the status module.
298
+ # Approval expire_date stays one year from deposition for HPUB and EM.
299
+ extensionDict = dict(strParamDict)
300
+ extensionDict["expire_date"] = extension_letter_date(strParamDict, b_em)
301
+ strParamDict["msg_tmplt_extension-3mo"] = MessagingTemplates.msgTmplt_extension3mo % extensionDict
302
+ strParamDict["msg_tmplt_extension-6mo"] = MessagingTemplates.msgTmplt_extension6mo % extensionDict
303
+
266
304
  # CS 2022-02-27 add map-only withdrawn template;
267
305
  # CS 2023-10-20 start, further seperate all scenarios of EM model-map, model-only, and map-only. The selection process needs to be optimized later.
268
306
  # logger.info("strParamDict: %s", strParamDict)
@@ -31,6 +31,9 @@
31
31
  # 2022-02-27 CS add template for Map-only withdrawn
32
32
  # 2023-10-20 CS add/modify various templates for superseding entry release, EM model-only and map-only
33
33
  # 2024-09-09 CS add templates msgTmplt_reminder_auth_to_rel and msgTmplt_reminder_auth_to_rel_em
34
+ # 2026-10-01 DH DAOTHER-10577 Add msgTmplt_reply sign-off for Communication Reply.
35
+ # 2026-10-20 DH DAOTHER-10577 Greeting on reply and letter closings is Sincerely yours.
36
+ # 2026-10-20 DH DAOTHER-10694 Add 3-month and 6-month hold extension templates.
34
37
  ##
35
38
  """
36
39
  Convenience class to serve as source of message templates for dynamic population
@@ -52,6 +55,20 @@ class MessagingTemplates(object):
52
55
 
53
56
  %(annotator_group_signoff)s
54
57
  %(site_contact_details)s
58
+ """
59
+
60
+ # DAOTHER-10577: Reply starts blank apart from this sign-off. Same name and
61
+ # group line as the letter closings, without the site contact block.
62
+ # Leading blank lines leave room to type the message above the sign-off.
63
+ msgTmplt_reply = """
64
+
65
+
66
+
67
+ Sincerely yours,
68
+
69
+ %(full_name_annotator)s
70
+
71
+ %(annotator_group_signoff)s
55
72
  """
56
73
  msgTmplt_annotatorGroupSignoff = "The wwPDB Biocuration Staff"
57
74
 
@@ -69,7 +86,7 @@ Twitter: http://twitter.com/#!/buildmodels
69
86
  msgTmplt_site_contact_details_pdbe = """
70
87
  --------------------------------------------------------------------------------------------------------------
71
88
  Protein Data Bank in Europe (PDBe) and Electron Microscopy Data Bank (EMDB), wwPDB partner sites
72
- https://www.PDBe.org | https://www.emdatabank.org
89
+ http://ebi.ac.uk/pdbe | http://ebi.ac.uk/emdb
73
90
  EMBL's European Bioinformatics Institute
74
91
  Wellcome Trust Genome Campus
75
92
  Hinxton, Cambridge, CB10 1SD, UK
@@ -163,6 +180,30 @@ In accordance with wwPDB policies (http://www.wwpdb.org/documentation/policy), i
163
180
 
164
181
  Thank you for your attention.
165
182
 
183
+ %(msg_closing)s
184
+ """
185
+
186
+ # DAOTHER-10694. expire_date here is the hold date saved in the status module.
187
+ # For HPUB and EM, the Approval letter keeps one year from deposition.
188
+ msgTmplt_extension3mo = """Dear Depositors,
189
+
190
+ Thank you for your message.
191
+
192
+ The hold period for your entry has been extended by an additional three months and is now set to expire on %(expire_date)s.
193
+
194
+ %(msg_closing)s
195
+ """
196
+
197
+ msgTmplt_extension6mo = """Dear Depositors,
198
+
199
+ Thank you for your message.
200
+
201
+ The hold period for your entry has been extended by an additional six months and is now set to expire on %(expire_date)s.
202
+
203
+ Please note that this is the maximum hold extension permitted by the wwPDB. If, after this date, you still require your entry to remain unreleased, you will need to withdraw the deposition and submit a new deposition.
204
+
205
+ To facilitate a future deposition, metadata from the current deposition, including author information and other relevant details, can be imported into a new deposition session. This option is available under "Based on a previous wwPDB deposition" in the "File Upload" section of the deposition interface.
206
+
166
207
  %(msg_closing)s
167
208
  """
168
209
 
@@ -120,6 +120,8 @@
120
120
  # 2023-10-20 CS Update release letter for pdb ids being superseded, for both autoMsg and UI, add "spr_to_replace_pdb_ids" to msg dict
121
121
  # 2023-11-01 CS Update file attachement list process to not to append validation report files if already in workingFileRefsList
122
122
  # 2023-11-02 CS Update to include PDB extension id in letter, add pdb_ext_id in msg dict
123
+ # 2026-05-20 DAOTHER-10451 Expose has_have for withdrawn subject when multiple accession IDs
124
+ # 2026-10-21 dh DAOTHER-10514 Hold-extension subject needs expmethod so the EMDB code is filled.
123
125
  # 2023-11-06 CS Update logic for __getDefaultMsgTmpltType(), i.e. default message pop-up for StatusMod
124
126
  # 2023-11-20 EP Add anyUnactionApprovalWithoutCorrection() to determine if any pendingapproval without corrections that need to be acted upon
125
127
  # 2023-11-23 EP autoMsg() add support for explicit-approved autogenerated message
@@ -145,6 +147,7 @@ import smtplib
145
147
  import sys
146
148
  import textwrap
147
149
  import time
150
+ from typing import List
148
151
 
149
152
  try:
150
153
  from html import unescape
@@ -284,7 +287,16 @@ class MessagingIo(object):
284
287
  #
285
288
  self.__groupId = groupId
286
289
 
287
- def initializeDataStore(self):
290
+ def refreshDataStore(self):
291
+ """Reread the archive model into the session snapshot.
292
+
293
+ initializeDataStore keeps the first snapshot for the session. A hold
294
+ date saved in the status module after that would not appear in the
295
+ message templates.
296
+ """
297
+ self.initializeDataStore(force=True)
298
+
299
+ def initializeDataStore(self, force=False):
288
300
  """Internalize data files"""
289
301
 
290
302
  if self.__isWorkflow():
@@ -295,6 +307,11 @@ class MessagingIo(object):
295
307
 
296
308
  @lockutils.synchronized("msgmoduledb-lock", external=True, lock_path=dirp)
297
309
  def initdb():
310
+ if force and os.path.exists(self.__dbFilePath):
311
+ try:
312
+ os.remove(self.__dbFilePath)
313
+ except OSError:
314
+ logger.exception("Could not refresh message template data at %s", self.__dbFilePath)
298
315
  if not os.access(self.__dbFilePath, os.R_OK):
299
316
  logger.debug("DB File not present %s", self.__dbFilePath)
300
317
 
@@ -1611,6 +1628,67 @@ class MessagingIo(object):
1611
1628
 
1612
1629
  return bOk
1613
1630
 
1631
+ def sendHoldExtensionNotice(self, depId, months, holdDate, sender):
1632
+ """Send the Extension 3 months or Extension 6 months letter.
1633
+
1634
+ holdDate is the YYYY-MM-DD value just saved in the hold-date field.
1635
+ The letter quotes that date. The Approval expire_date is one year
1636
+ from deposition for HPUB and EM entries, so it is not used here.
1637
+
1638
+ Returns True when the message was sent.
1639
+ """
1640
+ months = str(months).strip()
1641
+ holdDate = str(holdDate).strip()
1642
+ if months not in ("3", "6"):
1643
+ logger.error("Hold extension months must be 3 or 6, got %s", months)
1644
+ return False
1645
+ if len(holdDate) != 10 or holdDate[4] != "-" or holdDate[7] != "-":
1646
+ logger.error("Hold extension date is not YYYY-MM-DD: %s", holdDate)
1647
+ return False
1648
+
1649
+ self.__reqObj.setValue("content_type", "msgs")
1650
+ self.__reqObj.setValue("filesource", "archive")
1651
+ self.__reqObj.setValue("identifier", depId)
1652
+ if sender:
1653
+ self.__reqObj.setValue("sender", sender)
1654
+
1655
+ # Compose marks an EM deposition with expmethod. That selects
1656
+ # "EMDB entry ID EMD-…" and reads the EMDB code from the model.
1657
+ # The status button does not send expmethod, so the subject was
1658
+ # "EMDB ID [EMDBID NOT AVAIL]". Use the method from the page when
1659
+ # it was posted, otherwise treat a requested EMDB accession as EM.
1660
+ if not str(self.__reqObj.getValue("expmethod") or "").strip():
1661
+ expMethod = str(self.__reqObj.getValue("experimental_methods") or "").strip()
1662
+ if not expMethod and "EMDB" in str(self.__reqObj.getValue("reqacctypes") or ""):
1663
+ expMethod = "ELECTRON MICROSCOPY"
1664
+ if expMethod:
1665
+ self.__reqObj.setValue("expmethod", expMethod)
1666
+
1667
+ # Rebuild from the archive model so the sign-off matches the file just saved.
1668
+ self.__dbFilePath = os.path.join(self.__sessionPath, depId + "_modelFileData.db")
1669
+ if os.path.exists(self.__dbFilePath):
1670
+ try:
1671
+ os.remove(self.__dbFilePath)
1672
+ except OSError:
1673
+ logger.exception("Could not refresh message template data for %s", depId)
1674
+
1675
+ self.initializeDataStore()
1676
+ templateDict = {"identifier": depId}
1677
+ self.getMsgTmpltDataItems(templateDict)
1678
+ templateDict["expire_date"] = DateUtil.date_to_display(holdDate)
1679
+
1680
+ accession = templateDict.get("accession_ids") or depId
1681
+ if months == "3":
1682
+ body = MessagingTemplates.msgTmplt_extension3mo % templateDict
1683
+ subject = "Hold period extended by three months for " + accession
1684
+ tmpltType = "extension-3mo"
1685
+ else:
1686
+ body = MessagingTemplates.msgTmplt_extension6mo % templateDict
1687
+ subject = "Hold period extended by six months for " + accession
1688
+ tmpltType = "extension-6mo"
1689
+
1690
+ return self.sendSingle(depId, subject, body, p_sender=sender or "auto", p_tmpltType=tmpltType)
1691
+
1614
1692
  def getMsgTmpltDataItems(self, p_returnDict):
1615
1693
  msgTmpltHelper = MsgTmpltHlpr(self.__reqObj, self.__dbFilePath, self.__verbose, self.__lfh)
1616
1694
  msgTmpltHelper.populateTmpltDict(p_returnDict)
@@ -3667,9 +3745,17 @@ class MsgTmpltHlpr(object):
3667
3745
  # "NEUTRON DIFFRACTION": "PDB ID %(pdb_id)s",
3668
3746
  # }
3669
3747
 
3670
- self.__idMapToString = {"PDB": "%(pdb_ext_id)s (PDB ID %(pdb_id)s)", "EMDB": "EMDB ID %(emdb_id)s", "BMRB": "PDB ID %(pdb_id)s"} # CS 2023-11-02
3748
+ self.__idMapToString = {"PDB": "%(pdb_ext_id)s (PDB ID %(pdb_id)s)",
3749
+ "PDB_EXT": "%(pdb_ext_id)s",
3750
+ "EMDB": "EMDB ID %(emdb_id)s",
3751
+ "BMRB": "PDB ID %(pdb_id)s"
3752
+ }
3671
3753
 
3672
- self.__idMapToString_EM = {"PDB": "PDB entry %(pdb_ext_id)s (PDB ID %(pdb_id)s)", "EMDB": "EMDB entry ID %(emdb_id)s", "BMRB": "PDB entry ID %(pdb_id)s"} # CS 2023-11-02
3754
+ self.__idMapToString_EM = {"PDB": "PDB entry %(pdb_ext_id)s (PDB ID %(pdb_id)s)",
3755
+ "PDB_EXT": "PDB ENTRY %(pdb_ext_id)s",
3756
+ "EMDB": "EMDB entry ID %(emdb_id)s",
3757
+ "BMRB": "PDB entry ID %(pdb_id)s"
3758
+ }
3673
3759
 
3674
3760
  if self.__verbose and self.__debug:
3675
3761
  for value in self.__expMethodList:
@@ -3688,6 +3774,7 @@ class MsgTmpltHlpr(object):
3688
3774
  #
3689
3775
  self.__pdbId = None
3690
3776
  self.__pdbExtId = None
3777
+ self.__pdbDoi = None # DOI from database2
3691
3778
  self.__entryAuthrs = []
3692
3779
  self.__title = None
3693
3780
  self.__obsReplacePdb = None
@@ -3708,6 +3795,7 @@ class MsgTmpltHlpr(object):
3708
3795
  self.__dpstnDateEmMap = None
3709
3796
  self.__releaseDateEmMap = None
3710
3797
  self.__expireDateEmMap = None
3798
+ self.__holdDateEmMap = None # em_admin.map_hold_date, the EM hold date saved by the status module
3711
3799
  self.__entryStatusEmMap = None
3712
3800
  #
3713
3801
  self.__statusCode = None
@@ -3878,7 +3966,10 @@ class MsgTmpltHlpr(object):
3878
3966
  logger.info("problem recovering data into PdbxPersist from db file at: %s", self.__dbFilePath)
3879
3967
  logger.exception("Problem recovering date from PdbxPersist")
3880
3968
 
3881
- def __getAccessionIdString(self, idList):
3969
+ def __getAccessionIdString(self, idList: List[str], extpdbonly: bool = False) -> str:
3970
+ """Produces accession id string for substitution based on the PDB list
3971
+ If extpdbonly is set, then if PDB ID == Extended PDB ID - adjust
3972
+ """
3882
3973
  sAccessionIdsString = ""
3883
3974
  sAnd = ""
3884
3975
  #
@@ -3890,7 +3981,12 @@ class MsgTmpltHlpr(object):
3890
3981
  for nIndex, sId in enumerate(idList):
3891
3982
  if nIndex > 0:
3892
3983
  sAnd = " and "
3893
- sIDstring = mapping[sId]
3984
+
3985
+ lookup = sId
3986
+ if lookup == "PDB" and extpdbonly:
3987
+ lookup = "PDB_EXT"
3988
+
3989
+ sIDstring = mapping[lookup]
3894
3990
  sAccessionIdsString += sAnd + sIDstring
3895
3991
  if self.__debug:
3896
3992
  logger.info("+index %s, sId: '%s'", nIndex, sId)
@@ -3912,7 +4008,11 @@ class MsgTmpltHlpr(object):
3912
4008
  p_returnDict["pdb_id"] = self.__pdbId if (self.__pdbId is not None and len(self.__pdbId) > 0 and self.__pdbId != "?") else "[PDBID NOT AVAIL]"
3913
4009
  p_returnDict["pdb_ext_id"] = self.__pdbExtId if (self.__pdbExtId is not None and len(self.__pdbExtId) > 0 and self.__pdbExtId != "?") else "[PDBEXTID NOT AVAIL]" # CS 2023-11-02
3914
4010
  p_returnDict["emdb_id"] = self.__emdbId if (self.__emdbId is not None and len(self.__emdbId) > 0 and self.__emdbId != "?") else "[EMDBID NOT AVAIL]"
3915
- p_returnDict["accession_ids"] = (self.__getAccessionIdString(accessionIdList)) % p_returnDict
4011
+ all_extended = p_returnDict["pdb_id"] == p_returnDict["pdb_ext_id"] # do they match?
4012
+ p_returnDict["accession_ids"] = (self.__getAccessionIdString(accessionIdList, extpdbonly=all_extended)) % p_returnDict
4013
+ rqstdNumber = "multi" if (len(accessionIdList) > 1) else "single"
4014
+ dictHasHave = {"single": "has ", "multi": "have "}
4015
+ p_returnDict["has_have"] = dictHasHave[rqstdNumber]
3916
4016
  #################################################################################
3917
4017
 
3918
4018
  p_returnDict["contact_authors_list"] = self.__contactAuths
@@ -3929,6 +4029,7 @@ class MsgTmpltHlpr(object):
3929
4029
  p_returnDict["auth_rel_status_code_map"] = self.__authRelStatusCodeMap if (self.__authRelStatusCodeMap is not None and len(self.__authRelStatusCodeMap) > 0) else "[NOT AVAILABLE]" # CS 2023-10-20 # noqa: E501
3930
4030
 
3931
4031
  p_returnDict["expire_date"] = self.__expireDate
4032
+ p_returnDict["hold_date"] = self.__holdDate if self.__holdDate is not None else ""
3932
4033
  p_returnDict["recvd_date"] = (
3933
4034
  du.date_to_display(self.__initRecvdDate)
3934
4035
  if (self.__initRecvdDate is not None and len(self.__initRecvdDate) > 0 and self.__isNotCifNull(self.__initRecvdDate))
@@ -4002,9 +4103,7 @@ class MsgTmpltHlpr(object):
4002
4103
  else:
4003
4104
  p_returnDict[
4004
4105
  "doinotice"
4005
- ] = "Your entry has been assigned the following PDB DOI: https://doi.org/10.2210/pdb{}/pdb\n\nPlease use the above PDB DOI link to access your data.\n".format(
4006
- p_returnDict["pdb_id"]
4007
- )
4106
+ ] = f"Your entry has been assigned the following PDB DOI: https://doi.org/{self.__pdbDoi}\n\nPlease use the above PDB DOI link to access your data.\n"
4008
4107
 
4009
4108
  #######################
4010
4109
  # EM ENTRY PROCESSING #
@@ -4081,7 +4180,8 @@ class MsgTmpltHlpr(object):
4081
4180
  else:
4082
4181
  emReleasedIdList = ["PDB"] if self.__emModelReleased else ["EMDB"] if self.__emMapReleased else []
4083
4182
 
4084
- p_returnDict["accession_ids_em_rel"] = (self.__getAccessionIdString(emReleasedIdList)) % p_returnDict
4183
+ all_extended = p_returnDict.get("pdb_id") == p_returnDict.get("pdb_ext_id") # do they match?
4184
+ p_returnDict["accession_ids_em_rel"] = (self.__getAccessionIdString(emReleasedIdList, extpdbonly=all_extended)) % p_returnDict
4085
4185
 
4086
4186
  else:
4087
4187
  p_returnDict["accession_ids_em_rel"] = p_returnDict["accession_ids"]
@@ -4102,6 +4202,7 @@ class MsgTmpltHlpr(object):
4102
4202
  p_returnDict["entry_status_em_map"] = self.__entryStatusEmMap if (self.__entryStatusEmMap is not None and len(self.__entryStatusEmMap) > 0) else "[NOT AVAILABLE]"
4103
4203
  p_returnDict["auth_rel_status_code_em_rel"] = p_returnDict["auth_rel_status_code"]
4104
4204
  p_returnDict["expire_date_em_map"] = self.__expireDateEmMap
4205
+ p_returnDict["hold_date_em_map"] = self.__holdDateEmMap if self.__holdDateEmMap is not None else ""
4105
4206
  #
4106
4207
  p_returnDict["outbound_rprt_date_em"] = (
4107
4208
  self.__lastOutboundRprtDateEm if (self.__lastOutboundRprtDateEm is not None and len(self.__lastOutboundRprtDateEm) > 0) else "[NOT AVAILABLE]"
@@ -4189,6 +4290,12 @@ class MsgTmpltHlpr(object):
4189
4290
  else:
4190
4291
  p_returnDict["msg_closing"] = MessagingTemplates.msgTmplt_closing % p_returnDict
4191
4292
 
4293
+ # DAOTHER-10577: short sign-off prefilled when Reply is used
4294
+ p_returnDict["msg_reply_signature"] = MessagingTemplates.msgTmplt_reply % {
4295
+ "full_name_annotator": p_returnDict.get("full_name_annotator") or "",
4296
+ "annotator_group_signoff": p_returnDict.get("annotator_group_signoff") or MessagingTemplates.msgTmplt_annotatorGroupSignoff,
4297
+ }
4298
+
4192
4299
  #######################
4193
4300
  # SUPERCEDE PROCESSING # CS 2023-10-20
4194
4301
  #######################
@@ -4204,7 +4311,9 @@ class MsgTmpltHlpr(object):
4204
4311
  acc.append("PDB")
4205
4312
  if self.__statusCodeEmMap == "OBS":
4206
4313
  acc.append("EMDB")
4207
- p_returnDict["obs_ids"] = self.__getAccessionIdString(acc) % p_returnDict
4314
+
4315
+ all_extended = p_returnDict.get("pdb_id") == p_returnDict.get("pdb_ext_id") # do they match?
4316
+ p_returnDict["obs_ids"] = self.__getAccessionIdString(acc, extpdbonly=all_extended) % p_returnDict
4208
4317
  p_returnDict["obs_id_types"] = acc
4209
4318
 
4210
4319
  dt = self.__obsDate
@@ -4417,6 +4526,7 @@ class MsgTmpltHlpr(object):
4417
4526
  idxDbId = itDict["_database_2.database_id"]
4418
4527
  idxDbCode = itDict["_database_2.database_code"]
4419
4528
  idxDbExtCode = itDict.get("_database_2.pdbx_database_accession", None) # CS 2023-11-02
4529
+ idxDbDoi = itDict.get("_database_2.pdbx_doi") # index lowercased above - why?
4420
4530
 
4421
4531
  for row in catObj.getRowList():
4422
4532
  try:
@@ -4427,10 +4537,19 @@ class MsgTmpltHlpr(object):
4427
4537
  else:
4428
4538
  dbExtCode = None
4429
4539
 
4540
+ if idxDbDoi:
4541
+ dbDoi = row[idxDbDoi]
4542
+ else:
4543
+ dbDoi = None
4544
+
4430
4545
  if dbId.upper() == p_IdType:
4431
4546
  if p_IdType == "PDB":
4432
4547
  self.__pdbId = dbCode
4433
4548
  self.__pdbExtId = dbExtCode # CS 2023-11-02
4549
+ if dbDoi:
4550
+ self.__pdbDoi = dbDoi
4551
+ else:
4552
+ self.__pdbDoi = getBackupDoi(dbCode)
4434
4553
  elif p_IdType == "EMDB":
4435
4554
  self.__emdbId = dbCode
4436
4555
 
@@ -4645,6 +4764,7 @@ class MsgTmpltHlpr(object):
4645
4764
  idxDpstnDate = itDict["_em_admin.deposition_date"]
4646
4765
  # idxDpstnSite = itDict['_em_admin.deposition_site']
4647
4766
  idxMapReleaseDate = itDict["_em_admin.map_release_date"]
4767
+ idxMapHoldDate = itDict.get("_em_admin.map_hold_date")
4648
4768
  # idxHeaderReleaseDate=itDict['_em_admin.header_release_date']
4649
4769
 
4650
4770
  for row in catObj.getRowList():
@@ -4652,10 +4772,18 @@ class MsgTmpltHlpr(object):
4652
4772
  self.__statusCodeEmMap = (str(row[idxStatusCode])).upper()
4653
4773
  self.__dpstnDateEmMap = str(row[idxDpstnDate])
4654
4774
  self.__releaseDateEmMap = str(row[idxMapReleaseDate])
4775
+ if idxMapHoldDate is not None:
4776
+ self.__holdDateEmMap = str(row[idxMapHoldDate])
4655
4777
 
4656
4778
  except: # noqa: E722 pylint: disable=bare-except
4657
4779
  pass
4658
4780
 
4781
+ du = DateUtil()
4782
+ if self.__holdDateEmMap is None or len(self.__holdDateEmMap) < 1 or self.__isCifNull(self.__holdDateEmMap):
4783
+ self.__holdDateEmMap = ""
4784
+ else:
4785
+ self.__holdDateEmMap = du.date_to_display(self.__holdDateEmMap)
4786
+
4659
4787
  if self.__statusCodeEmMap is not None and len(self.__statusCodeEmMap) > 0:
4660
4788
  if self.__statusCodeEmMap == "HPUB":
4661
4789
  self.__entryStatusEmMap = "Hold for publication"
@@ -5236,3 +5364,15 @@ Please use the latest annotated mmCIF file (attached) to start a new deposition
5236
5364
  if self.__verbose:
5237
5365
  logger.info("following email address found to be invalid: %s\n", email)
5238
5366
  return False
5367
+
5368
+
5369
+ def getBackupDoi(pdbid: str) -> str:
5370
+ """Returns the DOI for a given PDB id. If PDB id is invalid return '' """
5371
+ if pdbid is None:
5372
+ return ""
5373
+ pdb_l = pdbid.lower()
5374
+ if len(pdb_l) == 4:
5375
+ return f"10.2210/pdb{pdb_l}/pdb"
5376
+ if pdb_l.startswith("pdb_0000"):
5377
+ return f"10.2210/pdb{pdb_l[8:]}/pdb"
5378
+ return f"10.2210/{pdb_l}/pdb"
@@ -1227,34 +1227,54 @@ class MessagingWebAppWorker(object):
1227
1227
  def _forwardMsg(self):
1228
1228
  return self._propagateMsg("forward")
1229
1229
 
1230
- def _verifyOrConvertId(self, id_to_check): # CS 2024-08-30
1231
- """Verify whether an id is valid site-specific deposition id (D_##...) through DA_INTERNAL DB.
1232
- If the id is not a deposition id, verify whether it's PDB ID or EMDB ID, and if so, attempt to convert
1233
- such ids to valid deposition id, which aims to handle message archving based on PDB or EMDB ID.
1234
- The verification and conversion is site-id specific, and do NOT work cross sites or corss site-ids.
1235
- Because DA_INTERNAL DB doesn't record pdb extension id at the time this function is created,
1236
- extended pdb id is handled by truncate the last 4 characters for temporary use.
1230
+ def _verifyOrConvertId(self, id_to_check, db_da_internal, wf_db_api): # CS 2024-08-30
1231
+ """Verify a target id for archiving or forwarding a message, converting it to a deposition id when needed.
1232
+
1233
+ The id is trimmed and upper-cased, then handled by its form:
1234
+
1235
+ * Deposition id (``D_`` followed by 6 to 10 digits): accepted when it is found in DA_INTERNAL, which covers
1236
+ submitted and processed entries, or otherwise in the local workflow database, which also covers entries that
1237
+ have been allocated but not yet submitted. A ``D_`` id of any other form is rejected without a lookup.
1238
+ * EMDB id (``EMD-...``), extended PDB id (``PDB_`` plus 8 characters) or PDB id (4 characters): looked up in
1239
+ DA_INTERNAL and converted to the corresponding deposition id.
1240
+
1241
+ Verification and conversion are specific to the site of the database helpers and do not work across sites.
1242
+
1243
+ Exceptions raised by either database helper propagate to the caller. Workflow lookup exceptions are
1244
+ additionally logged at their source and re-raised unchanged.
1237
1245
 
1238
1246
  Args:
1239
- id (_type_): Deposition id, PDB ID, extended PDB ID, or EMDB ID, or any input text string as ID
1247
+ id_to_check (str): deposition id, PDB id, extended PDB id or EMDB id
1248
+ db_da_internal (DaInternalDb): DA_INTERNAL database utility, created once per request and reused for each id
1249
+ wf_db_api (WfDbApi): workflow database api, created once per request and reused for each id
1240
1250
 
1241
1251
  Returns:
1242
- _type_: verfied or converted deposition id at the same site, or 'None' for invalid id input
1252
+ str: the verified or converted deposition id, or None if the id is empty, malformed or not found
1243
1253
  """
1244
- id_to_check = id_to_check.strip()
1254
+ id_to_check = id_to_check.strip().upper()
1245
1255
  if not id_to_check:
1246
1256
  return None
1247
1257
 
1248
- logger.info("verify or convert id: %s through DA_INTERNAL DB", id_to_check)
1249
- db_da_internal = DaInternalDb() # connect to DA_INTERNAL DB utility
1250
- id_to_check = id_to_check.upper()
1258
+ logger.info("verify or convert id: %s", id_to_check)
1251
1259
  if id_to_check.startswith("D_"): # format of deposition id
1252
1260
  dep_id = id_to_check
1253
- if db_da_internal.verifyDepId(dep_id):
1254
- logger.debug("%s is valid deposition id at this site", dep_id)
1255
- return dep_id # return the input id itself is vefified
1256
- else:
1261
+ if not re.match(r"D_[0-9]{6,10}\Z", dep_id):
1262
+ logger.warning("%s is not in the supported deposition id format", dep_id)
1257
1263
  return None
1264
+ if db_da_internal.verifyDepId(dep_id):
1265
+ logger.debug("%s is valid deposition id at this site (found in DA_INTERNAL)", dep_id)
1266
+ return dep_id # the input id itself is verified
1267
+ logger.info("%s not found in DA_INTERNAL, checking workflow database", dep_id)
1268
+ try:
1269
+ in_workflow = wf_db_api.exist({"DEP_SET_ID": dep_id})
1270
+ except Exception:
1271
+ logger.exception("workflow database lookup failed for %s", dep_id)
1272
+ raise
1273
+ if in_workflow:
1274
+ logger.debug("%s is valid deposition id at this site (found in workflow database)", dep_id)
1275
+ return dep_id
1276
+ logger.warning("%s not found in DA_INTERNAL or in the workflow database", dep_id)
1277
+ return None
1258
1278
  elif id_to_check.startswith("EMD-"): # format of EMDB ID
1259
1279
  emdb_id = id_to_check
1260
1280
  if db_da_internal.verifyEmdbId(emdb_id):
@@ -1262,11 +1282,7 @@ class MessagingWebAppWorker(object):
1262
1282
  return db_da_internal.convertEmdbIdToDepId(emdb_id) # EMDB->dep conversion
1263
1283
  else:
1264
1284
  return None
1265
- elif id_to_check.startswith("PDB_") and len(id_to_check) == 12: # format of extended PDB ID
1266
- # pdb_id = id_to_check[-4:] # truncate the last 4 chars as temporary solution
1267
- # if db_da_internal.verifyPdbId(pdb_id):
1268
- # logger.debug("%s is valid extended PDB ID, convert it to deposition id", id_to_check)
1269
- # return db_da_internal.convertPdbIdToDepId(pdb_id) # PDB->dep conversion
1285
+ elif id_to_check.upper().startswith("PDB_") and len(id_to_check) == 12: # format of extended PDB ID
1270
1286
  pdb_ext_id = id_to_check
1271
1287
  if db_da_internal.verifyExtendedPdbId(pdb_ext_id):
1272
1288
  logger.debug("%s is valid extended PDB ID, convert it to deposition id", pdb_ext_id)
@@ -1343,15 +1359,19 @@ class MessagingWebAppWorker(object):
1343
1359
  #
1344
1360
  # statusApi = StatusDbApi(siteId=self.__siteId, verbose=self.__verbose, log=self.__lfh)
1345
1361
 
1362
+ # database helpers are created once per request and reused for every target id
1363
+ db_da_internal = DaInternalDb(siteId=self.__siteId)
1364
+ wf_db_api = WfDbApi(siteId=self.__siteId, verbose=self.__verbose, log=self.__lfh)
1365
+
1346
1366
  bOk = False # initiate bOk in case of exit from loop below
1347
1367
  for depId in depIdLst:
1348
1368
  depId = depId.strip()
1349
1369
  logger.debug("start processing %s", depId)
1350
- depId_2 = self._verifyOrConvertId(depId) # CS 2024-08-30 verify dep id or convert PDB/EMDB ID to dep id for archiving
1370
+ depId_2 = self._verifyOrConvertId(depId, db_da_internal, wf_db_api) # CS 2024-08-30 verify dep id or convert PDB/EMDB ID to dep id for archiving
1351
1371
  logger.debug("verified or converted id %s", depId_2)
1352
1372
 
1353
1373
  if not depId_2:
1354
- logger.error("fail to verify or convert the input id %s", depId) # skip unverified id
1374
+ logger.warning("fail to verify or convert the input id %s", depId) # skip unverified id
1355
1375
  rtrnDict["success"][depId] = "false"
1356
1376
  continue
1357
1377
 
@@ -1386,12 +1406,15 @@ class MessagingWebAppWorker(object):
1386
1406
  # typically only notes actually authored by annotators trigger the Notes indicator in the WFM UI, but annotators have
1387
1407
  # requested that notes generated via emails archived/flagged from BMRB should also trigger the indicator
1388
1408
  #
1389
- if (bOk is True) and (contentType == "notes") and (self._getNotesFlaggingStatus() == "false") and (flagMsg == "y"):
1409
+ # flagMsg is checked before reading the flagging status, which creates the status file and fails for a deposition
1410
+ # without an archive directory
1411
+ #
1412
+ if (bOk is True) and (contentType == "notes") and (flagMsg == "y") and (self._getNotesFlaggingStatus() == "false"):
1390
1413
  self.__reqObj.setValue("activate_notes_flagging", "true")
1391
1414
  self._toggleNotesFlagging()
1392
1415
  bGlobalStatusCheckReqd = True
1393
1416
  #
1394
- if (bOk is True) and (contentType == "notes") and (self._getNotesFlaggingStatus("bmrb") == "false") and (flagMsg == "y"):
1417
+ if (bOk is True) and (contentType == "notes") and (flagMsg == "y") and (self._getNotesFlaggingStatus("bmrb") == "false"):
1395
1418
  self.__reqObj.setValue("activate_notes_flagging_bmrb", "true")
1396
1419
  self._toggleNotesFlagging("bmrb")
1397
1420
  bGlobalStatusCheckReqd = True
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wwpdb.apps.msgmodule
3
- Version: 0.181
3
+ Version: 0.182
4
4
  Summary: wwPDB messaging module
5
5
  Home-page: https://github.com/rcsb/py-wwpdb_apps_ann_tasks_v2
6
6
  Author: Ezra Peisach