Skip to content

Commit

Permalink
DAOTHER-8905: V5.30 Release, fix potential MemoryError exception duri…
Browse files Browse the repository at this point in the history
…ng parsing XEASY PROT candidate file
  • Loading branch information
yokochi47 committed Feb 4, 2025
1 parent ff5d6fc commit d25bc41
Showing 1 changed file with 60 additions and 39 deletions.
99 changes: 60 additions & 39 deletions wwpdb/utils/nmr/NmrDpUtility.py
Original file line number Diff line number Diff line change
Expand Up @@ -33139,8 +33139,6 @@ def __validateLegacyMr(self) -> bool:

cyanaUplDistRest = cyanaLolDistRest = 0

fileListId = self.__file_path_list_len

def deal_aux_warn_message(listener):

if listener.warningMessage is not None:
Expand Down Expand Up @@ -33186,6 +33184,8 @@ def deal_aux_warn_message(listener):
if self.__verbose:
self.__lfh.write(f"+{self.__class_name__}.__validateLegacyMr() ++ KeyError - {warn}\n")

fileListId = self.__file_path_list_len

for ar in self.__inputParamDict[ar_file_path_list]:

file_path = ar['file_name']
Expand Down Expand Up @@ -35025,10 +35025,25 @@ def __validateLegacyPk(self) -> bool:

xeasyAtomNumberDict = None

has_nm_aux_xea_file = False
has_nm_aux_xea_file = has_nm_pea_xea_file = False

fileListId = self.__file_path_list_len

for ar in self.__inputParamDict[ar_file_path_list]:

file_path = ar['file_name']

input_source = self.report.input_sources[fileListId]
input_source_dic = input_source.get()

file_type = input_source_dic['file_type']

if file_type == 'nm-pea-xea':
has_nm_pea_xea_file = True
break

fileListId += 1

def deal_lexer_or_parser_error(a_pk_format_name, file_name, lexer_err_listener, parser_err_listener):
spa_order = 'default'
_err = ''
Expand Down Expand Up @@ -35137,56 +35152,62 @@ def deal_aux_warn_message(listener):
if self.__verbose:
self.__lfh.write(f"+{self.__class_name__}.__validateLegacyPk() ++ KeyError - {warn}\n")

for ar in self.__inputParamDict[ar_file_path_list]:
if has_nm_pea_xea_file:

file_path = ar['file_name']
fileListId = self.__file_path_list_len

input_source = self.report.input_sources[fileListId]
input_source_dic = input_source.get()
for ar in self.__inputParamDict[ar_file_path_list]:

file_type = input_source_dic['file_type']
file_path = ar['file_name']

fileListId += 1
input_source = self.report.input_sources[fileListId]
input_source_dic = input_source.get()

if file_type == 'nm-aux-xea':
has_nm_aux_xea_file = True
file_type = input_source_dic['file_type']

file_name = input_source_dic['file_name']
fileListId += 1

original_file_name = None
if 'original_file_name' in input_source_dic:
if input_source_dic['original_file_name'] is not None:
original_file_name = os.path.basename(input_source_dic['original_file_name'])
if file_name != original_file_name and original_file_name is not None:
file_name = f"{original_file_name} ({file_name})"
if file_type == 'nm-aux-xea':
has_nm_aux_xea_file = True

reader = XeasyPROTReader(self.__verbose, self.__lfh,
self.__representative_model_id,
self.__representative_alt_id,
self.__mr_atom_name_mapping,
self.__cR, self.__caC,
self.__ccU, self.__csStat, self.__nefT)
file_name = input_source_dic['file_name']

listener, parser_err_listener, lexer_err_listener = reader.parse(file_path, self.__cifPath)
original_file_name = None
if 'original_file_name' in input_source_dic:
if input_source_dic['original_file_name'] is not None:
original_file_name = os.path.basename(input_source_dic['original_file_name'])
if file_name != original_file_name and original_file_name is not None:
file_name = f"{original_file_name} ({file_name})"

_content_subtype = listener.getContentSubtype() if listener is not None else None
if _content_subtype is not None and len(_content_subtype) == 0:
_content_subtype = None
reader = XeasyPROTReader(self.__verbose, self.__lfh,
self.__representative_model_id,
self.__representative_alt_id,
self.__mr_atom_name_mapping,
self.__cR, self.__caC,
self.__ccU, self.__csStat, self.__nefT)

if None not in (lexer_err_listener, parser_err_listener, listener)\
and ((lexer_err_listener.getMessageList() is None and parser_err_listener.getMessageList() is None)
or _content_subtype is not None):
_pk_format_name = getRestraintFormatName(file_type)
pk_format_name = _pk_format_name.split()[0]
a_pk_format_name = ('an ' if pk_format_name[0] in ('AINMX') else 'a ') + _pk_format_name
if deal_lexer_or_parser_error(a_pk_format_name, file_name, lexer_err_listener, parser_err_listener)[0]:
continue
listener, parser_err_listener, lexer_err_listener = reader.parse(file_path, self.__cifPath)

if listener is not None:
_content_subtype = listener.getContentSubtype() if listener is not None else None
if _content_subtype is not None and len(_content_subtype) == 0:
_content_subtype = None

if None not in (lexer_err_listener, parser_err_listener, listener)\
and ((lexer_err_listener.getMessageList() is None and parser_err_listener.getMessageList() is None)
or _content_subtype is not None):
_pk_format_name = getRestraintFormatName(file_type)
pk_format_name = _pk_format_name.split()[0]
a_pk_format_name = ('an ' if pk_format_name[0] in ('AINMX') else 'a ') + _pk_format_name
if deal_lexer_or_parser_error(a_pk_format_name, file_name, lexer_err_listener, parser_err_listener)[0]:
continue

deal_aux_warn_message(listener)
if listener is not None:

xeasyAtomNumberDict = listener.getAtomNumberDict()
deal_aux_warn_message(listener)

xeasyAtomNumberDict = listener.getAtomNumberDict()

break

poly_seq_set = []

Expand Down

0 comments on commit d25bc41

Please sign in to comment.