Skip to content

Commit

Permalink
V5.30 unit test: Fix a bug relating NMRIF resource priority and merge…
Browse files Browse the repository at this point in the history
… procedure
  • Loading branch information
yokochi47 committed Jan 27, 2025
1 parent 5174031 commit 2703b34
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
14 changes: 9 additions & 5 deletions wwpdb/utils/nmr/ann/OneDepAnnTasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2187,16 +2187,20 @@ def replace_none(array, default: str = '.'):

# merge categories of model file as secondary source of NMRIF
if cR is not None:
existing_categories, target_categories = [], []

for categories in cifObj.getCategoryNameList(self.__entryId):
existing_categories.extend(categories)
primary_categories = cifObj.getCategoryNameList(self.__entryId)
secondary_categories = cR.getCategoryNameList()

target_categories = []
for cif_page in self.__cifPages:
if not any(cif_category in existing_categories for cif_category in self.__cifRequirements[cif_page]):
if not any(cif_category in primary_categories for cif_category in self.__cifRequirements[cif_page]):
for cif_category in self.__cifRequirements[cif_page]:
if cif_category not in target_categories:
target_categories.append(cif_category)
else:
for cif_category in self.__cifRequirements[cif_page]:
if cif_category not in primary_categories and cif_category in secondary_categories:
if cif_category not in target_categories:
target_categories.append(cif_category)

if len(target_categories) > 0:
for cif_category in target_categories:
Expand Down
14 changes: 10 additions & 4 deletions wwpdb/utils/nmr/io/CifReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,17 +441,23 @@ def getDataBlock(self, blockId: Optional[str] = None) -> Optional[DataContainer]

return dBlock if self.__setDataBlock(dBlock) else None

def hasCategory(self, catName: str, blockId: Optional[str] = None) -> bool:
""" Return whether a given category exists.
def getCategoryNameList(self, blockId: Optional[str] = None) -> List[str]:
""" Return all category names in a given datablock.
"""

if blockId is not None and self.__dBlock is not None and self.__dBlock.getName() != blockId:
self.__setDataBlock(self.getDataBlock(blockId))

if self.__dBlock is None:
return False
return []

return self.__dBlock.getObjNameList()

def hasCategory(self, catName: str, blockId: Optional[str] = None) -> bool:
""" Return whether a given category exists.
"""

return catName in self.__dBlock.getObjNameList()
return catName in self.getCategoryNameList(blockId)

def hasItem(self, catName: str, itName: str, blockId: Optional[str] = None) -> bool:
""" Return whether a given item exists in a category.
Expand Down
12 changes: 12 additions & 0 deletions wwpdb/utils/nmr/io/mmCIFUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,12 @@ def getCategoryNameList(self, blockName: str, ext: int = 1) -> List[str]:

return self.__dBlockList[self.__dBlockMap[get_ext_block_name(blockName, ext)]].getObjNameList()

def hasCategory(self, blockName: str, catName: str, ext: int = 1) -> bool:
""" Return whether a given category exists.
"""

return catName in self.getCategoryNameList(blockName, ext)

def getAttributeList(self, blockName: str, catName: str, ext: int = 1) -> List[str]:
""" Get item names in given datablock and category.
"""
Expand All @@ -412,6 +418,12 @@ def getAttributeList(self, blockName: str, catName: str, ext: int = 1) -> List[s

return catObj.getAttributeList()

def hasItem(self, blockName: str, catName: str, itName: str, ext: int = 1) -> bool:
""" Return whether a given item exists in a category.
"""

return itName in self.getAttributeList(blockName, catName, ext)

def getRowLength(self, blockName: str, catName: str, ext: int = 1) -> int:
""" Return length of rows of a given datablock and category.
"""
Expand Down

0 comments on commit 2703b34

Please sign in to comment.