diff --git a/wwpdb/utils/nmr/AlignUtil.py b/wwpdb/utils/nmr/AlignUtil.py index 6286875fc..1b85b9a9c 100644 --- a/wwpdb/utils/nmr/AlignUtil.py +++ b/wwpdb/utils/nmr/AlignUtil.py @@ -304,8 +304,7 @@ def beautifyPolySeq(polySeq1, polySeq2, seqIdName1='seq_id', seqIdName2='seq_id' if _a_c2 in emptyValue: _a_c2 = _c2 - gapS = [] - gapP = [] + gapS, gapP = [], [] lenSpacer = 5 # DAOTHER-7465, issue #2 @@ -856,13 +855,8 @@ def sortPolySeqRst(polySeqRst, nonPolyRemap=None): if _authCompIds[_idx] in emptyValue: _authCompIds[_idx] = _compIds[_idx] - _endSeqIds = [] - _endCompIds = [] - _endAuthCompIds = [] - - _begSeqIds = [] - _begCompIds = [] - _begAuthCompIds = [] + _endSeqIds, _endCompIds, _endAuthCompIds = [], [], [] + _begSeqIds, _begCompIds, _begAuthCompIds = [], [], [] for item in remapList: if item['chain_id'] != ps['chain_id']: @@ -994,14 +988,12 @@ def alignPolymerSequence(pA, polySeqModel, polySeqRst, conservative=True, resolv """ Align polymer sequence of the coordinates and restraints. """ - seqAlign = [] - compIdMapping = [] + seqAlign, compIdMapping = [], [] if pA is None or polySeqModel is None or polySeqRst is None: return seqAlign, compIdMapping - tabooList = [] - inhibitList = [] + tabooList, inhibitList = [], [] hasMultimer = False @@ -1191,8 +1183,7 @@ def alignPolymerSequence(pA, polySeqModel, polySeqRst, conservative=True, resolv if s_p is None or s_q is None or s_p not in s2['seq_id'] or s_q not in s2['seq_id']: continue if s_p + 1 != s_q: - idx1 = 0 - idx2 = 0 + idx1 = idx2 = 0 beg = -1 for i in range(length): myPr = myAlign[i] @@ -1236,20 +1227,17 @@ def alignPolymerSequence(pA, polySeqModel, polySeqRst, conservative=True, resolv and any((__s1, __s2) for (__s1, __s2, __c1, __c2) in zip(_s1['seq_id'], _s2['seq_id'], _s1['comp_id'], _s2['comp_id']) if __c1 != '.' and __c2 != '.' and __c1 != __c2): - seq_id1 = [] - seq_id2 = [] + seq_id1, seq_id2 = [], [] if has_auth_seq_id1: auth_seq_id1 = [] if has_auth_seq_id2: auth_seq_id2 = [] - comp_id1 = [] - comp_id2 = [] + comp_id1, comp_id2 = [], [] if has_auth_comp_id1: auth_comp_id1 = [] if has_auth_comp_id2: auth_comp_id2 = [] - idx1 = 0 - idx2 = 0 + idx1 = idx2 = 0 for i in range(length): myPr = myAlign[i] myPr0 = str(myPr[0]) @@ -1427,8 +1415,7 @@ def alignPolymerSequenceWithConflicts(pA, polySeqModel, polySeqRst, conflictTh=1 """ Align polymer sequence of the coordinates and restraints allowing minor conflicts. """ - seqAlign = [] - compIdMapping = [] + seqAlign, compIdMapping = [], [] if pA is None or polySeqModel is None or polySeqRst is None: return seqAlign, compIdMapping @@ -1578,8 +1565,7 @@ def alignPolymerSequenceWithConflicts(pA, polySeqModel, polySeqRst, conflictTh=1 if s_p is None or s_q is None or s_p not in s2['seq_id'] or s_q not in s2['seq_id']: continue if s_p + 1 != s_q: - idx1 = 0 - idx2 = 0 + idx1 = idx2 = 0 beg = -1 for i in range(length): myPr = myAlign[i] @@ -1622,20 +1608,17 @@ def alignPolymerSequenceWithConflicts(pA, polySeqModel, polySeqRst, conflictTh=1 if any((__s1, __s2) for (__s1, __s2, __c1, __c2) in zip(_s1['seq_id'], _s2['seq_id'], _s1['comp_id'], _s2['comp_id']) if __c1 != '.' and __c2 != '.' and __c1 != __c2): - seq_id1 = [] - seq_id2 = [] + seq_id1, seq_id2 = [], [] if has_auth_seq_id1: auth_seq_id1 = [] if has_auth_seq_id2: auth_seq_id2 = [] - comp_id1 = [] - comp_id2 = [] + comp_id1, comp_id2 = [], [] if has_auth_comp_id1: auth_comp_id1 = [] if has_auth_comp_id2: auth_comp_id2 = [] - idx1 = 0 - idx2 = 0 + idx1 = idx2 = 0 for i in range(length): myPr = myAlign[i] myPr0 = str(myPr[0]) @@ -1757,8 +1740,7 @@ def assignPolymerSequence(pA, ccU, fileType, polySeqModel, polySeqRst, seqAlign) mr_chains = len(polySeqRst) if len(polySeqRst) < LEN_LARGE_ASYM_ID else LEN_LARGE_ASYM_ID - mat = [] - indices = [] + mat, indices = [], [] for i1, s1 in enumerate(polySeqModel): chain_id_name = 'auth_chain_id' if 'auth_chain_id' in s1 else 'chain_id' @@ -1877,8 +1859,7 @@ def assignPolymerSequence(pA, ccU, fileType, polySeqModel, polySeqRst, seqAlign) if result['unmapped'] > 0 or result['conflict'] > 0: aligned = [True] * length - seq_id1 = [] - seq_id2 = [] + seq_id1, seq_id2 = [], [] j = 0 for i in range(length): @@ -1940,8 +1921,7 @@ def assignPolymerSequence(pA, ccU, fileType, polySeqModel, polySeqRst, seqAlign) if _conflicts + offset_1 > _matched and ca['sequence_coverage'] < LOW_SEQ_COVERAGE: # DAOTHER-7825 (2lyw) continue - unmapped = [] - conflict = [] + unmapped, conflict = [], [] for i in range(length): myPr = myAlign[i] @@ -2819,10 +2799,8 @@ def splitPolySeqRstForMultimers(pA, polySeqModel, polySeqRst, chainAssign): _polySeqRst.append(_test_ps_) - ref_seq_ids = [] - test_seq_ids = [] - idx1 = 0 - idx2 = 0 + ref_seq_ids, test_seq_ids = [], [] + idx1 = idx2 = 0 for i in range(length): myPr = myAlign[i] myPr0 = str(myPr[0]) @@ -2892,8 +2870,7 @@ def splitPolySeqRstForExactNoes(pA, polySeqModel, polySeqRst, chainAssign): split = False _polySeqRst = copy.copy(polySeqRst) - _chainIdMapping = {} - _modelChainIdExt = {} + _chainIdMapping, _modelChainIdExt = {}, {} for test_chain_id, ref_chain_ids in target_chain_ids.items(): @@ -2970,10 +2947,8 @@ def splitPolySeqRstForExactNoes(pA, polySeqModel, polySeqRst, chainAssign): if conflict > 0: return None, None, None - ref_seq_ids = [] - test_seq_ids = [] - idx1 = 0 - idx2 = 0 + ref_seq_ids, test_seq_ids = [], [] + idx1 = idx2 = 0 for i in range(length): myPr = myAlign[i] myPr0 = str(myPr[0]) @@ -3038,10 +3013,8 @@ def splitPolySeqRstForExactNoes(pA, polySeqModel, polySeqRst, chainAssign): _polySeqRst.append(_test_ps_) - ref_seq_ids = [] - test_seq_ids = [] - idx1 = 0 - idx2 = 0 + ref_seq_ids, test_seq_ids = [], [] + idx1 = idx2 = 0 for i in range(length): myPr = myAlign[i] myPr0 = str(myPr[0]) @@ -3302,8 +3275,7 @@ def splitPolySeqRstForBranched(pA, polySeqModel, branchedModel, polySeqRst, chai _split = False - p = 0 - b_p = 0 + p = b_p = 0 _ref_chain_ids = [] for ref_chain_id in ref_chain_ids: @@ -3362,15 +3334,11 @@ def splitPolySeqRstForBranched(pA, polySeqModel, branchedModel, polySeqRst, chai _polySeqRst.remove(test_ps) _split = True - ref_seq_ids = [] - test_seq_ids = [] - idx1 = 0 - idx2 = 0 + ref_seq_ids, test_seq_ids = [], [] + idx1 = idx2 = 0 - b_ref_seq_ids = [] - b_test_seq_ids = [] - b_idx1 = 0 - b_idx2 = 0 + b_ref_seq_ids, b_test_seq_ids = [], [] + b_idx1 = b_idx2 = 0 if matched > 0: @@ -3535,8 +3503,7 @@ def getPrettyChunk(chunk): lines = json.dumps(data, indent=2).split('\n') - is_tag = [] - chunk = [] + is_tag, chunk = [], [] with io.StringIO() as f: diff --git a/wwpdb/utils/nmr/BMRBChemShiftStat.py b/wwpdb/utils/nmr/BMRBChemShiftStat.py index 8187cace8..8add79821 100644 --- a/wwpdb/utils/nmr/BMRBChemShiftStat.py +++ b/wwpdb/utils/nmr/BMRBChemShiftStat.py @@ -1022,7 +1022,6 @@ def loadStatFromCsvFile(self, file_name, primary_th, secondary_th=None, comp_id_ or re.match(r'^HBB[23]', _atom_id) is not None)) or (comp_id == 'HEC' and (re.match(r'^HM[A-D][123]$', _atom_id) is not None or re.match(r'^HB[BC][123]$', _atom_id) is not None))): - _row = {} _row['comp_id'] = comp_id _row['atom_id'] = _atom_id @@ -1072,7 +1071,6 @@ def loadStatFromCsvFile(self, file_name, primary_th, secondary_th=None, comp_id_ and a[self.__ccU.ccaCTerminalAtomFlag] == 'N'): if not any(item for item in atm_list if item['comp_id'] == comp_id and item['atom_id'] == a[self.__ccU.ccaAtomId]): - _row = {} _row['comp_id'] = comp_id _row['atom_id'] = a[self.__ccU.ccaAtomId] @@ -1560,7 +1558,6 @@ def loadStatFromCsvFile(self, file_name, primary_th, secondary_th=None, comp_id_ and a[self.__ccU.ccaCTerminalAtomFlag] == 'N'): if not any(item for item in atm_list if item['comp_id'] == comp_id and item['atom_id'] == a[self.__ccU.ccaAtomId]): - _row = {} _row['comp_id'] = comp_id _row['atom_id'] = a[self.__ccU.ccaAtomId] @@ -1605,7 +1602,6 @@ def __appendExtraFromCcd(self, comp_id): or (peptide_like and a[self.__ccU.ccaNTerminalAtomFlag] == 'N' and a[self.__ccU.ccaCTerminalAtomFlag] == 'N'): - _row = {} _row['comp_id'] = comp_id _row['atom_id'] = a[self.__ccU.ccaAtomId] diff --git a/wwpdb/utils/nmr/NEFTranslator/NEFTranslator.py b/wwpdb/utils/nmr/NEFTranslator/NEFTranslator.py index 9986b9f52..bc45a8166 100644 --- a/wwpdb/utils/nmr/NEFTranslator/NEFTranslator.py +++ b/wwpdb/utils/nmr/NEFTranslator/NEFTranslator.py @@ -1653,8 +1653,7 @@ def check_mandatory_tags(self, in_file=None, file_type=None): mandatoryTag = self.nefMandatoryTag if file_type == 'nef' else self.starMandatoryTag - missing_sf_tags = [] - missing_lp_tags = [] + missing_sf_tags, missing_lp_tags = [], [] try: star_data = pynmrstar.Entry.from_file(in_file) @@ -1731,8 +1730,7 @@ def validate_file(self, in_file, file_subtype='A', allow_empty=False): """ is_valid = True - info = [] - error = [] + info, error = [], [] file_type = 'unknown' @@ -2116,8 +2114,7 @@ def get_inventory_list(self, star_data): # pylint: disable=no-self-use @return: list of saveframe category names, list of loop category names """ - sf_list = [] - lp_list = [] + sf_list, lp_list = [], [] if isinstance(star_data, pynmrstar.Entry): @@ -2177,8 +2174,7 @@ def skip_empty_value_error(lp, idx): return False for loop in loops: - cmp_dict = {} - seq_dict = {} + cmp_dict, seq_dict = {}, {} seq_data = [] @@ -2367,8 +2363,7 @@ def skip_empty_value_error(lp, idx): return False for loop in loops: - cmp_dict = {} - seq_dict = {} + cmp_dict, seq_dict = {}, {} seq_data = [] @@ -2581,8 +2576,7 @@ def resolve_entity_assembly(_loop, _alt_chain_id_list, sync_seq): orig_seq_id_col = _loop.tags.index('Original_PDB_residue_no') if 'Original_PDB_residue_no' in _loop.tags else -1 auth_to_star_seq = coord_assembly_checker['auth_to_star_seq'] - rev_seq = {} - _offset = {} + rev_seq, _offset = {}, {} _entity_assembly_id = _entity_id = None for ca in chain_assign: @@ -3326,8 +3320,7 @@ def fill_ligand(_loop, idx, np): asm = [] # assembly of a loop - valid_gap_key = [] - valid_spacer_key = [] + valid_gap_key, valid_spacer_key = [], [] if coord_assembly_checker is not None: cif_ps = coord_assembly_checker['polymer_sequence'] @@ -3538,10 +3531,7 @@ def skip_empty_value_error(lp, idx): seq_id_col = 3 for loop in loops: - seq_dict = {} - acmp_dict = {} - aseq_dict = {} - asym_dict = {} + seq_dict, acmp_dict, aseq_dict, asym_dict = {}, {}, {}, {} seq_data = [] @@ -3833,8 +3823,7 @@ def get_atom_type_from_cs_loop(self, star_data, lp_category, atom_type, isotope_ tags = [atom_type, isotope_number, atom_id] for loop in loops: - ist_dict = {} - atm_dict = {} + ist_dict, atm_dict = {}, {} a_type_data = [] @@ -4162,7 +4151,7 @@ def skip_empty_value_error(lp, idx): return True return False - f = _f = [] # user warnings + f, _f = [], [] # user warnings with io.StringIO() as idx_f, io.StringIO() as key_f, io.StringIO() as msg_f: @@ -6642,8 +6631,7 @@ def get_valid_star_atom_in_xplor_for_ligand_remap(self, comp_id, atom_id, coord_ elif len_protons == 2: atom_list, ambiguity_code, details = protons, 2, None if atom_id.startswith('QQ') and self.__ccU.updateChemCompDict(comp_id): - root = [] - _branch = [] + root, _branch = [], [] _root = self.__ccU.getBondedAtoms(comp_id, 'C' + atom_id[2:], exclProton=True) if len(_root) > 0: _branch.append('C' + atom_id[2:]) @@ -6806,10 +6794,8 @@ def get_star_atom_for_ligand_remap(self, comp_id, nef_atom, details, coord_atom_ comp_id = comp_id.upper() is_std_comp_id = comp_id in monDict3 - atom_list = [] + atom_list, atoms, methyl_atoms = [], [], [] ambiguity_code = 1 - atoms = [] - methyl_atoms = [] alt_atom_conv_dict = dict(zip(coord_atom_site['atom_id'], coord_atom_site['alt_atom_id'])) atom_conv_dict = dict(zip(coord_atom_site['alt_atom_id'], coord_atom_site['atom_id'])) @@ -7198,8 +7184,7 @@ def get_valid_star_atom_in_xplor(self, comp_id, atom_id, details=None, leave_unm if details is not None and atom_id[0] in ('Q', 'M'): if atom_id.startswith('QQM'): # 2n06, comp_id=CM8, atom_id=QQM -> ['HM2%', HM3%'] - root = [] - _branch = [] + root, _branch = [], [] _root = self.__ccU.getBondedAtoms(comp_id, 'C' + atom_id[2:], exclProton=True) if len(_root) > 0: _branch.append('C' + atom_id[2:]) @@ -7247,8 +7232,7 @@ def get_valid_star_atom_in_xplor(self, comp_id, atom_id, details=None, leave_unm elif len_protons == 2: atom_list, ambiguity_code, details = protons, 2, None if atom_id.startswith('QQ') and self.__ccU.updateChemCompDict(comp_id): - root = [] - _branch = [] + root, _branch = [], [] _root = self.__ccU.getBondedAtoms(comp_id, 'C' + atom_id[2:], exclProton=True) if len(_root) > 0: _branch.append('C' + atom_id[2:]) @@ -7350,8 +7334,7 @@ def get_valid_star_atom(self, comp_id, atom_id, details=None, leave_unmatched=Tr if atom_id[0] == 'M' or (atom_id[0] == 'Q' and self.__remediation_mode): # DAOTHER-8663, 8751 if atom_id.startswith('QQM'): # 2n06, comp_id=CM8, atom_id=QQM -> ['HM2%', HM3%'] - root = [] - _branch = [] + root, _branch = [], [] _root = self.__ccU.getBondedAtoms(comp_id, 'C' + atom_id[2:], exclProton=True) if len(_root) > 0: _branch.append('C' + atom_id[2:]) @@ -7490,10 +7473,8 @@ def get_star_atom(self, comp_id, nef_atom, details=None, leave_unmatched=True, m comp_id = comp_id.upper() is_std_comp_id = comp_id in monDict3 - atom_list = [] + atom_list, atoms, methyl_atoms = [], [], [] ambiguity_code = 1 - atoms = [] - methyl_atoms = [] try: @@ -7805,9 +7786,8 @@ def get_nef_atom(self, comp_id, star_atom_list, details=None, leave_unmatched=Tr if key in self.__cachedDictForNefAtom: return copy.deepcopy(self.__cachedDictForNefAtom[key]) - atom_list = [] + atom_list, atoms = [], [] atom_id_map = {} - atoms = [] try: @@ -8309,8 +8289,7 @@ def nef2star_seq_row(self, nef_tags, star_tags, loop_data, report=None): @return: rows of NMR-STAR, rows of _Entity_deleted_atom loop (residue variants), otherwise None """ - out_row = [] - aux_row = [] + out_row, aux_row = [], [] chain_index = nef_tags.index('_nef_sequence.chain_code') seq_index = nef_tags.index('_nef_sequence.sequence_code') @@ -8478,9 +8457,7 @@ def star2nef_seq_row(self, star_tags, nef_tags, loop_data, report=None, entity_d self.star2NefChainMapping = {} self.star2CifChainMapping = {} - auth_scheme = {} - - seq_list = {} + auth_scheme, seq_list = {}, {} for cid, star_chain in enumerate(self.authChainId): @@ -8643,8 +8620,7 @@ def star2star_seq_row(self, in_star_tags, star_tags, loop_data, report=None): @return: rows of NMR-STAR, rows of _Entity_deleted_atom loop (residue variants), otherwise None """ - out_row = [] - aux_row = [] + out_row, aux_row = [], [] chain_index = in_star_tags.index('_Chem_comp_assembly.Entity_assembly_ID') seq_index = in_star_tags.index('_Chem_comp_assembly.Comp_index_ID') @@ -8827,8 +8803,7 @@ def nef2star_bond_row(self, nef_tags, star_tags, loop_data): buf_row = [] - tag_map = {} - self_tag_map = {} + tag_map, self_tag_map = {}, {} for tag in seq_ident_tags: chain_tag = tag['chain_tag'] @@ -9000,8 +8975,7 @@ def star2star_bond_row(self, in_star_tags, star_tags, loop_data): buf_row = [] - tag_map = {} - self_tag_map = {} + tag_map, self_tag_map = {}, {} for tag in seq_ident_tags: chain_tag = tag['chain_tag'] @@ -9640,8 +9614,7 @@ def nef2star_dist_row(self, nef_tags, star_tags, loop_data): for row in in_row: - tag_map = {} - self_tag_map = {} + tag_map, self_tag_map = {}, {} for tag in seq_ident_tags: chain_tag = tag['chain_tag'] @@ -10008,8 +9981,7 @@ def star2star_dist_row(self, in_star_tags, star_tags, loop_data): for row in in_row: - tag_map = {} - self_tag_map = {} + tag_map, self_tag_map = {}, {} for tag in seq_ident_tags: chain_tag = tag['chain_tag'] @@ -10202,8 +10174,7 @@ def nef2star_dihed_row(self, nef_tags, star_tags, loop_data): for row in in_row: - tag_map = {} - self_tag_map = {} + tag_map, self_tag_map = {}, {} for tag in seq_ident_tags: chain_tag = tag['chain_tag'] @@ -10428,8 +10399,7 @@ def star2star_dihed_row(self, in_star_tags, star_tags, loop_data): for row in in_row: - tag_map = {} - self_tag_map = {} + tag_map, self_tag_map = {}, {} for tag in seq_ident_tags: chain_tag = tag['chain_tag'] @@ -10638,8 +10608,7 @@ def nef2star_rdc_row(self, nef_tags, star_tags, loop_data): for row in in_row: - tag_map = {} - self_tag_map = {} + tag_map, self_tag_map = {}, {} for tag in seq_ident_tags: chain_tag = tag['chain_tag'] @@ -10812,8 +10781,7 @@ def star2star_rdc_row(self, in_star_tags, star_tags, loop_data): for row in in_row: - tag_map = {} - self_tag_map = {} + tag_map, self_tag_map = {}, {} for tag in seq_ident_tags: chain_tag = tag['chain_tag'] @@ -10932,8 +10900,7 @@ def nef2star_peak_row(self, nef_tags, star_tags, loop_data, leave_unmatched=Fals out_row = [] - nef_comp_indices = [] - nef_atom_indices = [] + nef_comp_indices, nef_atom_indices = [], [] seq_ident_tags = self.get_seq_ident_tags(nef_tags, 'nef') @@ -10969,8 +10936,7 @@ def nef2star_peak_row(self, nef_tags, star_tags, loop_data, leave_unmatched=Fals for row in in_row: - tag_map = {} - self_tag_map = {} + tag_map, self_tag_map = {}, {} for tag in seq_ident_tags: chain_tag = tag['chain_tag'] @@ -11165,9 +11131,7 @@ def star2nef_peak_row(self, star_tags, nef_tags, loop_data): @return: rows of NEF """ - out_row = [] - - comp_indices = [] + out_row, comp_indices = [], [] seq_ident_tags = self.get_seq_ident_tags(star_tags, 'nmr-star') @@ -11309,8 +11273,7 @@ def star2star_peak_row(self, in_star_tags, star_tags, loop_data, leave_unmatched out_row = [] - in_star_comp_indices = [] - in_star_atom_indices = [] + in_star_comp_indices, in_star_atom_indices = [], [] seq_ident_tags = self.get_seq_ident_tags(in_star_tags, 'nmr-star') @@ -11346,8 +11309,7 @@ def star2star_peak_row(self, in_star_tags, star_tags, loop_data, leave_unmatched for row in in_row: - tag_map = {} - self_tag_map = {} + tag_map, self_tag_map = {}, {} for tag in seq_ident_tags: chain_tag = tag['chain_tag'] @@ -11546,8 +11508,7 @@ def nef2star_row(self, nef_tags, star_tags, in_row): out_row = [] - tag_map = {} - self_tag_map = {} + tag_map, self_tag_map = {}, {} for tag in self.get_seq_ident_tags(nef_tags, 'nef'): chain_tag = tag['chain_tag'] @@ -11683,8 +11644,7 @@ def star2star_row(self, in_star_tags, star_tags, in_row): out_row = [] - tag_map = {} - self_tag_map = {} + tag_map, self_tag_map = {}, {} for tag in self.get_seq_ident_tags(in_star_tags, 'nmr-star'): chain_tag = tag['chain_tag'] @@ -11937,8 +11897,7 @@ def nef_to_nmrstar(self, nef_file, star_file=None, report=None, leave_unmatched= (file_path, file_name) = ntpath.split(os.path.realpath(nef_file)) - info = [] - error = [] + info, error = [], [] if star_file is None: star_file = file_path + '/' + file_name.split('.')[0] + '.str' @@ -12468,8 +12427,7 @@ def nmrstar_to_nef(self, star_file, nef_file=None, report=None): (file_path, file_name) = ntpath.split(os.path.realpath(star_file)) - info = [] - error = [] + info, error = [], [] if nef_file is None: nef_file = file_path + '/' + file_name.split('.')[0] + '.nef' diff --git a/wwpdb/utils/nmr/NmrDpUtility.py b/wwpdb/utils/nmr/NmrDpUtility.py index 31e5b9e23..8d5363ab1 100644 --- a/wwpdb/utils/nmr/NmrDpUtility.py +++ b/wwpdb/utils/nmr/NmrDpUtility.py @@ -662,13 +662,7 @@ def get_type_of_star_file(fPath): try: - is_cif = False - - has_datablock = False - has_anonymous_saveframe = False - has_save = False - has_loop = False - has_stop = False + is_cif = has_datablock = has_anonymous_saveframe = has_save = has_loop = has_stop = False with open(fPath, 'r', encoding='utf-8') as ifh: for line in ifh: @@ -8315,8 +8309,7 @@ def __fixFormatIssueOfInputSource(self, file_list_id, file_name, file_type, srcP if is_cs_cif: loop_count = 0 - has_sf_category = False - has_sf_framecode = False + has_sf_category = has_sf_framecode = False with open(_srcPath, 'r', encoding='utf-8') as ifh: for line in ifh: @@ -8490,8 +8483,7 @@ def __fixFormatIssueOfInputSource(self, file_list_id, file_name, file_type, srcP target = {'sf_framecode': sf_framecode} - pass_sf_framecode = False - pass_sf_loop = False + pass_sf_framecode = pass_sf_loop = False sf_named_pattern = re.compile(r'\s*save_' + sf_framecode + r'\s*') @@ -8520,8 +8512,7 @@ def __fixFormatIssueOfInputSource(self, file_list_id, file_name, file_type, srcP sf_framecode = target['sf_framecode'] - pass_sf_framecode = False - pass_sf_loop = False + pass_sf_framecode = pass_sf_loop = False sf_named_pattern = re.compile(r'\s*save_' + sf_framecode + r'\s*') @@ -8689,10 +8680,7 @@ def __fixFormatIssueOfInputSource(self, file_list_id, file_name, file_type, srcP target = {'category_1': category_1, 'category_2': category_2} - pass_sf_framecode = False - pass_category_1 = False - pass_category_2 = False - pass_sf_loop = False + pass_sf_framecode = pass_category_1 = pass_category_2 = pass_sf_loop = False i = 1 @@ -8703,10 +8691,7 @@ def __fixFormatIssueOfInputSource(self, file_list_id, file_name, file_type, srcP if 'category_1_begin' in target and 'category_2_begin' in target: targets.append(target) break - pass_sf_framecode = False - pass_category_1 = False - pass_category_2 = False - pass_sf_loop = False + pass_sf_framecode = pass_category_1 = pass_category_2 = pass_sf_loop = False elif loop_pattern.match(line): pass_sf_loop = True elif not pass_sf_loop: @@ -8750,9 +8735,7 @@ def __fixFormatIssueOfInputSource(self, file_list_id, file_name, file_type, srcP pass_sf_loop = True elif sf_anonymous_pattern.match(line): pass_sf_framecode = True - pass_category_1 = False - pass_category_2 = False - pass_sf_loop = False + pass_category_1 = pass_category_2 = pass_sf_loop = False i += 1 @@ -10338,20 +10321,12 @@ def __detectContentSubTypeOfLegacyMr(self): with open(file_path, 'r', encoding='utf-8') as ifh: - atom_likes = 0 - atom_unlikes = 0 - cs_atom_likes = 0 - resid_likes = 0 - real_likes = 0 - names = [] - resids = [] + atom_likes = atom_unlikes = cs_atom_likes = resid_likes = real_likes = 0 + names, resids = [], [] rdc_atom_names = set() - cs_range_like = False - dist_range_like = False - dihed_range_like = False - rdc_range_like = False + cs_range_like = dist_range_like = dihed_range_like = rdc_range_like = False for line in ifh: @@ -10401,17 +10376,9 @@ def __detectContentSubTypeOfLegacyMr(self): and names[0][0] in hbond_da_atom_types and names[1][0] in protonBeginCode and names[2][0] in hbond_da_atom_types: has_hbond_restraint = True - atom_likes = 0 - atom_unlikes = 0 - cs_atom_likes = 0 - resid_likes = 0 - real_likes = 0 - names = [] - resids = [] - cs_range_like = False - dist_range_like = False - dihed_range_like = False - rdc_range_like = False + atom_likes = atom_unlikes = cs_atom_likes = resid_likes = real_likes = 0 + names, resids = [], [] + cs_range_like = dist_range_like = dihed_range_like = rdc_range_like = False elif _t_lower == 'name': name = t.upper() @@ -10458,11 +10425,7 @@ def __detectContentSubTypeOfLegacyMr(self): atom_likes = 0 names = [] - has_rest = False - has_plan = False - has_grou = False - has_sele = False - has_resi = False + has_rest = has_plan = has_grou = has_sele = has_resi = False for line in ifh: @@ -10519,9 +10482,7 @@ def __detectContentSubTypeOfLegacyMr(self): pass elif t_lower == 'end': - has_grou = False - has_sele = False - has_resi = False + has_grou = has_sele = has_resi = False _t_lower = t_lower @@ -10529,19 +10490,13 @@ def __detectContentSubTypeOfLegacyMr(self): with open(file_path, 'r', encoding='utf-8') as ifh: - in_rst = False - in_iat = False - in_igr1 = False - in_igr2 = False + in_rst = in_iat = in_igr1 = in_igr2 = False - names = [] - values = [] + names, values = [], [] pos = 0 - dist_range_like = False - dihed_range_like = False - rdc_range_like = False + dist_range_like = dihed_range_like = rdc_range_like = False for line in ifh: @@ -10603,8 +10558,7 @@ def __detectContentSubTypeOfLegacyMr(self): if t == '&end': - atom_likes = 0 - atom_unlikes = 0 + atom_likes = atom_unlikes = 0 for name in names: @@ -10640,13 +10594,9 @@ def __detectContentSubTypeOfLegacyMr(self): elif atom_likes + atom_unlikes == 6 and rdc_range_like: has_rdc_restraint = True - names = [] - values = [] + names, values = [], [] - in_rst = False - in_iat = False - in_igr1 = False - in_igr2 = False + in_rst = in_iat = in_igr1 = in_igr2 = False elif t.startswith('iat='): in_iat = True @@ -10656,8 +10606,7 @@ def __detectContentSubTypeOfLegacyMr(self): except ValueError: pass - in_igr1 = False - in_igr2 = False + in_igr1 = in_igr2 = False elif '=' not in t and in_iat: try: @@ -10683,9 +10632,7 @@ def __detectContentSubTypeOfLegacyMr(self): except ValueError: pass - in_iat = False - in_igr1 = False - in_igr2 = False + in_iat = in_igr1 = in_igr2 = False elif t.startswith('igr1'): in_igr1 = True @@ -10695,8 +10642,7 @@ def __detectContentSubTypeOfLegacyMr(self): except ValueError: pass - in_iat = False - in_igr2 = False + in_iat = in_igr2 = False elif '=' not in t and in_igr1: try: @@ -10714,8 +10660,7 @@ def __detectContentSubTypeOfLegacyMr(self): except ValueError: pass - in_iat = False - in_igr1 = False + in_iat = in_igr1 = False elif '=' not in t and in_igr2: try: @@ -10726,53 +10671,31 @@ def __detectContentSubTypeOfLegacyMr(self): pass elif '=' in t: - in_iat = False - in_igr1 = False - in_igr2 = False + in_iat = in_igr1 = in_igr2 = False elif file_type in light_mr_file_types or is_aux_amb or is_aux_gro or is_aux_cha: if is_aux_amb: - has_atom_name = False - has_residue_label = False - has_residue_pointer = False - has_amb_atom_type = False + has_atom_name = has_residue_label = has_residue_pointer = has_amb_atom_type = False - chk_atom_name_format = False - chk_residue_label_format = False - chk_residue_pointer_format = False - chk_amb_atom_type_format = False + chk_atom_name_format = chk_residue_label_format = chk_residue_pointer_format = chk_amb_atom_type_format = False - in_atom_name = False - in_residue_label = False - in_residue_pointer = False - in_amb_atom_type = False + in_atom_name = in_residue_label = in_residue_pointer = in_amb_atom_type = False - atom_names = 0 - residue_labels = 0 - residue_pointers = 0 - amb_atom_types = 0 + atom_names = residue_labels = residue_pointers = amb_atom_types = 0 elif is_aux_gro: - has_system = False - has_molecules = False - has_atoms = False + has_system = has_molecules = has_atoms = False - in_system = False - in_molecules = False - in_atoms = False + in_system = in_molecules = in_atoms = False - system_names = 0 - molecule_names = 0 - atom_names = 0 + system_names = molecule_names = atom_names = 0 elif is_aux_cha: - has_ext = False - - in_atoms = False + has_ext = in_atoms = False atom_names = 0 @@ -10885,9 +10808,8 @@ def __detectContentSubTypeOfLegacyMr(self): elif in_atom_name: len_line = len(line) - begin = 0 + begin = col = 0 end = max_char - col = 0 while col < max_cols and end < len_line: if len(line[begin:end].rstrip()) > 0: atom_names += 1 @@ -10897,9 +10819,8 @@ def __detectContentSubTypeOfLegacyMr(self): elif in_residue_label: len_line = len(line) - begin = 0 + begin = col = 0 end = max_char - col = 0 while col < max_cols and end < len_line: if len(line[begin:end].rstrip()) > 0: residue_labels += 1 @@ -10909,9 +10830,8 @@ def __detectContentSubTypeOfLegacyMr(self): elif in_residue_pointer: len_line = len(line) - begin = 0 + begin = col = 0 end = max_char - col = 0 while col < max_cols and end < len_line: try: _residue_pointer = line[begin:end].lstrip() @@ -10926,9 +10846,8 @@ def __detectContentSubTypeOfLegacyMr(self): elif in_amb_atom_type: len_line = len(line) - begin = 0 + begin = col = 0 end = max_char - col = 0 while col < max_cols and end < len_line: if len(line[begin:end].rstrip()) > 0: amb_atom_types += 1 @@ -11016,14 +10935,9 @@ def __detectContentSubTypeOfLegacyMr(self): s = re.split('[ ()]', _line) - atom_likes = 0 - cs_atom_likes = 0 + atom_likes = cs_atom_likes = 0 names = [] - res_like = False - angle_like = False - cs_range_like = False - dist_range_like = False - dihed_range_like = False + res_like = angle_like = cs_range_like = dist_range_like = dihed_range_like = False for t in s: @@ -11085,14 +10999,9 @@ def __detectContentSubTypeOfLegacyMr(self): s = re.split('[ ()]', _line) - atom_likes = 0 - cs_atom_likes = 0 + atom_likes = cs_atom_likes = 0 names = [] - res_like = False - angle_like = False - cs_range_like = False - dist_range_like = False - dihed_range_like = False + res_like = angle_like = cs_range_like = dist_range_like = dihed_range_like = False for t in s: @@ -11915,27 +11824,16 @@ def __detectContentSubTypeOfLegacyPk(self): if has_spectral_peak: continue - has_mr_header = False - has_pdb_format = False - has_cif_format = False - has_str_format = False + has_mr_header = has_pdb_format = has_cif_format = has_str_format = False try: header = True - in_header = False - pdb_record = False - cs_str = False - mr_str = False + in_header = pdb_record = cs_str = mr_str = False - has_datablock = False - has_anonymous_saveframe = False - has_save = False - has_loop = False - has_stop = False + has_datablock = has_anonymous_saveframe = has_save = has_loop = has_stop = False - first_str_line_num = -1 - last_str_line_num = -1 + first_str_line_num = last_str_line_num = -1 i = 0 @@ -14260,13 +14158,10 @@ def __detectOtherPossibleFormatAsErrorOfLegacyMr(self, file_path, file_name, fil """ Report other possible format as error of a given legacy NMR restraint file. """ - is_valid = False + is_valid = agreed_w_cns = False err = '' genuine_type = [] - valid_types = {} - possible_types = {} - - agreed_w_cns = False + valid_types, possible_types = {}, {} if (not is_valid or multiple_check) and file_type != 'nm-res-cns': _is_valid, _err, _genuine_type, _valid_types, _possible_types =\ @@ -14471,8 +14366,7 @@ def __detectOtherPossibleFormatAsErrorOfLegacyMr__(self, file_path, file_name, f is_valid = False err = '' genuine_type = None - valid_types = {} - possible_types = {} + valid_types, possible_types = {}, {} try: @@ -14599,19 +14493,14 @@ def __extractPublicMrFileIntoLegacyMr(self): fileListId = self.__file_path_list_len - dir_path = '.' - mr_file_name = '.' - split_file_list = [] - peak_file_list = [] + dir_path = mr_file_name = '.' + split_file_list, peak_file_list = [], [] self.__mr_atom_name_mapping = [] - remediated = False - aborted = False - src_basename = mr_core_path = None - mr_file_path = mr_file_link = None - mr_part_paths = [] - pk_list_paths = [] + remediated = aborted = False + src_basename = mr_core_path = mr_file_path = mr_file_link = None + mr_part_paths, pk_list_paths = [], [] settled_mr_file_types = ('nm-res-amb', 'nm-res-ari', 'nm-res-bio', 'nm-res-cha', 'nm-res-cns', 'nm-res-cya', 'nm-res-dyn', 'nm-res-gro', @@ -14766,28 +14655,16 @@ def __extractPublicMrFileIntoLegacyMr(self): mr_part_paths.append({'header': header_file}) mr_part_paths.append({'footer': footer_file}) - has_mr_header = False - has_pdb_format = False - has_cif_format = False - has_str_format = False - has_cs_str = False - has_mr_str = False + has_mr_header = has_pdb_format = has_cif_format = has_str_format = has_cs_str = has_mr_str = False try: header = True - in_header = False - pdb_record = False - footer = False + in_header = pdb_record = footer = False - has_datablock = False - has_anonymous_saveframe = False - has_save = False - has_loop = False - has_stop = False + has_datablock = has_anonymous_saveframe = has_save = has_loop = has_stop = False - first_str_line_num = -1 - last_str_line_num = -1 + first_str_line_num = last_str_line_num = -1 i = 0 @@ -14949,8 +14826,7 @@ def split_concat_comp_id_seq_id(string): mrPath = os.path.splitext(src_file)[0] + '-trimmed.str' header = True - in_header = False - pdb_record = False + in_header = pdb_record = False i = 0 @@ -15125,9 +15001,7 @@ def split_concat_comp_id_seq_id(string): mrPath = os.path.splitext(src_file)[0] + '-trimmed.cif' header = True - in_header = False - pdb_record = False - has_sharp = False + in_header = pdb_record = has_sharp = False i = 0 @@ -18489,12 +18363,8 @@ def __appendPolymerSequenceAlignment(self): seq_align_set = [] - dst_chain_ids = {} - ref_chain_ids = {} - map_chain_ids = {} - map_seq_ids = {} - - proc_chain_ids = {} + dst_chain_ids, ref_chain_ids, map_chain_ids, map_seq_ids, proc_chain_ids =\ + {}, {}, {}, {}, {} for s1 in polymer_sequence: chain_id = s1['chain_id'] @@ -18542,10 +18412,7 @@ def __appendPolymerSequenceAlignment(self): __matched = _matched __unmapped = unmapped __conflict = conflict - __chain_id = None - __s1 = None - __offset_1 = None - __offset_2 = None + __chain_id = __s1 = __offset_1 = __offset_2 = None for _s1 in polymer_sequence: @@ -18865,10 +18732,7 @@ def __appendPolymerSequenceAlignment(self): __matched = _matched __unmapped = unmapped __conflict = conflict - __chain_id = None - __s1 = None - __offset_1 = None - __offset_2 = None + __chain_id = __s1 = __offset_1 = __offset_2 = None for _s1 in polymer_sequence: @@ -19062,8 +18926,7 @@ def __appendPolymerSequenceAlignment(self): k_rests = list(total - set(mapping.keys())) v_rests = list(total - set(mapping.values())) - circular = False - cross = False + circular = cross = False for k, v in mapping.items(): for _k, _v in mapping.items(): @@ -19322,13 +19185,9 @@ def __getSeqAlignCode(self, file_list_id, file_type, content_subtype, sf_frameco length = len(myAlign) - seq_id1 = [] - seq_id2 = [] - comp_id1 = [] - comp_id2 = [] + seq_id1, seq_id2, comp_id1, comp_id2 = [], [], [], [] - idx1 = 0 - idx2 = 0 + idx1 = idx2 = 0 for i in range(length): myPr = myAlign[i] myPr0 = str(myPr[0]) @@ -21221,8 +21080,7 @@ def __testDataConsistencyInLoop__(self, file_list_id, file_name, file_type, cont warns = str(e).strip("'").split('\n') - has_multiple_data = False - has_bad_pattern = False + has_multiple_data = has_bad_pattern = False for warn in warns: @@ -21482,8 +21340,7 @@ def __detectConflictDataInLoop__(self, file_name, file_type, content_subtype, sf except IndexError: continue - conflict = False - inconsist = False + conflict = inconsist = False discrepancy = '' @@ -21746,8 +21603,7 @@ def __testNmrCovalentBond(self): enforce_allowed_tags=(file_type == 'nmr-star'), excl_missing_data=self.__excl_missing_data)[0] - disulf_asm = [] - other_asm = [] + disulf_asm, other_asm = [], [] item_names = self.item_names_in_rdc_loop[file_type] chain_id_1_name = item_names['chain_id_1'] @@ -21807,8 +21663,7 @@ def __testNmrCovalentBond(self): if cs_lp_data is not None: - ca_chem_shift_1 = None - cb_chem_shift_1 = None + ca_chem_shift_1 = cb_chem_shift_1 = None for _row in cs_lp_data: @@ -21829,8 +21684,7 @@ def __testNmrCovalentBond(self): disulf['ca_chem_shift_1'] = ca_chem_shift_1 disulf['cb_chem_shift_1'] = cb_chem_shift_1 - ca_chem_shift_2 = None - cb_chem_shift_2 = None + ca_chem_shift_2 = cb_chem_shift_2 = None for _row in cs_lp_data: @@ -21980,8 +21834,7 @@ def __testNmrCovalentBond(self): if cs_lp_data is not None: - ca_chem_shift_1 = None - cb_chem_shift_1 = None + ca_chem_shift_1 = cb_chem_shift_1 = None for _row in cs_lp_data: @@ -22002,8 +21855,7 @@ def __testNmrCovalentBond(self): other['ca_chem_shift_1'] = ca_chem_shift_1 other['cb_chem_shift_1'] = cb_chem_shift_1 - ca_chem_shift_2 = None - cb_chem_shift_2 = None + ca_chem_shift_2 = cb_chem_shift_2 = None for _row in cs_lp_data: @@ -22275,8 +22127,7 @@ def __testDataConsistencyInAuxLoop(self): warns = str(e).strip("'").split('\n') - has_multiple_data = False - has_bad_pattern = False + has_multiple_data = has_bad_pattern = False for warn in warns: @@ -22507,10 +22358,7 @@ def __testDataConsistencyInAuxLoopOfSpectralPeak(self, file_name, file_type, sf_ first_point /= sp_freq sp_width /= sp_freq - min_point = None - max_point = None - min_limit = None - max_limit = None + min_point = max_point = min_limit = max_limit = None if first_point is not None and sp_width is not None: @@ -22668,10 +22516,7 @@ def __testDataConsistencyInAuxLoopOfSpectralPeakAlt(self, file_name, file_type, first_point /= sp_freq sp_width /= sp_freq - min_point = None - max_point = None - min_limit = None - max_limit = None + min_point = max_point = min_limit = max_limit = None if first_point is not None and sp_width is not None: @@ -23681,8 +23526,7 @@ def __validateCsValue__(self, file_list_id, file_name, file_type, content_subtyp f"is located at a distance of {na['ring_distance']}Å, "\ f"and has an elevation angle of {na['ring_angle']}° with the ring plane." else: - warn = None - warn_alt = None + warn = warn_alt = None elif pa is not None: @@ -23692,8 +23536,7 @@ def __validateCsValue__(self, file_list_id, file_name, file_type, content_subtyp warn_alt += f" The nearest paramagnetic/ferromagnetic atom ({pa['chain_id']}:{pa['seq_id']}:{pa['comp_id']}:{pa['atom_id']}) "\ f"is located at a distance of {pa['distance']}Å." else: - warn = None - warn_alt = None + warn = warn_alt = None elif self.__cifChecked: warn += no_reason_message @@ -25355,8 +25198,7 @@ def delete_aux_loop(): if row[0] in valid_auth_seq_per_chain: valid_auth_seq_per_chain.remove(row[0]) - has_orig_seq = False - ch2_name_in_xplor = ch3_name_in_xplor = False + has_orig_seq = ch2_name_in_xplor = ch3_name_in_xplor = False if self.__remediation_mode: if set(orig_pdb_tags) & set(loop.tags) == set(orig_pdb_tags): @@ -25486,9 +25328,11 @@ def fill_cs_row(lp, index, _row, prefer_auth_atom_name, coord_atom_site, _seq_ke _row[7] = _coord_atom_site['type_symbol'][_atom_site_atom_id.index(atom_id)] if _row[7] in ISOTOPE_NUMBERS_OF_NMR_OBS_NUCS: _row[8] = ISOTOPE_NUMBERS_OF_NMR_OBS_NUCS[_row[7]][0] - if fill_orig_atom_id and _row[6] != _row[23] and _row[23] in _atom_site_atom_id: - if _row[23] in self.__csStat.getProtonsInSameGroup(comp_id, atom_id, True): - _row[23] = copy.copy(atom_id) + # """ + # if fill_orig_atom_id and _row[6] != _row[23] and _row[23] in _atom_site_atom_id: + # if _row[23] in self.__csStat.getProtonsInSameGroup(comp_id, atom_id, True): + # _row[23] = copy.copy(atom_id) + # """ else: if atom_id in ('H1', 'HT1') and 'H' in _atom_site_atom_id\ and atom_id not in _atom_site_atom_id: @@ -28084,10 +27928,7 @@ def __testCsPseudoAtomNameConsistencyInMrLoop(self): num_dim = max_dim - 1 - chain_id_names = [] - seq_id_names = [] - comp_id_names = [] - atom_id_names = [] + chain_id_names, seq_id_names, comp_id_names, atom_id_names = [], [], [], [] for d in range(num_dim): @@ -28450,9 +28291,7 @@ def __testCsValueConsistencyInPkLoop(self): if lp['file_name'] == file_name and lp['sf_framecode'] == sf_framecode and lp['category'] == self.aux_lp_categories[file_type][content_subtype][0]), None) - axis_codes = [] - abs_pk_pos = [] - sp_widths = [] + axis_codes, abs_pk_pos, sp_widths = [], [], [] if aux_data is not None and len(aux_data) > 0: for i in range(1, max_dim): @@ -28547,11 +28386,7 @@ def __testCsValueConsistencyInPkLoop(self): _d[k] = v item_names.append(_d) - chain_id_names = [] - seq_id_names = [] - comp_id_names = [] - atom_id_names = [] - position_names = [] + chain_id_names, seq_id_names, comp_id_names, atom_id_names, position_names = [], [], [], [], [] for d in range(num_dim): chain_id_names.append(item_names[d]['chain_id']) @@ -28948,10 +28783,7 @@ def __testCsValueConsistencyInPkAltLoop(self): _d[k] = v item_names.append(_d) - chain_id_names = [] - seq_id_names = [] - comp_id_names = [] - atom_id_names = [] + chain_id_names, seq_id_names, comp_id_names, atom_id_names = [], [], [], [] for i in range(num_dim): chain_id_names.append(item_names[i]['chain_id']) @@ -28963,9 +28795,7 @@ def __testCsValueConsistencyInPkAltLoop(self): if lp['file_name'] == file_name and lp['sf_framecode'] == sf_framecode and lp['category'] == self.aux_lp_categories[file_type][content_subtype][0]), None) - axis_codes = [] - abs_pk_pos = [] - sp_widths = [] + axis_codes, abs_pk_pos, sp_widths = [], [], [] if aux_data is not None and len(aux_data) > 0: for i in range(1, max_dim): @@ -31696,10 +31526,7 @@ def get_auth_seq_scheme(chain_id, seq_id): if sf_item['constraint_subsubtype'] == 'simple': - metal_coord = False - disele_bond = False - disulf_bond = False - hydrog_bond = False + metal_coord = disele_bond = disulf_bond = hydrog_bond = False for row in lp: comp_id_1 = row[comp_id_1_col] @@ -32093,13 +31920,11 @@ def concat_target_val(row): + (str(row[upper_limit_col]) if upper_limit_col != -1 else '')\ + (str(row[weight_col]) if weight_col != -1 else '') - _rest_id = None - _member_logic_code = None - _atom1 = _atom2 = {} + _rest_id = _member_logic_code = None + _atom1, _atom2 = {}, {} _values = '' - modified = False - has_member_id = False + modified = has_member_id = False sf_item['id'] = 0 @@ -32179,7 +32004,7 @@ def concat_target_val(row): _rest_id, _member_logic_code, _atom1, _atom2, _values = rest_id, member_logic_code, atom1, atom2, values except ValueError: - _atom1 = _atom2 = {} + _atom1, _atom2 = {}, {} if not self.__native_combined: # DAOTHER-8855 _row[id_col] = sf_item['id'] @@ -32196,8 +32021,7 @@ def update_member_id_dict(rows): if len(rows) < 2: return - atom_sel1 = [] - atom_sel2 = [] + atom_sel1, atom_sel2 = [], [] for row in rows: @@ -32226,8 +32050,7 @@ def update_member_id_dict(rows): index_id = row[index_id_col] member_id_dict[index_id] = member_id - _row = None - _rest_id = None + _row = _rest_id = None _union_rows = [] for row in lp: @@ -32767,16 +32590,12 @@ def __validateLegacyMr(self): if not has_poly_seq: return False - amberAtomNumberDict = None - gromacsAtomNumberDict = None - charmmAtomNumberDict = None + amberAtomNumberDict = gromacsAtomNumberDict = charmmAtomNumberDict = None _amberAtomNumberDict = {} - has_nm_aux_gro_file = False - has_nm_aux_cha_file = False + has_nm_aux_gro_file = has_nm_aux_cha_file = False - cyanaUplDistRest = 0 - cyanaLolDistRest = 0 + cyanaUplDistRest = cyanaLolDistRest = 0 fileListId = self.__file_path_list_len @@ -32965,9 +32784,7 @@ def deal_aux_warn_message(listener): fileListId = self.__file_path_list_len - ar_file_order = [] - ar_file_any_dist = [] # 6gbm, NOE restraint files must take precedence over other distance constraints such as hydrogen bonds - ar_file_wo_dist = [] + ar_file_order, ar_file_any_dist, ar_file_wo_dist = [], [], [] # 6gbm, NOE restraint files must take precedence over other distance constraints such as hydrogen bonds derived_from_public_mr = False @@ -33078,8 +32895,7 @@ def deal_aux_warn_message(listener): if conflict == 0 and unmapped > 0: - nmr_seq_ids = [] - cif_auth_seq_ids = [] + nmr_seq_ids, cif_auth_seq_ids = [], [] for i in range(length): if str(myAlign[i][0]) != '.' and i < len(s1['seq_id']): @@ -34658,10 +34474,9 @@ def __validateSaxsMr(self): sf_item = {} - title = None + title = _row = None _q_value = 0.0 - _row = None lp_count = 0 @@ -36379,15 +36194,9 @@ def __calculateStatsOfAssignedChemShift(self, file_list_id, sf_framecode, lp_dat # all atoms - all_c = [] - - excluded_comp_id = [] - excluded_atom_id = [] + all_c, excluded_comp_id, excluded_atom_id = [], [], [] - h1_col = -1 - c13_col = -1 - n15_col = -1 - p31_col = -1 + h1_col = c13_col = n15_col = p31_col = -1 col = 0 @@ -36526,10 +36335,7 @@ def __calculateStatsOfAssignedChemShift(self, file_list_id, sf_framecode, lp_dat bb_c = [] - h1_col = -1 - c13_col = -1 - n15_col = -1 - p31_col = -1 + h1_col = c13_col = n15_col = p31_col = -1 col = 0 @@ -36652,10 +36458,7 @@ def __calculateStatsOfAssignedChemShift(self, file_list_id, sf_framecode, lp_dat sc_c = [] - h1_col = -1 - c13_col = -1 - n15_col = -1 - p31_col = -1 + h1_col = c13_col = n15_col = p31_col = -1 col = 0 @@ -36778,8 +36581,7 @@ def __calculateStatsOfAssignedChemShift(self, file_list_id, sf_framecode, lp_dat ch3_c = [] - h1_col = -1 - c13_col = -1 + h1_col = c13_col = -1 col = 0 @@ -36881,9 +36683,7 @@ def __calculateStatsOfAssignedChemShift(self, file_list_id, sf_framecode, lp_dat aro_c = [] - h1_col = -1 - c13_col = -1 - n15_col = -1 + h1_col = c13_col = n15_col = -1 col = 0 @@ -37000,8 +36800,7 @@ def __calculateStatsOfAssignedChemShift(self, file_list_id, sf_framecode, lp_dat for k in count: z_scores[k] = [] - max_val = 0.0 - min_val = 0.0 + max_val = min_val = 0.0 for row in lp_data: @@ -37100,8 +36899,7 @@ def __calculateStatsOfAssignedChemShift(self, file_list_id, sf_framecode, lp_dat while scale > target_scale: scale /= 2.0 - range_of_vals = [] - count_of_vals = [] + range_of_vals, count_of_vals = [], [] v = 0.0 while v < min_val: @@ -37156,8 +36954,7 @@ def __calculateStatsOfAssignedChemShift(self, file_list_id, sf_framecode, lp_dat cys = {'chain_id': chain_id, 'seq_id': seq_id} - ca_chem_shift = None - cb_chem_shift = None + ca_chem_shift = cb_chem_shift = None for row in lp_data: @@ -37240,8 +37037,7 @@ def __calculateStatsOfAssignedChemShift(self, file_list_id, sf_framecode, lp_dat pro = {'chain_id': chain_id, 'seq_id': seq_id} - cb_chem_shift = None - cg_chem_shift = None + cb_chem_shift = cg_chem_shift = None for row in lp_data: @@ -37349,10 +37145,7 @@ def __calculateStatsOfAssignedChemShift(self, file_list_id, sf_framecode, lp_dat his = {'chain_id': chain_id, 'seq_id': seq_id} - cg_chem_shift = None - cd2_chem_shift = None - nd1_chem_shift = None - ne2_chem_shift = None + cg_chem_shift = cd2_chem_shift = nd1_chem_shift = ne2_chem_shift = None for row in lp_data: @@ -37461,8 +37254,7 @@ def __calculateStatsOfAssignedChemShift(self, file_list_id, sf_framecode, lp_dat if comp_id == 'VAL': - cg1_chem_shift = None - cg2_chem_shift = None + cg1_chem_shift = cg2_chem_shift = None for row in lp_data: @@ -37555,8 +37347,7 @@ def __calculateStatsOfAssignedChemShift(self, file_list_id, sf_framecode, lp_dat elif comp_id == 'LEU': - cd1_chem_shift = None - cd2_chem_shift = None + cd1_chem_shift = cd2_chem_shift = None for row in lp_data: @@ -37749,10 +37540,7 @@ def __calculateStatsOfAssignedChemShift(self, file_list_id, sf_framecode, lp_dat if s is not None: - rci_residues = [] - rci_assignments = [] - seq_ids_wo_assign = [] - oxidized_cys_seq_ids = [] + rci_residues, rci_assignments, seq_ids_wo_assign, oxidized_cys_seq_ids = [], [], [], [] for seq_id, comp_id in zip(s['seq_id'], s['comp_id']): @@ -37811,8 +37599,7 @@ def __calculateStatsOfAssignedChemShift(self, file_list_id, sf_framecode, lp_dat if comp_id in ('CYS', 'DCY'): - ca_chem_shift = None - cb_chem_shift = None + ca_chem_shift = cb_chem_shift = None for row in lp_data: @@ -37895,11 +37682,19 @@ def __calculateStatsOfAssignedChemShift(self, file_list_id, sf_framecode, lp_dat sf = self.__star_data[file_list_id].get_saveframe_by_name(sf_framecode) lp = next(lp for lp in sf.loops if lp.category == lp_category) - mapping = [] + mapping, identity_mapping = [], [] tags = ['Comp_ID', 'Atom_ID', 'Original_PDB_atom_name'] if set(tags) & set(lp.tags) == set(tags): dat = get_lp_tag(lp, tags) + + for row in dat: + if row[0] in emptyValue or row[1] in emptyValue or row[2] in emptyValue or row[1] != row[2]: + continue + key = (row[0], row[2]) + if key not in identity_mapping: + identity_mapping.append(key) + for row in dat: if row[0] in emptyValue or row[1] in emptyValue or row[2] in emptyValue or row[1] == row[2]: continue @@ -37913,11 +37708,11 @@ def __calculateStatsOfAssignedChemShift(self, file_list_id, sf_framecode, lp_dat history = next(m['history'] for m in mapping if m['comp_id'] == comp_id) if not any(h for h in history if h['atom_name'] == atom_name): - history.append({'atom_name': atom_name, 'atom_id': [atom_id]}) - else: - h = next(h for h in history if h['atom_name'] == atom_name) - if atom_id not in h['atom_id']: - h['atom_id'].append(atom_id) + history.append({'atom_name': atom_name, 'atom_id': [atom_name] if (comp_id, atom_name) in identity_mapping else []}) + + h = next(h for h in history if h['atom_name'] == atom_name) + if atom_id not in h['atom_id']: + h['atom_id'].append(atom_id) if len(mapping) == 0: mapping = None @@ -37979,17 +37774,12 @@ def __calculateStatsOfDistanceRestraint(self, file_list_id, sf_framecode, lp_dat max_val = -100.0 min_val = 100.0 - count = {} - comb_count = {} - inco_count = {} - redu_count = {} - weights = {} - potential_types = {} + count, comb_count, inco_count, redu_count, weights, potential_types =\ + {}, {}, {}, {}, {}, {} + set_id = set() - count_per_residue = [] - count_on_map = [] - count_on_asym_map = [] + count_per_residue, count_on_map, count_on_asym_map = [], [], [] has_inter_chain_constraint = False @@ -38058,8 +37848,7 @@ def __calculateStatsOfDistanceRestraint(self, file_list_id, sf_framecode, lp_dat target_value = row.get(target_value_name) - upper_limit = None - lower_limit = None + upper_limit = lower_limit = None if target_value is None: @@ -38362,8 +38151,7 @@ def __calculateStatsOfDistanceRestraint(self, file_list_id, sf_framecode, lp_dat while scale > target_scale: scale /= 2.0 - range_of_vals = [] - count_of_vals = [] + range_of_vals, count_of_vals = [], [] v = 0.0 while v < min_val: @@ -38393,8 +38181,7 @@ def __calculateStatsOfDistanceRestraint(self, file_list_id, sf_framecode, lp_dat target_value = row.get(target_value_name) - upper_limit = None - lower_limit = None + upper_limit = lower_limit = None if target_value is None: @@ -38459,8 +38246,7 @@ def __calculateStatsOfDistanceRestraint(self, file_list_id, sf_framecode, lp_dat # max_inclusive = DIST_UNCERT_MAX - max_val = 0.0 - min_val = 0.0 + max_val = min_val = 0.0 dist_ann = [] @@ -38566,8 +38352,7 @@ def __calculateStatsOfDistanceRestraint(self, file_list_id, sf_framecode, lp_dat while scale > target_scale: scale /= 2.0 - range_of_vals = [] - count_of_vals = [] + range_of_vals, count_of_vals = [], [] v = 0.0 while v < min_val: @@ -38668,8 +38453,7 @@ def __calculateStatsOfDistanceRestraint(self, file_list_id, sf_framecode, lp_dat target_value = row_1.get(target_value_name) - upper_limit = None - lower_limit = None + upper_limit = lower_limit = None if target_value is None: @@ -38726,8 +38510,7 @@ def __calculateStatsOfDistanceRestraint(self, file_list_id, sf_framecode, lp_dat target_value = row_1.get(target_value_name) - upper_limit = None - lower_limit = None + upper_limit = lower_limit = None if target_value is None: @@ -38801,12 +38584,38 @@ def __calculateStatsOfDistanceRestraint(self, file_list_id, sf_framecode, lp_dat sf = self.__star_data[file_list_id].get_saveframe_by_name(sf_framecode) lp = next(lp for lp in sf.loops if lp.category == lp_category) - mapping = [] + mapping, identity_mapping = [], [] + dat1 = dat2 = None - tags = ['Comp_ID_1', 'Atom_ID_1', 'Auth_atom_name_1'] - if set(tags) & set(lp.tags) == set(tags): - dat = get_lp_tag(lp, tags) - for row in dat: + tags1 = ['Comp_ID_1', 'Atom_ID_1', 'Auth_atom_name_1'] + if set(tags1) & set(lp.tags) == set(tags1): + dat1 = get_lp_tag(lp, tags1) + + tags2 = ['Comp_ID_2', 'Atom_ID_2', 'Auth_atom_name_2'] + if set(tags2) & set(lp.tags) == set(tags2): + dat2 = get_lp_tag(lp, tags2) + + if dat1 is not None: + + for row in dat1: + if row[0] in emptyValue or row[1] in emptyValue or row[2] in emptyValue or row[1] != row[2]: + continue + key = (row[0], row[2]) + if key not in identity_mapping: + identity_mapping.append(key) + + if dat2 is not None: + + for row in dat2: + if row[0] in emptyValue or row[1] in emptyValue or row[2] in emptyValue or row[1] != row[2]: + continue + key = (row[0], row[2]) + if key not in identity_mapping: + identity_mapping.append(key) + + if dat1 is not None: + + for row in dat1: if row[0] in emptyValue or row[1] in emptyValue or row[2] in emptyValue or row[1] == row[2]: continue comp_id = row[0] @@ -38819,16 +38628,15 @@ def __calculateStatsOfDistanceRestraint(self, file_list_id, sf_framecode, lp_dat history = next(m['history'] for m in mapping if m['comp_id'] == comp_id) if not any(h for h in history if h['atom_name'] == atom_name): - history.append({'atom_name': atom_name, 'atom_id': [atom_id]}) - else: - h = next(h for h in history if h['atom_name'] == atom_name) - if atom_id not in h['atom_id']: - h['atom_id'].append(atom_id) + history.append({'atom_name': atom_name, 'atom_id': [atom_name] if (comp_id, atom_name) in identity_mapping else []}) - tags = ['Comp_ID_2', 'Atom_ID_2', 'Auth_atom_name_2'] - if set(tags) & set(lp.tags) == set(tags): - dat = get_lp_tag(lp, tags) - for row in dat: + h = next(h for h in history if h['atom_name'] == atom_name) + if atom_id not in h['atom_id']: + h['atom_id'].append(atom_id) + + if dat2 is not None: + + for row in dat2: if row[0] in emptyValue or row[1] in emptyValue or row[2] in emptyValue or row[1] == row[2]: continue comp_id = row[0] @@ -38841,11 +38649,11 @@ def __calculateStatsOfDistanceRestraint(self, file_list_id, sf_framecode, lp_dat history = next(m['history'] for m in mapping if m['comp_id'] == comp_id) if not any(h for h in history if h['atom_name'] == atom_name): - history.append({'atom_name': atom_name, 'atom_id': [atom_id]}) - else: - h = next(h for h in history if h['atom_name'] == atom_name) - if atom_id not in h['atom_id']: - h['atom_id'].append(atom_id) + history.append({'atom_name': atom_name, 'atom_id': [atom_name] if (comp_id, atom_name) in identity_mapping else []}) + + h = next(h for h in history if h['atom_name'] == atom_name) + if atom_id not in h['atom_id']: + h['atom_id'].append(atom_id) if len(mapping) == 0: mapping = None @@ -38891,8 +38699,7 @@ def __calculateStatsOfCovalentBond(self, file_list_id, sf_framecode, lp_category count = {} - count_on_map = [] - count_on_asym_map = [] + count_on_map, count_on_asym_map = [], [] has_inter_chain_constraint = False @@ -39067,15 +38874,9 @@ def __getTypeOfDistanceRestraint(self, file_type, lp_data, row_id, target_value, comp_id_1_name = item_names['comp_id_1'] comp_id_2_name = item_names['comp_id_2'] - hydrogen_bond_type = None - hydrogen_bond = False - disulfide_bond_type = None - disulfide_bond = False - diselenide_bond_type = None - diselenide_bond = False - other_bond_type = None - other_bond = False - symmetry = False + hydrogen_bond_type = disulfide_bond_type = diselenide_bond_type = other_bond_type = None + + hydrogen_bond = disulfide_bond = diselenide_bond = other_bond = symmetry = False if chain_id_1 != chain_id_2 or seq_id_1 != seq_id_2: @@ -39374,10 +39175,7 @@ def __getTypeOfDistanceRestraint(self, file_type, lp_data, row_id, target_value, is_bb_atom_2 = _atom_id_2[0] in self.__csStat.getBackBoneAtoms(comp_id_2) else: - is_bb_atom_1 = False - is_bb_atom_2 = False - is_sc_atom_1 = False - is_sc_atom_2 = False + is_bb_atom_1 = is_bb_atom_2 = is_sc_atom_1 = is_sc_atom_2 = False else: is_sc_atom_1 = atom_id_1 in self.__csStat.getSideChainAtoms(comp_id_1) @@ -39426,15 +39224,9 @@ def __getTypeOfCovalentBond(self, file_type, lp_data, row_id, target_value, comp_id_1_name = item_names['comp_id_1'] comp_id_2_name = item_names['comp_id_2'] - hydrogen_bond_type = None - hydrogen_bond = False - disulfide_bond_type = None - disulfide_bond = False - diselenide_bond_type = None - diselenide_bond = False - other_bond_type = None - other_bond = False - symmetry = False + hydrogen_bond_type = disulfide_bond_type = diselenide_bond_type = other_bond_type = None + + hydrogen_bond = disulfide_bond = diselenide_bond = other_bond = symmetry = False if chain_id_1 != chain_id_2 or seq_id_1 != seq_id_2: @@ -39716,10 +39508,7 @@ def __getTypeOfCovalentBond(self, file_type, lp_data, row_id, target_value, is_bb_atom_2 = _atom_id_2[0] in self.__csStat.getBackBoneAtoms(comp_id_2) else: - is_bb_atom_1 = False - is_bb_atom_2 = False - is_sc_atom_1 = False - is_sc_atom_2 = False + is_bb_atom_1 = is_bb_atom_2 = is_sc_atom_1 = is_sc_atom_2 = False else: is_sc_atom_1 = atom_id_1 in self.__csStat.getSideChainAtoms(comp_id_1) @@ -39796,20 +39585,12 @@ def __calculateStatsOfDihedralRestraint(self, file_list_id, lp_data, conflict_id try: - count = {} - comb_count = {} - inco_count = {} - redu_count = {} - polymer_types = {} - weights = {} - potential_types = {} + count, comb_count, inco_count, redu_count, polymer_types, weights, potential_types =\ + {}, {}, {}, {}, {}, {}, {} + set_id = set() - phi_list = [] - psi_list = [] - chi1_list = [] - chi2_list = [] - value_per_residue = [] + phi_list, psi_list, chi1_list, chi2_list, value_per_residue = [], [], [], [], [] polymer_sequence = input_source_dic['polymer_sequence'] @@ -39877,8 +39658,7 @@ def __calculateStatsOfDihedralRestraint(self, file_list_id, lp_data, conflict_id upper_limit += 360.0 else: - lower_limit = None - upper_limit = None + lower_limit = upper_limit = None data_type = row[angle_type_name] @@ -39965,18 +39745,20 @@ def __calculateStatsOfDihedralRestraint(self, file_list_id, lp_data, conflict_id else: polymer_types['other'] = 1 - seq_ids = [] + seq_ids, comp_ids = [], [] + seq_ids.append(seq_id_1) seq_ids.append(seq_id_2) seq_ids.append(seq_id_3) seq_ids.append(seq_id_4) - comp_ids = [] + + seq_id_common = collections.Counter(seq_ids).most_common() + comp_ids.append(comp_id_1) comp_ids.append(comp_id_2) comp_ids.append(comp_id_3) comp_ids.append(comp_id_4) - seq_id_common = collections.Counter(seq_ids).most_common() comp_id_common = collections.Counter(comp_ids).most_common() if data_type.startswith('phi_'): @@ -40106,8 +39888,7 @@ def __calculateStatsOfDihedralRestraint(self, file_list_id, lp_data, conflict_id if 'phi_angle_constraints' in count and 'psi_angle_constraints' in count: - phi_psi_value = {} - phi_psi_error = {} + phi_psi_value, phi_psi_error = {}, {} for phi in phi_list: @@ -40144,8 +39925,7 @@ def __calculateStatsOfDihedralRestraint(self, file_list_id, lp_data, conflict_id if 'chi1_angle_constraints' in count and 'chi2_angle_constraints' in count: - chi1_chi2_value = {} - chi1_chi2_error = {} + chi1_chi2_value, chi1_chi2_error = {}, {} for chi1 in chi1_list: @@ -40331,8 +40111,7 @@ def __calculateStatsOfDihedralRestraint(self, file_list_id, lp_data, conflict_id while scale > target_scale: scale /= 2.0 - range_of_vals = [] - count_of_vals = [] + range_of_vals, count_of_vals = [], [] v = 0.0 while v < min_val: @@ -40625,12 +40404,9 @@ def __calculateStatsOfRdcRestraint(self, file_list_id, lp_data, conflict_id_set, weight_name = self.weight_tags[file_type]['rdc_restraint'] id_tag = self.consist_id_tags[file_type]['rdc_restraint'] - count = {} - comb_count = {} - inco_count = {} - redu_count = {} - weights = {} - potential_types = {} + count, comb_count, inco_count, redu_count, weights, potential_types =\ + {}, {}, {}, {}, {}, {} + set_id = set() value_per_residue = [] @@ -40786,8 +40562,7 @@ def __calculateStatsOfRdcRestraint(self, file_list_id, lp_data, conflict_id_set, while scale > target_scale: scale /= 2.0 - range_of_vals = [] - count_of_vals = [] + range_of_vals, count_of_vals = [], [] v = 0.0 while v < min_val: @@ -40864,8 +40639,7 @@ def __calculateStatsOfRdcRestraint(self, file_list_id, lp_data, conflict_id_set, max_inclusive = RDC_UNCERT_MAX - max_val = 0.0 - min_val = 0.0 + max_val = min_val = 0.0 rdc_ann = [] @@ -40962,8 +40736,7 @@ def __calculateStatsOfRdcRestraint(self, file_list_id, lp_data, conflict_id_set, while scale > target_scale: scale /= 2.0 - range_of_vals = [] - count_of_vals = [] + range_of_vals, count_of_vals = [], [] v = 0.0 while v < min_val: @@ -41141,10 +40914,7 @@ def __calculateStatsOfSpectralPeak(self, file_list_id, sf_framecode, num_dim, lp _d[k] = v item_names.append(_d) - chain_id_names = [] - seq_id_names = [] - comp_id_names = [] - atom_id_names = [] + chain_id_names, seq_id_names, comp_id_names, atom_id_names = [], [], [], [] try: @@ -41177,12 +40947,7 @@ def __calculateStatsOfSpectralPeak(self, file_list_id, sf_framecode, num_dim, lp if aux_data is not None: for i in range(1, max_dim): for sp_dim in aux_data: - sp_freq = None - center_point = None - under_sampling_type = None - encoding_code = None - encoded_src_dim_id = None - mag_link_id = None + sp_freq = center_point = under_sampling_type = encoding_code = encoded_src_dim_id = mag_link_id = None if file_type == 'nef': if sp_dim['dimension_id'] != i: continue @@ -41444,12 +41209,7 @@ def __calculateStatsOfSpectralPeakAlt(self, file_list_id, sf_framecode, num_dim, if aux_data is not None: for i in range(1, max_dim): for sp_dim in aux_data: - sp_freq = None - center_point = None - under_sampling_type = None - encoding_code = None - encoded_src_dim_id = None - mag_link_id = None + sp_freq = center_point = under_sampling_type = encoding_code = encoded_src_dim_id = mag_link_id = None if sp_dim['ID'] != i: continue axis_code = sp_dim['Axis_code'] @@ -42296,9 +42056,7 @@ def __extractCoordPolymerSequence(self): cif_input_source.setItemValue('polymer_sequence', poly_seq) - not_superimposed_ensemble = {} - exactly_overlaid_ensemble = {} - exactly_overlaid_models = {} + not_superimposed_ensemble, exactly_overlaid_ensemble, exactly_overlaid_models = {}, {}, {} if not self.__combined_mode and self.__allow_missing_legacy_dist_restraint: # no exception @@ -43204,13 +42962,9 @@ def __appendCoordPolymerSequenceAlignment(self): len_s1 = len(_s1['seq_id']) len_s2 = len(_s2['seq_id']) - seq_id1 = [] - seq_id2 = [] - comp_id1 = [] - comp_id2 = [] + seq_id1, seq_id2, comp_id1, comp_id2 = [], [], [], [] - idx1 = 0 - idx2 = 0 + idx1 = idx2 = 0 for i in range(length): myPr = myAlign[i] myPr0 = str(myPr[0]) @@ -43359,13 +43113,9 @@ def __appendCoordPolymerSequenceAlignment(self): len_s1 = len(_s1['seq_id']) len_s2 = len(_s2['seq_id']) - seq_id1 = [] - seq_id2 = [] - comp_id1 = [] - comp_id2 = [] + seq_id1, seq_id2, comp_id1, comp_id2 = [], [], [], [] - idx1 = 0 - idx2 = 0 + idx1 = idx2 = 0 for i in range(length): myPr = myAlign[i] myPr0 = str(myPr[0]) @@ -43517,8 +43267,7 @@ def __assignCoordPolymerSequence(self): # from model to nmr (first trial, never raise a warning or an error) - mat = [] - indices = [] + mat, indices = [], [] for s1 in cif_polymer_sequence: chain_id = s1['chain_id'] @@ -43684,8 +43433,7 @@ def __assignCoordPolymerSequence(self): if result['unmapped'] > 0 or result['conflict'] > 0: aligned = [True] * length - seq_id1 = [] - seq_id2 = [] + seq_id1, seq_id2 = [], [] j = 0 for i in range(length): @@ -43750,10 +43498,8 @@ def __assignCoordPolymerSequence(self): if not low_evid_chain_mapping: # DAOTHER-8751 continue - unmapped = [] - conflict = [] - # offset_1 = 0 - # offset_2 = 0 + unmapped, conflict = [], [] + # offset_1 = offset_2 = 0 for i in range(length): myPr = myAlign[i] @@ -43792,8 +43538,7 @@ def __assignCoordPolymerSequence(self): ca_idx = 0 - mat = [] - indices = [] + mat, indices = [], [] for s1 in nmr_polymer_sequence: chain_id = s1['chain_id'] @@ -43968,8 +43713,7 @@ def __assignCoordPolymerSequence(self): if result['unmapped'] > 0 or result['conflict'] > 0: aligned = [True] * length - seq_id1 = [] - seq_id2 = [] + seq_id1, seq_id2 = [], [] j = 0 for i in range(length): @@ -44048,10 +43792,8 @@ def __assignCoordPolymerSequence(self): if not low_evid_chain_mapping: # DAOTHER-8751 continue - unmapped = [] - conflict = [] - # offset_1 = 0 - # offset_2 = 0 + unmapped, conflict = [], [] + # offset_1 = offset_2 = 0 for i in range(length): myPr = myAlign[i] @@ -44262,8 +44004,7 @@ def __assignCoordPolymerSequence(self): if len(cif_ident_chain_id) == len(nmr_ident_chain_id) and len(cif_ident_chain_id) > 1: _chain_assign = chain_assign.copy() - nmr_mapped_chain_id = [] - cif_mapped_chain_id = [] + nmr_mapped_chain_id, cif_mapped_chain_id = [], [] for ca in _chain_assign: @@ -44307,8 +44048,7 @@ def __assignCoordPolymerSequence(self): ca_idx = 0 - mat = [] - indices = [] + mat, indices = [], [] for s1 in cif_polymer_sequence: chain_id = s1['chain_id'] @@ -44510,8 +44250,7 @@ def __assignCoordPolymerSequence(self): if result['unmapped'] > 0 or result['conflict'] > 0: aligned = [True] * length - seq_id1 = [] - seq_id2 = [] + seq_id1, seq_id2 = [], [] j = 0 for i in range(length): @@ -44576,10 +44315,8 @@ def __assignCoordPolymerSequence(self): if not low_evid_chain_mapping: # DAOTHER-8751 continue - unmapped = [] - conflict = [] - # offset_1 = 0 - # offset_2 = 0 + unmapped, conflict = [], [] + # offset_1 = offset_2 = 0 for i in range(length): myPr = myAlign[i] @@ -44795,8 +44532,7 @@ def __assignCoordPolymerSequence(self): if len(cif_ident_chain_id) == len(nmr_ident_chain_id) and len(cif_ident_chain_id) > 1: _chain_assign = chain_assign.copy() - nmr_mapped_chain_id = [] - cif_mapped_chain_id = [] + nmr_mapped_chain_id, cif_mapped_chain_id = [], [] for ca in _chain_assign: @@ -45426,10 +45162,7 @@ def __testCoordAtomIdConsistency__(self, file_list_id, file_name, file_type, con num_dim = max_dim - 1 - chain_id_names = [] - seq_id_names = [] - comp_id_names = [] - atom_id_names = [] + chain_id_names, seq_id_names, comp_id_names, atom_id_names = [], [], [], [] if file_type == 'nmr-star': alt_seq_id_names = [] @@ -46468,10 +46201,7 @@ def __updatePolymerSequence(self): orig_lp_data = None - has_res_var_dat = False - - has_nef_index = False - has_entry_id = False + has_res_var_dat = has_nef_index = has_entry_id = False sf_framecode = 'assembly' @@ -48901,8 +48631,7 @@ def __testTautomerOfHistidinePerModel(self): _protons = [h for h in protons if h['model_id'] == model_id] - has_hd1 = False - has_he2 = False + has_hd1 = has_he2 = False for h in _protons: if h['atom_id'] == hd1_name: @@ -49014,8 +48743,7 @@ def __getTautomerOfHistidine(self, nmr_chain_id, nmr_seq_id): if len(protons) > 0: - has_hd1 = False - has_he2 = False + has_hd1 = has_he2 = False for h in protons: if h['atom_id'] == 'HD1': @@ -49741,10 +49469,7 @@ def __mapCoordDisulfideBond2Nmr__(self, file_name, file_type, content_subtype, s """ Map disulfide bond of coordinate file to NMR data. """ - ca_chem_shift_1 = None - cb_chem_shift_1 = None - ca_chem_shift_2 = None - cb_chem_shift_2 = None + ca_chem_shift_1 = cb_chem_shift_1 = ca_chem_shift_2 = cb_chem_shift_2 = None key_items = self.key_items[file_type][content_subtype] data_items = self.data_items[file_type][content_subtype] @@ -50136,10 +49861,7 @@ def __mapCoordOtherBond2Nmr__(self, file_name, file_type, content_subtype, sf, s """ Map other bond (neither disulfide nor covalent bond) of coordinate file to NMR data. """ - ca_chem_shift_1 = None - cb_chem_shift_1 = None - ca_chem_shift_2 = None - cb_chem_shift_2 = None + ca_chem_shift_1 = cb_chem_shift_1 = ca_chem_shift_2 = cb_chem_shift_2 = None key_items = self.key_items[file_type][content_subtype] data_items = self.data_items[file_type][content_subtype] @@ -50485,9 +50207,7 @@ def __getNearestAromaticRing(self, nmr_chain_id, nmr_seq_id, nmr_atom_id, cutoff len_model_ids = 0 - dist = 0.0 - ring_dist = 0.0 - ring_angle = 0.0 + dist = ring_dist = ring_angle = 0.0 for model_id in model_ids: @@ -51925,8 +51645,7 @@ def __testDistRestraintAsHydrogenBond(self, lp_data): target_value = row.get(target_value_name) - upper_limit = None - lower_limit = None + upper_limit = lower_limit = None if target_value is None: @@ -52059,8 +51778,7 @@ def __testDistRestraintAsDisulfideBond(self, lp_data): target_value = row.get(target_value_name) - upper_limit = None - lower_limit = None + upper_limit = lower_limit = None if target_value is None: @@ -52231,10 +51949,8 @@ def __testDihedRestraintAsBackBoneChemShifts(self, lp_data): lower_limit_name = item_names['lower_limit'] upper_limit_name = item_names['upper_limit'] - dh_chain_ids = set() - dh_seq_ids = {} - cs_chain_ids = set() - cs_seq_ids = {} + dh_chain_ids, cs_chain_ids = set(), set() + dh_seq_ids, cs_seq_ids = {}, {} try: @@ -53658,23 +53374,22 @@ def __mergeLegacyCsAndMr(self): cst_sf.add_tag('NOE_dist_averaging_method', sf_item['NOE_dist_averaging_method']) break - NOE_tot_num = 0 - - NOE_intraresidue_tot_num = 0 - NOE_sequential_tot_num = 0 - NOE_medium_range_tot_num = 0 - NOE_long_range_tot_num = 0 - NOE_unique_tot_num = 0 - NOE_intraresidue_unique_tot_num = 0 - NOE_sequential_unique_tot_num = 0 - NOE_medium_range_unique_tot_num = 0 - NOE_long_range_unique_tot_num = 0 - NOE_unamb_intramol_tot_num = 0 - NOE_unamb_intermol_tot_num = 0 - NOE_ambig_intramol_tot_num = 0 - NOE_ambig_intermol_tot_num = 0 - NOE_interentity_tot_num = 0 - NOE_other_tot_num = 0 + NOE_tot_num =\ + NOE_intraresidue_tot_num =\ + NOE_sequential_tot_num =\ + NOE_medium_range_tot_num =\ + NOE_long_range_tot_num =\ + NOE_unique_tot_num =\ + NOE_intraresidue_unique_tot_num =\ + NOE_sequential_unique_tot_num =\ + NOE_medium_range_unique_tot_num =\ + NOE_long_range_unique_tot_num =\ + NOE_unamb_intramol_tot_num =\ + NOE_unamb_intermol_tot_num =\ + NOE_ambig_intramol_tot_num =\ + NOE_ambig_intermol_tot_num =\ + NOE_interentity_tot_num =\ + NOE_other_tot_num = 0 for sf_item in self.__mr_sf_dict_holder[content_subtype]: @@ -53817,17 +53532,17 @@ def __mergeLegacyCsAndMr(self): cst_sf.add_tag('ROE_dist_averaging_method', sf_item['ROE_dist_averaging_method']) break - ROE_tot_num = 0 - - ROE_intraresidue_tot_num = 0 - ROE_sequential_tot_num = 0 - ROE_medium_range_tot_num = 0 - ROE_long_range_tot_num = 0 - ROE_unambig_intramol_tot_num = 0 - ROE_unambig_intermol_tot_num = 0 - ROE_ambig_intramol_tot_num = 0 - ROE_ambig_intermol_tot_num = 0 - ROE_other_tot_num = 0 + ROE_tot_num =\ + ROE_intraresidue_tot_num =\ + ROE_sequential_tot_num =\ + ROE_medium_range_tot_num =\ + ROE_long_range_tot_num =\ + ROE_unambig_intramol_tot_num =\ + ROE_unambig_intermol_tot_num =\ + ROE_ambig_intramol_tot_num =\ + ROE_ambig_intermol_tot_num =\ + ROE_other_tot_num = 0 + for sf_item in self.__mr_sf_dict_holder[content_subtype]: sf = sf_item['saveframe'] potential_type = get_first_sf_tag(sf, 'Potential_type') @@ -53938,12 +53653,12 @@ def __mergeLegacyCsAndMr(self): if Dihedral_angle_tot_num > 0: cst_sf.add_tag('Dihedral_angle_tot_num', Dihedral_angle_tot_num) - Protein_dihedral_angle_tot_num = 0 + Protein_dihedral_angle_tot_num =\ + Protein_phi_angle_tot_num =\ + Protein_psi_angle_tot_num =\ + Protein_chi_one_angle_tot_num =\ + Protein_other_angle_tot_num = 0 - Protein_phi_angle_tot_num = 0 - Protein_psi_angle_tot_num = 0 - Protein_chi_one_angle_tot_num = 0 - Protein_other_angle_tot_num = 0 if content_subtype in self.__mr_sf_dict_holder: for sf_item in self.__mr_sf_dict_holder[content_subtype]: self.__updateTorsionAngleConstIdInMrStr(sf_item) @@ -53956,8 +53671,7 @@ def __mergeLegacyCsAndMr(self): auth_comp_id_col = lp.tags.index('Auth_comp_ID_2') angle_name_col = lp.tags.index('Torsion_angle_name') - _protein_angles = _other_angles = 0 - _protein_bb_angles = _protein_oth_angles = 0 + _protein_angles = _other_angles = _protein_bb_angles = _protein_oth_angles = 0 prev_id = -1 for row in lp: @@ -54008,9 +53722,7 @@ def __mergeLegacyCsAndMr(self): else: - _protein_jcoups = 0 - _protein_bb_jcoups = 0 - _protein_oth_jcoups = 0 + _protein_jcoups = _protein_bb_jcoups = _protein_oth_jcoups = 0 for _sf_item in self.__mr_sf_dict_holder['jcoup_restraint']: @@ -54062,16 +53774,16 @@ def __mergeLegacyCsAndMr(self): cst_sf.add_tag('Protein_chi_one_angle_tot_num', Protein_chi_one_angle_tot_num) cst_sf.add_tag('Protein_other_angle_tot_num', Protein_other_angle_tot_num) - NA_dihedral_angle_tot_num = 0 + NA_dihedral_angle_tot_num =\ + NA_alpha_angle_tot_num =\ + NA_beta_angle_tot_num =\ + NA_gamma_angle_tot_num =\ + NA_delta_angle_tot_num =\ + NA_epsilon_angle_tot_num =\ + NA_chi_angle_tot_num =\ + NA_other_angle_tot_num =\ + NA_amb_dihedral_angle_tot_num = 0 - NA_alpha_angle_tot_num = 0 - NA_beta_angle_tot_num = 0 - NA_gamma_angle_tot_num = 0 - NA_delta_angle_tot_num = 0 - NA_epsilon_angle_tot_num = 0 - NA_chi_angle_tot_num = 0 - NA_other_angle_tot_num = 0 - NA_amb_dihedral_angle_tot_num = 0 if content_subtype in self.__mr_sf_dict_holder: for sf_item in self.__mr_sf_dict_holder[content_subtype]: @@ -54256,30 +53968,27 @@ def __mergeLegacyCsAndMr(self): content_subtype = 'rdc_restraint' - RDC_tot_num = 0 - - RDC_HH_tot_num = 0 - RDC_HNC_tot_num = 0 - RDC_NH_tot_num = 0 - RDC_CC_tot_num = 0 - RDC_CN_i_1_tot_num = 0 - RDC_CAHA_tot_num = 0 - RDC_HNHA_tot_num = 0 - RDC_HNHA_i_1_tot_num = 0 - RDC_CAC_tot_num = 0 - RDC_CAN_tot_num = 0 - RDC_other_tot_num = 0 - - RDC_intraresidue_tot_num = 0 - RDC_sequential_tot_num = 0 - RDC_medium_range_tot_num = 0 - RDC_long_range_tot_num = 0 - - RDC_unambig_intramol_tot_num = 0 - RDC_unambig_intermol_tot_num = 0 - RDC_ambig_intramol_tot_num = 0 - RDC_ambig_intermol_tot_num = 0 - RDC_intermol_tot_num = 0 + RDC_tot_num =\ + RDC_HH_tot_num =\ + RDC_HNC_tot_num =\ + RDC_NH_tot_num =\ + RDC_CC_tot_num =\ + RDC_CN_i_1_tot_num =\ + RDC_CAHA_tot_num =\ + RDC_HNHA_tot_num =\ + RDC_HNHA_i_1_tot_num =\ + RDC_CAC_tot_num =\ + RDC_CAN_tot_num =\ + RDC_other_tot_num =\ + RDC_intraresidue_tot_num =\ + RDC_sequential_tot_num =\ + RDC_medium_range_tot_num =\ + RDC_long_range_tot_num =\ + RDC_unambig_intramol_tot_num =\ + RDC_unambig_intermol_tot_num =\ + RDC_ambig_intramol_tot_num =\ + RDC_ambig_intermol_tot_num =\ + RDC_intermol_tot_num = 0 if content_subtype in self.__mr_sf_dict_holder: for sf_item in self.__mr_sf_dict_holder[content_subtype]: @@ -54618,8 +54327,7 @@ def __mergeLegacyCsAndMr(self): content_subtype = 'other_restraint' if content_subtype in self.__mr_sf_dict_holder: - Protein_other_tot_num = 0 - NA_other_tot_num = 0 + Protein_other_tot_num = NA_other_tot_num = 0 for sf_item in self.__mr_sf_dict_holder[content_subtype]: lp = sf_item['loop'] lp_tags = lp['tags'] @@ -54711,8 +54419,7 @@ def __mergeLegacyCsAndMr(self): software_id = max(software_id, _id_) file_name_dict = {} - file_id = 0 - block_id = 0 + file_id = block_id = 0 for content_subtype in self.mr_content_subtypes: if self.__mr_sf_dict_holder is not None and content_subtype in self.__mr_sf_dict_holder: @@ -54872,8 +54579,7 @@ def __mergeLegacyCsAndMr(self): dir_path = os.path.dirname(file_path) - details = None - data_format = None + details = data_format = None unknown_mr_desc = os.path.join(dir_path, '.entry_with_unknown_mr') if os.path.exists(unknown_mr_desc): @@ -55645,10 +55351,7 @@ def __updateConstraintStats(self): if sf_item[sf_framecode]['constraint_subsubtype'] == 'simple': - metal_coord = False - disele_bond = False - disulf_bond = False - hydrog_bond = False + metal_coord = disele_bond = disulf_bond = hydrog_bond = False for row in lp: comp_id_1 = row[comp_id_1_col] @@ -55709,23 +55412,22 @@ def __updateConstraintStats(self): elif not metal_coord and not disele_bond and not disulf_bond and hydrog_bond: sf_item[sf_framecode]['constraint_subtype'] = 'hydrogen bond' - NOE_tot_num = 0 - - NOE_intraresidue_tot_num = 0 - NOE_sequential_tot_num = 0 - NOE_medium_range_tot_num = 0 - NOE_long_range_tot_num = 0 - NOE_unique_tot_num = 0 - NOE_intraresidue_unique_tot_num = 0 - NOE_sequential_unique_tot_num = 0 - NOE_medium_range_unique_tot_num = 0 - NOE_long_range_unique_tot_num = 0 - NOE_unamb_intramol_tot_num = 0 - NOE_unamb_intermol_tot_num = 0 - NOE_ambig_intramol_tot_num = 0 - NOE_ambig_intermol_tot_num = 0 - NOE_interentity_tot_num = 0 - NOE_other_tot_num = 0 + NOE_tot_num =\ + NOE_intraresidue_tot_num =\ + NOE_sequential_tot_num =\ + NOE_medium_range_tot_num =\ + NOE_long_range_tot_num =\ + NOE_unique_tot_num =\ + NOE_intraresidue_unique_tot_num =\ + NOE_sequential_unique_tot_num =\ + NOE_medium_range_unique_tot_num =\ + NOE_long_range_unique_tot_num =\ + NOE_unamb_intramol_tot_num =\ + NOE_unamb_intermol_tot_num =\ + NOE_ambig_intramol_tot_num =\ + NOE_ambig_intermol_tot_num =\ + NOE_interentity_tot_num =\ + NOE_other_tot_num = 0 for sf in master_entry.get_saveframes_by_category(sf_category): sf_framecode = get_first_sf_tag(sf, 'sf_framecode') @@ -55863,17 +55565,16 @@ def __updateConstraintStats(self): cst_sf.add_tag('ROE_dist_averaging_method', avr_method) break - ROE_tot_num = 0 - - ROE_intraresidue_tot_num = 0 - ROE_sequential_tot_num = 0 - ROE_medium_range_tot_num = 0 - ROE_long_range_tot_num = 0 - ROE_unambig_intramol_tot_num = 0 - ROE_unambig_intermol_tot_num = 0 - ROE_ambig_intramol_tot_num = 0 - ROE_ambig_intermol_tot_num = 0 - ROE_other_tot_num = 0 + ROE_tot_num =\ + ROE_intraresidue_tot_num =\ + ROE_sequential_tot_num =\ + ROE_medium_range_tot_num =\ + ROE_long_range_tot_num =\ + ROE_unambig_intramol_tot_num =\ + ROE_unambig_intermol_tot_num =\ + ROE_ambig_intramol_tot_num =\ + ROE_ambig_intermol_tot_num =\ + ROE_other_tot_num = 0 for sf in master_entry.get_saveframes_by_category(sf_category): sf_framecode = get_first_sf_tag(sf, 'sf_framecode') @@ -56056,12 +55757,11 @@ def __updateConstraintStats(self): if Dihedral_angle_tot_num > 0: cst_sf.add_tag('Dihedral_angle_tot_num', Dihedral_angle_tot_num) - Protein_dihedral_angle_tot_num = 0 - - Protein_phi_angle_tot_num = 0 - Protein_psi_angle_tot_num = 0 - Protein_chi_one_angle_tot_num = 0 - Protein_other_angle_tot_num = 0 + Protein_dihedral_angle_tot_num =\ + Protein_phi_angle_tot_num =\ + Protein_psi_angle_tot_num =\ + Protein_chi_one_angle_tot_num =\ + Protein_other_angle_tot_num = 0 for sf in master_entry.get_saveframes_by_category(sf_category): sf_framecode = get_first_sf_tag(sf, 'sf_framecode') @@ -56135,16 +55835,15 @@ def __updateConstraintStats(self): cst_sf.add_tag('Protein_chi_one_angle_tot_num', Protein_chi_one_angle_tot_num) cst_sf.add_tag('Protein_other_angle_tot_num', Protein_other_angle_tot_num) - NA_dihedral_angle_tot_num = 0 - - NA_alpha_angle_tot_num = 0 - NA_beta_angle_tot_num = 0 - NA_gamma_angle_tot_num = 0 - NA_delta_angle_tot_num = 0 - NA_epsilon_angle_tot_num = 0 - NA_chi_angle_tot_num = 0 - NA_other_angle_tot_num = 0 - NA_amb_dihedral_angle_tot_num = 0 + NA_dihedral_angle_tot_num =\ + NA_alpha_angle_tot_num =\ + NA_beta_angle_tot_num =\ + NA_gamma_angle_tot_num =\ + NA_delta_angle_tot_num =\ + NA_epsilon_angle_tot_num =\ + NA_chi_angle_tot_num =\ + NA_other_angle_tot_num =\ + NA_amb_dihedral_angle_tot_num = 0 for sf in master_entry.get_saveframes_by_category(sf_category): sf_framecode = get_first_sf_tag(sf, 'sf_framecode') @@ -56350,30 +56049,27 @@ def __updateConstraintStats(self): sf_item[sf_framecode]['id'] = count - RDC_tot_num = 0 - - RDC_HH_tot_num = 0 - RDC_HNC_tot_num = 0 - RDC_NH_tot_num = 0 - RDC_CC_tot_num = 0 - RDC_CN_i_1_tot_num = 0 - RDC_CAHA_tot_num = 0 - RDC_HNHA_tot_num = 0 - RDC_HNHA_i_1_tot_num = 0 - RDC_CAC_tot_num = 0 - RDC_CAN_tot_num = 0 - RDC_other_tot_num = 0 - - RDC_intraresidue_tot_num = 0 - RDC_sequential_tot_num = 0 - RDC_medium_range_tot_num = 0 - RDC_long_range_tot_num = 0 - - RDC_unambig_intramol_tot_num = 0 - RDC_unambig_intermol_tot_num = 0 - RDC_ambig_intramol_tot_num = 0 - RDC_ambig_intermol_tot_num = 0 - RDC_intermol_tot_num = 0 + RDC_tot_num =\ + RDC_HH_tot_num =\ + RDC_HNC_tot_num =\ + RDC_NH_tot_num =\ + RDC_CC_tot_num =\ + RDC_CN_i_1_tot_num =\ + RDC_CAHA_tot_num =\ + RDC_HNHA_tot_num =\ + RDC_HNHA_i_1_tot_num =\ + RDC_CAC_tot_num =\ + RDC_CAN_tot_num =\ + RDC_other_tot_num =\ + RDC_intraresidue_tot_num =\ + RDC_sequential_tot_num =\ + RDC_medium_range_tot_num =\ + RDC_long_range_tot_num =\ + RDC_unambig_intramol_tot_num =\ + RDC_unambig_intermol_tot_num =\ + RDC_ambig_intramol_tot_num =\ + RDC_ambig_intermol_tot_num =\ + RDC_intermol_tot_num = 0 for sf in master_entry.get_saveframes_by_category(sf_category): sf_framecode = get_first_sf_tag(sf, 'sf_framecode') diff --git a/wwpdb/utils/nmr/NmrVrptUtility.py b/wwpdb/utils/nmr/NmrVrptUtility.py index f7a89e4fd..1249158f9 100644 --- a/wwpdb/utils/nmr/NmrVrptUtility.py +++ b/wwpdb/utils/nmr/NmrVrptUtility.py @@ -1273,8 +1273,7 @@ def __extractCoordAtomSite(self): _auth_atom_id_ = 'alt_auth_atom_id' break - atom_id_list_per_model = {} - coordinates_per_model = {} + atom_id_list_per_model, coordinates_per_model = {}, {} for c in coord: atom_key = (c['auth_asym_id'], c['auth_seq_id'], c['auth_comp_id'], @@ -2113,8 +2112,7 @@ def fill_smaller_error_for_each_model(error_per_model, min_error_per_model, min_comb_key_per_model[model_id]['member_id'] = member_id def get_viol_per_model(min_error_per_model, min_comb_key_per_model): - viol_per_model = {} - comb_key_per_model = {} + viol_per_model, comb_key_per_model = {}, {} for model_id in self.__eff_model_ids: error = min_error_per_model[model_id] @@ -2328,8 +2326,7 @@ def fill_smaller_error_for_each_model(error_per_model, min_error_per_model, min_comb_key_per_model[model_id]['combination_id'] = combination_id def get_viol_per_model(min_error_per_model, min_comb_key_per_model): - viol_per_model = {} - comb_key_per_model = {} + viol_per_model, comb_key_per_model = {}, {} for model_id in self.__eff_model_ids: error = min_error_per_model[model_id] @@ -2490,8 +2487,7 @@ def fill_smaller_error_for_each_model(error_per_model, min_error_per_model, min_comb_key_per_model[model_id]['combination_id'] = combination_id def get_viol_per_model(min_error_per_model, min_comb_key_per_model): - viol_per_model = {} - comb_key_per_model = {} + viol_per_model, comb_key_per_model = {}, {} for model_id in self.__eff_model_ids: error = min_error_per_model[model_id] @@ -2604,12 +2600,10 @@ def __summarizeDistanceRestraintAnalysis(self): self.__results['key_lists']['distance_sub_type'] = distance_sub_type self.__results['key_lists']['bond_flag'] = bond_flag - distance_summary = {} - distance_violation = {} + distance_summary, distance_violation = {}, {} - consistent_distance_violation = {} - distance_violations_vs_models = {} - distance_violations_in_models = {} + consistent_distance_violation, distance_violations_vs_models, distance_violations_in_models =\ + {}, {}, {} for m in self.__eff_model_ids: distance_violations_in_models[m] = {} @@ -2868,12 +2862,10 @@ def __summarizeDihedralAngleRestraintAnalysis(self): self.__results['key_lists']['angle_type'] = angle_type - angle_summary = {} - angle_violation = {} + angle_summary, angle_violation = {}, {} - consistent_angle_violation = {} - angle_violations_vs_models = {} - angle_violations_in_models = {} + consistent_angle_violation, angle_violations_vs_models, angle_violations_in_models =\ + {}, {}, {} for m in self.__eff_model_ids: angle_violations_in_models[m] = {} @@ -3034,10 +3026,7 @@ def __summarizeDihedralAngleRestraintAnalysis(self): if comb_key is None: continue - atom_ids_1 = [] - atom_ids_2 = [] - atom_ids_3 = [] - atom_ids_4 = [] + atom_ids_1, atom_ids_2, atom_ids_3, atom_ids_4 = [], [], [], [] angle_type = None for r in self.__dihedRestDictWithCombKey[rest_key][comb_key]: @@ -3113,12 +3102,10 @@ def __summarizeRdcRestraintAnalysis(self): self.__results['key_lists']['rdc_type'] = rdc_type - rdc_summary = {} - rdc_violation = {} + rdc_summary, rdc_violation = {}, {} - consistent_rdc_violation = {} - rdc_violations_vs_models = {} - rdc_violations_in_models = {} + consistent_rdc_violation, rdc_violations_vs_models, rdc_violations_in_models =\ + {}, {}, {} for m in self.__eff_model_ids: rdc_violations_in_models[m] = {} @@ -3275,8 +3262,7 @@ def __summarizeRdcRestraintAnalysis(self): if comb_key is None: continue - atom_ids_1 = [] - atom_ids_2 = [] + atom_ids_1, atom_ids_2 = [], [] rdc_type = None for r in self.__rdcRestDictWithCombKey[rest_key][comb_key]: diff --git a/wwpdb/utils/nmr/README.md b/wwpdb/utils/nmr/README.md index 14e68c392..6df335f74 100644 --- a/wwpdb/utils/nmr/README.md +++ b/wwpdb/utils/nmr/README.md @@ -280,7 +280,7 @@ nm-aux-amb|nm-aux-amb|nmr-restraints/any|Topology file in AMBER format nm-res-amb|nm-res-amb|nmr-restraints/amber|Restraint file in AMBER format nm-res-ari|nm-res-ari|nmr-restraints/aria|Restraint file in ARIA format nm-res-bio|nm-res-bio|nmr-restraints/biosym|Restraint file in BIOSYM format -nm-aux-cha|**not applicable**|nmr-restraints/any|Topology file in CHARMM format (aka. CHARMM extended CRD) +nm-aux-cha|nm-aux-cha|nmr-restraints/any|Topology file in CHARMM format (aka. CHARMM extended CRD) nm-res-cha|nm-res-cha|nmr-restraints/charmm|Restraint file in CHARMM format nm-res-cns|nm-res-cns|nmr-restraints/cns|Restraint file in CNS format nm-res-cya|nm-res-cya|nmr-restraints/cyana|Restraint file in CYANA format diff --git a/wwpdb/utils/nmr/io/CifReader.py b/wwpdb/utils/nmr/io/CifReader.py index 2e9ab2270..2b9bae88d 100644 --- a/wwpdb/utils/nmr/io/CifReader.py +++ b/wwpdb/utils/nmr/io/CifReader.py @@ -555,9 +555,7 @@ def getDictListWithFilter(self, catName, dataItems, filterItems=None, blockId=No len_catName = len(catName) + 2 # get column name index - colDict = {} - fcolDict = {} - fetchDict = {} # 'fetch_first_match': True + colDict, fcolDict, fetchDict = {}, {}, {} # 'fetch_first_match': True itNameList = [name[len_catName:] for name in catObj.getItemNameList()] @@ -734,8 +732,7 @@ def getPolymerSequence(self, catName, keyItems, withStructConf=False, withRmsd=F len_catName = len(catName) + 2 # get column name index - itDict = {} - altDict = {} + itDict, altDict = {}, {} itNameList = [name[len_catName:] for name in catObj.getItemNameList()] @@ -750,9 +747,7 @@ def getPolymerSequence(self, catName, keyItems, withStructConf=False, withRmsd=F # get row list rowList = catObj.getRowList() _rowList = None - unmapSeqIds = {} - unmapAuthSeqIds = {} - mapAuthSeqIds = {} + unmapSeqIds, unmapAuthSeqIds, mapAuthSeqIds = {}, {}, {} chainIdWoDefault = set() entityPoly = self.getDictList('entity_poly') @@ -835,13 +830,8 @@ def getPolymerSequence(self, catName, keyItems, withStructConf=False, withRmsd=F row[itCol] = row[itDict[keyItems[j]['default-from']]] continue - compDict = {} - seqDict = {} - insCodeDict = {} - authSeqDict = {} - labelSeqDict = {} - - authChainDict = {} + compDict, seqDict, insCodeDict, authSeqDict, labelSeqDict, authChainDict =\ + {}, {}, {}, {}, {}, {} chain_id_col = altDict['chain_id'] seq_id_col = altDict['seq_id'] @@ -936,7 +926,7 @@ def getPolymerSequence(self, catName, keyItems, withStructConf=False, withRmsd=F largeAssembly = catName == 'pdbx_poly_seq_scheme' and len(chainIds) > LEN_MAJOR_ASYM_ID caRmsd = caWellDefinedRegion = None - polyPeptideChains = polyPeptideLengths = [] + polyPeptideChains, polyPeptideLengths = [], [] _seqDict = copy.deepcopy(seqDict) @@ -1665,9 +1655,7 @@ def __calculateRmsd(self, chain_ids, lengths, total_models=1, eff_model_ids: lis key=itemgetter(0, 1)) _bb_atom_site_p = [_a for _a in _bb_atom_site_ref if (_a['chain_id'], _a['seq_id']) in _seq_keys] - core_rmsd = [] - align_rmsd = [] - exact_overlaid_model_ids = [] + core_rmsd, align_rmsd, exact_overlaid_model_ids = [], [], [] for test_model_id in eff_model_ids: diff --git a/wwpdb/utils/nmr/io/mmCIFUtil.py b/wwpdb/utils/nmr/io/mmCIFUtil.py index 8d49c0c81..f3f517381 100644 --- a/wwpdb/utils/nmr/io/mmCIFUtil.py +++ b/wwpdb/utils/nmr/io/mmCIFUtil.py @@ -82,8 +82,7 @@ def GetBlockIDList(self): def GetValueAndItemByBlock(self, blockName, catName, ext=1): """ Get category values and item names """ - dList = [] - iList = [] + dList, iList = [], [] if blockName not in self.__dataMap: return dList, iList # diff --git a/wwpdb/utils/nmr/mr/AmberPTParserListener.py b/wwpdb/utils/nmr/mr/AmberPTParserListener.py index e8699fa57..ef1dec71e 100644 --- a/wwpdb/utils/nmr/mr/AmberPTParserListener.py +++ b/wwpdb/utils/nmr/mr/AmberPTParserListener.py @@ -819,9 +819,7 @@ def is_metal_elem(prev_atom_name, prev_seq_id, seq_id): "Please verify the two sequences and re-upload the correct file(s) if required.") assi_ref_chain_ids = {} - proc_test_chain_ids = [] - atom_nums = [] - delete_atom_nums = [] + proc_test_chain_ids, atom_nums, delete_atom_nums = [], [], [] def update_atom_num(seq_align, orphan): ref_chain_id = seq_align['ref_chain_id'] @@ -1021,8 +1019,7 @@ def update_atom_num(seq_align, orphan): if self.__hasNonPolyModel: compIdMapping = {} - mappedSeqVal = [] - mappedAtomNum = [] + mappedSeqVal, mappedAtomNum = [], [] for np in self.__nonPolyModel: authChainId = np['auth_chain_id'] diff --git a/wwpdb/utils/nmr/mr/AriaMRParserListener.py b/wwpdb/utils/nmr/mr/AriaMRParserListener.py index cc46e3bd2..0f6c52ee2 100644 --- a/wwpdb/utils/nmr/mr/AriaMRParserListener.py +++ b/wwpdb/utils/nmr/mr/AriaMRParserListener.py @@ -669,8 +669,7 @@ def exitAria_mr(self, ctx: AriaMRParser.Aria_mrContext): # pylint: disable=unus poly_seq_model = next(ps for ps in self.__polySeq if ps['auth_chain_id'] == ref_chain_id) - seq_id_mapping = {} - comp_id_mapping = {} + seq_id_mapping, comp_id_mapping = {}, {} for seq_id, comp_id in zip(ps['seq_id'], ps['comp_id']): if seq_id in sa['test_seq_id']: diff --git a/wwpdb/utils/nmr/mr/BiosymMRParserListener.py b/wwpdb/utils/nmr/mr/BiosymMRParserListener.py index be75f427b..529254250 100644 --- a/wwpdb/utils/nmr/mr/BiosymMRParserListener.py +++ b/wwpdb/utils/nmr/mr/BiosymMRParserListener.py @@ -682,8 +682,7 @@ def exitBiosym_mr(self, ctx: BiosymMRParser.Biosym_mrContext): # pylint: disabl poly_seq_model = next(ps for ps in self.__polySeq if ps['auth_chain_id'] == ref_chain_id) - seq_id_mapping = {} - comp_id_mapping = {} + seq_id_mapping, comp_id_mapping = {}, {} for seq_id, comp_id in zip(ps['seq_id'], ps['comp_id']): if seq_id in sa['test_seq_id']: diff --git a/wwpdb/utils/nmr/mr/CharmmCRDParserListener.py b/wwpdb/utils/nmr/mr/CharmmCRDParserListener.py index ec6fc1858..0193dfb82 100644 --- a/wwpdb/utils/nmr/mr/CharmmCRDParserListener.py +++ b/wwpdb/utils/nmr/mr/CharmmCRDParserListener.py @@ -174,9 +174,7 @@ def exitCharmm_crd(self, ctx: CharmmCRDParser.Charmm_crdContext): # pylint: dis if terminus[-1]: terminus[-1] = False - seqIdList = [] - compIdList = [] - retrievedAtomNumList = [] + seqIdList, compIdList, retrievedAtomNumList = [], [], [] NON_METAL_ELEMENTS = ('H', 'C', 'N', 'O', 'P', 'S') @@ -253,8 +251,7 @@ def is_metal_elem(prev_atom_name, prev_seq_id, seq_id): self.__polySeqPrmTop.append({'chain_id': chainId, 'seq_id': seqIdList, 'auth_comp_id': compIdList}) - seqIdList = [] - compIdList = [] + seqIdList, compIdList = [], [] chainIndex += 1 chainId = indexToLetter(chainIndex) offset = 1 - _seqId @@ -460,9 +457,7 @@ def is_metal_elem(prev_atom_name, prev_seq_id, seq_id): len_top_na = sum(len(ps_top['seq_id']) for ps_top in self.__polySeqPrmTop if len(ps_top['seq_id']) > 3 and any(compId in ('DA?', 'DT?', 'DG?', 'DC?', 'A?', 'U?', 'G?', 'C?') for compId in ps_top['comp_id'])) if len_cif_na == len_top_na: - chainIdList = [] - seqIdList = [] - authCompIdList = [] + chainIdList, seqIdList, authCompIdList = [], [], [] for ps_top in self.__polySeqPrmTop: len_ps_cif_seq = len(ps_top['seq_id']) if len_ps_cif_seq > 3 and any(compId in ('DA?', 'DT?', 'DG?', 'DC?', 'A?', 'U?', 'G?', 'C?') for compId in ps_top['comp_id']): @@ -554,9 +549,7 @@ def is_metal_elem(prev_atom_name, prev_seq_id, seq_id): "Please verify the two sequences and re-upload the correct file(s) if required.") assi_ref_chain_ids = {} - proc_test_chain_ids = [] - atom_nums = [] - delete_atom_nums = [] + proc_test_chain_ids, atom_nums, delete_atom_nums = [], [], [] def update_atom_num(seq_align, orphan): ref_chain_id = seq_align['ref_chain_id'] @@ -747,8 +740,7 @@ def update_atom_num(seq_align, orphan): if self.__hasNonPolyModel: compIdMapping = {} - mappedSeqVal = [] - mappedAtomNum = [] + mappedSeqVal, mappedAtomNum = [], [] for np in self.__nonPolyModel: authChainId = np['auth_chain_id'] diff --git a/wwpdb/utils/nmr/mr/CyanaMRParserListener.py b/wwpdb/utils/nmr/mr/CyanaMRParserListener.py index 8730616ed..69932895d 100644 --- a/wwpdb/utils/nmr/mr/CyanaMRParserListener.py +++ b/wwpdb/utils/nmr/mr/CyanaMRParserListener.py @@ -855,8 +855,7 @@ def exitCyana_mr(self, ctx: CyanaMRParser.Cyana_mrContext): # pylint: disable=u poly_seq_model = next(ps for ps in self.__polySeq if ps['auth_chain_id'] == ref_chain_id) - seq_id_mapping = {} - comp_id_mapping = {} + seq_id_mapping, comp_id_mapping = {}, {} for seq_id, comp_id in zip(ps['seq_id'], ps['comp_id']): if seq_id in sa['test_seq_id']: diff --git a/wwpdb/utils/nmr/mr/CyanaNOAParserListener.py b/wwpdb/utils/nmr/mr/CyanaNOAParserListener.py index a8cc2b515..cc60d3542 100644 --- a/wwpdb/utils/nmr/mr/CyanaNOAParserListener.py +++ b/wwpdb/utils/nmr/mr/CyanaNOAParserListener.py @@ -701,8 +701,7 @@ def exitCyana_noa(self, ctx: CyanaNOAParser.Cyana_noaContext): # pylint: disabl poly_seq_model = next(ps for ps in self.__polySeq if ps['auth_chain_id'] == ref_chain_id) - seq_id_mapping = {} - comp_id_mapping = {} + seq_id_mapping, comp_id_mapping = {}, {} for seq_id, comp_id in zip(ps['seq_id'], ps['comp_id']): if seq_id in sa['test_seq_id']: diff --git a/wwpdb/utils/nmr/mr/DynamoMRParserListener.py b/wwpdb/utils/nmr/mr/DynamoMRParserListener.py index 9b7fff17c..df2d67d4f 100644 --- a/wwpdb/utils/nmr/mr/DynamoMRParserListener.py +++ b/wwpdb/utils/nmr/mr/DynamoMRParserListener.py @@ -730,8 +730,7 @@ def exitDynamo_mr(self, ctx: DynamoMRParser.Dynamo_mrContext): # pylint: disabl poly_seq_model = next(ps for ps in self.__polySeq if ps['auth_chain_id'] == ref_chain_id) - seq_id_mapping = {} - comp_id_mapping = {} + seq_id_mapping, comp_id_mapping = {}, {} for seq_id, comp_id in zip(ps['seq_id'], ps['comp_id']): if seq_id in sa['test_seq_id']: diff --git a/wwpdb/utils/nmr/mr/GromacsPTParserListener.py b/wwpdb/utils/nmr/mr/GromacsPTParserListener.py index 6973f49c6..869db6b0d 100644 --- a/wwpdb/utils/nmr/mr/GromacsPTParserListener.py +++ b/wwpdb/utils/nmr/mr/GromacsPTParserListener.py @@ -220,9 +220,7 @@ def exitGromacs_pt(self, ctx: GromacsPTParser.Gromacs_ptContext): # pylint: dis if terminus[-1]: terminus[-1] = False - seqIdList = [] - compIdList = [] - retrievedAtomNumList = [] + seqIdList, compIdList, retrievedAtomNumList = [], [], [] NON_METAL_ELEMENTS = ('H', 'C', 'N', 'O', 'P', 'S') @@ -297,8 +295,7 @@ def is_metal_elem(prev_atom_name, prev_seq_id, seq_id): self.__polySeqPrmTop.append({'chain_id': chainId, 'seq_id': seqIdList, 'auth_comp_id': compIdList}) - seqIdList = [] - compIdList = [] + seqIdList, compIdList = [], [] chainIndex += 1 chainId = indexToLetter(chainIndex) offset = 1 - _seqId @@ -571,9 +568,7 @@ def is_metal_elem(prev_atom_name, prev_seq_id, seq_id): len_top_na = sum(len(ps_top['seq_id']) for ps_top in self.__polySeqPrmTop if len(ps_top['seq_id']) > 3 and any(compId in ('DA?', 'DT?', 'DG?', 'DC?', 'A?', 'U?', 'G?', 'C?') for compId in ps_top['comp_id'])) if len_cif_na == len_top_na: - chainIdList = [] - seqIdList = [] - authCompIdList = [] + chainIdList, seqIdList, authCompIdList = [], [], [] for ps_top in self.__polySeqPrmTop: len_ps_cif_seq = len(ps_top['seq_id']) if len_ps_cif_seq > 3 and any(compId in ('DA?', 'DT?', 'DG?', 'DC?', 'A?', 'U?', 'G?', 'C?') for compId in ps_top['comp_id']): @@ -761,9 +756,7 @@ def is_metal_elem(prev_atom_name, prev_seq_id, seq_id): "Please verify the two sequences and re-upload the correct file(s) if required.") assi_ref_chain_ids = {} - proc_test_chain_ids = [] - atom_nums = [] - delete_atom_nums = [] + proc_test_chain_ids, atom_nums, delete_atom_nums = [], [], [] def update_atom_num(seq_align, orphan): ref_chain_id = seq_align['ref_chain_id'] @@ -963,8 +956,7 @@ def update_atom_num(seq_align, orphan): if self.__hasNonPolyModel: compIdMapping = {} - mappedSeqVal = [] - mappedAtomNum = [] + mappedSeqVal, mappedAtomNum = [], [] for np in self.__nonPolyModel: authChainId = np['auth_chain_id'] diff --git a/wwpdb/utils/nmr/mr/IsdMRParserListener.py b/wwpdb/utils/nmr/mr/IsdMRParserListener.py index 33e220e7f..53ed3c197 100644 --- a/wwpdb/utils/nmr/mr/IsdMRParserListener.py +++ b/wwpdb/utils/nmr/mr/IsdMRParserListener.py @@ -649,8 +649,7 @@ def exitIsd_mr(self, ctx: IsdMRParser.Isd_mrContext): # pylint: disable=unused- poly_seq_model = next(ps for ps in self.__polySeq if ps['auth_chain_id'] == ref_chain_id) - seq_id_mapping = {} - comp_id_mapping = {} + seq_id_mapping, comp_id_mapping = {}, {} for seq_id, comp_id in zip(ps['seq_id'], ps['comp_id']): if seq_id in sa['test_seq_id']: diff --git a/wwpdb/utils/nmr/mr/ParserListenerUtil.py b/wwpdb/utils/nmr/mr/ParserListenerUtil.py index cd1ff687e..b1610e3bd 100644 --- a/wwpdb/utils/nmr/mr/ParserListenerUtil.py +++ b/wwpdb/utils/nmr/mr/ParserListenerUtil.py @@ -3627,9 +3627,7 @@ def to_np_array(a): if conflict == 0 and unmapped > 0: - nmr_seq_ids = [] - cif_auth_seq_ids = [] - cif_label_seq_ids = [] + nmr_seq_ids, cif_auth_seq_ids, cif_label_seq_ids = [], [], [] for i in range(length): if str(myAlign[i][0]) != '.' and i < len(s1['seq_id']): @@ -3973,11 +3971,7 @@ def to_np_array(a): if len(coord) > 0: nonPoly = [] - compDict = {} - seqDict = {} - insCodeDict = {} - - authChainDict = {} + compDict, seqDict, insCodeDict, authChainDict = {}, {}, {}, {} chainIds = [] for item in coord: @@ -4308,17 +4302,13 @@ def to_np_array(a): if seqKey in labelToAuthSeqForBranched: c['seq_id'], c['alt_seq_id'] = labelToAuthSeqForBranched[seqKey], str(c['seq_id']) - coordAtomSite = {} - labelToAuthSeq = {} + coordAtomSite, labelToAuthSeq = {}, {} # DAOTHER-8817 - chemCompAtom = {} - chemCompBond = {} - chemCompTopo = {} + chemCompAtom, chemCompBond, chemCompTopo = {}, {}, {} # DAOTHER-8828 - authAtomNameToId = {} - authAtomNameToIdExt = {} + authAtomNameToId, authAtomNameToIdExt = {}, {} chainIds = set(c['chain_id'] for c in coord) for chainId in chainIds: @@ -4426,8 +4416,7 @@ def to_np_array(a): resCoordDict = {c['atom_id']: to_np_array(c) for c in cR.getDictListWithFilter('atom_site', dataItems, filterItems)} - chemCompBond[compId] = {} - chemCompTopo[compId] = {} + chemCompBond[compId], chemCompTopo[compId] = {}, {} for proton in atomIds: if proton[0] in protonBeginCode: @@ -4609,11 +4598,8 @@ def to_np_array(a): if authToStarSeq is None or authToEntityType is None or entityAssembly is None or authToStarSeqAnn is None: changed = True - authToStarSeq = {} - authToOrigSeq = {} - authToInsCode = {} - authToEntityType = {} - authToStarSeqAnn = {} + authToStarSeq, authToOrigSeq, authToInsCode, authToEntityType, authToStarSeqAnn =\ + {}, {}, {}, {}, {} entityAssembly = [] entityAssemblyId = 1 @@ -4797,8 +4783,7 @@ def to_np_array(a): mappings = sorted(mappings, key=itemgetter('seq_id')) - authAsymIds = [] - labelAsymIds = [] + authAsymIds, labelAsymIds = [], [] compIds = set() for item in mappings: if item['auth_asym_id'] not in authAsymIds: @@ -4905,8 +4890,7 @@ def to_np_array(a): for labelAsymId in _labelAsymIds: - authAsymIds = [] - labelAsymIds = [] + authAsymIds, labelAsymIds = [], [] compIds = set() for item in mappings: if item['label_asym_id'] != labelAsymId: @@ -5320,7 +5304,7 @@ def to_np_array(a): authToInsCode[seqKey] = item['ins_code'][idx] authToEntityType[seqKey] = entityType - authAsymIds = labelAsymIds = [] + authAsymIds, labelAsymIds = [], [] for _item in nonPoly: if idx < len(item['comp_id']) and item['comp_id'][idx] == compId: if _item['auth_chain_id'] not in authAsymIds: diff --git a/wwpdb/utils/nmr/mr/RosettaMRParserListener.py b/wwpdb/utils/nmr/mr/RosettaMRParserListener.py index 254d4a769..2b23cb9eb 100644 --- a/wwpdb/utils/nmr/mr/RosettaMRParserListener.py +++ b/wwpdb/utils/nmr/mr/RosettaMRParserListener.py @@ -830,8 +830,7 @@ def set_label_seq_scheme(): poly_seq_model = next(ps for ps in self.__polySeq if ps['auth_chain_id'] == ref_chain_id) - seq_id_mapping = {} - comp_id_mapping = {} + seq_id_mapping, comp_id_mapping = {}, {} for seq_id, comp_id in zip(ps['seq_id'], ps['comp_id']): if seq_id in sa['test_seq_id']: diff --git a/wwpdb/utils/nmr/mr/SybylMRParserListener.py b/wwpdb/utils/nmr/mr/SybylMRParserListener.py index 9b4223218..f8f57deb3 100644 --- a/wwpdb/utils/nmr/mr/SybylMRParserListener.py +++ b/wwpdb/utils/nmr/mr/SybylMRParserListener.py @@ -651,8 +651,7 @@ def exitSybyl_mr(self, ctx: SybylMRParser.Sybyl_mrContext): # pylint: disable=u poly_seq_model = next(ps for ps in self.__polySeq if ps['auth_chain_id'] == ref_chain_id) - seq_id_mapping = {} - comp_id_mapping = {} + seq_id_mapping, comp_id_mapping = {}, {} for seq_id, comp_id in zip(ps['seq_id'], ps['comp_id']): if seq_id in sa['test_seq_id']: diff --git a/wwpdb/utils/nmr/rci/RCI.py b/wwpdb/utils/nmr/rci/RCI.py index 117455fe1..e14b4f9d5 100644 --- a/wwpdb/utils/nmr/rci/RCI.py +++ b/wwpdb/utils/nmr/rci/RCI.py @@ -6020,7 +6020,6 @@ def __read_csi_pseudo(self): """ sec_str_list = [] - for l_bmrb_to_aa_entry in self.__bmrb_to_aa_list: if l_bmrb_to_aa_entry[0] in self.__aa_names_full_all_CAP: residue_num = l_bmrb_to_aa_entry[1] @@ -6140,12 +6139,9 @@ def __gap_fill2(self, L_list, l_atom): if L_residue_number_found == 0 and self.__real_BMRB_first_res <= L_residue_number <= self.__real_BMRB_last_res\ and L_residue_number not in self.__excluded_residues: - positive_found = 0 - negative_found = 0 - pos_neg_list_true = [] - pos_neg_list_abs = [] - pos_neg_list_true_ave = None - pos_neg_list_abs_ave = None + positive_found = negative_found = 0 + pos_neg_list_true, pos_neg_list_abs = [], [] + pos_neg_list_true_ave = pos_neg_list_abs_ave = None for i in range(1, self.gap_limit + 1): if L_residue_number_found == 0: if positive_found != 1: @@ -6233,13 +6229,11 @@ def __smoothing(self, L_smooth, L_list, l_atom_type): #################################################### Real_first_residue = L_list[0][0] Real_last_residue = L_list[-1][0] - L_chem_shift_diff_list = [] - L_chem_shift_diff_abs_list = [] + L_chem_shift_diff_list, L_chem_shift_diff_abs_list = [], [] Old_first_residue = Real_first_residue negative_switch = 0 for L_number in range(0, (smooth_factor - N_terminus_smooth_factor)): - L_chem_shift_diff_list = [] - L_chem_shift_diff_abs_list = [] + L_chem_shift_diff_list, L_chem_shift_diff_abs_list = [], [] L_residue_number = L_list[L_number][0] L_residue_name = L_list[L_number][1] L_bmrb_shift = L_list[L_number][2] @@ -6289,10 +6283,9 @@ def __smoothing(self, L_smooth, L_list, l_atom_type): plus_done = 1 else: minus_done = 1 - N_chem_shift_diff_mean = None + N_chem_shift_diff_mean = N_chem_shift_diff_abs_mean = None if len(L_chem_shift_diff_list) > 0: N_chem_shift_diff_mean = lmean(L_chem_shift_diff_list) - N_chem_shift_diff_abs_mean = None if len(L_chem_shift_diff_abs_list) > 0: N_chem_shift_diff_abs_mean = lmean(L_chem_shift_diff_abs_list) N_chem_shift_diff_len = len(L_chem_shift_diff_list) @@ -6307,17 +6300,11 @@ def __smoothing(self, L_smooth, L_list, l_atom_type): done = 0 while not done: if L_end <= last_residue - offset: # For Ubiquitin - L_smooth_list = [] - missing_chemshift = [] - bigger_missing = 0 - smaller_missing = 0 - new_end = 0 - new_start = 0 - - L_residue_number = None - L_residue_name = None - L_bmrb_shift = None - L_simpred_shift = None + L_smooth_list, missing_chemshift = [], [] + bigger_missing = smaller_missing = 0 + new_end = new_start = 0 + + L_residue_number = L_residue_name = L_bmrb_shift = L_simpred_shift = None for L_number in residue_number_list[L_start:L_end]: found_flag = 0 @@ -6327,12 +6314,10 @@ def __smoothing(self, L_smooth, L_list, l_atom_type): found_flag = 1 if found_flag == 0: missing_chemshift.append(L_number) - more_smaller = 0 - more_bigger = 0 + more_smaller = more_bigger = 0 if len(L_smooth_list) == smooth_factor and smooth_factor != 0: - L_chem_shift_diff_tmp_list = [] - L_chem_shift_diff_abs_tmp_list = [] + L_chem_shift_diff_tmp_list, L_chem_shift_diff_abs_tmp_list = [], [] L_residue_number = L_smooth_list[central_residue - 1][0] L_residue_name = L_smooth_list[central_residue - 1][1] L_bmrb_shift = L_smooth_list[central_residue - 1][2] @@ -6351,8 +6336,7 @@ def __smoothing(self, L_smooth, L_list, l_atom_type): chem_shift_diff_mean, chem_shift_diff_abs_mean, l_atom_type, chem_shift_len, smooth_factor]) elif len(L_smooth_list) < smooth_factor: - L_chem_shift_diff_tmp_list = [] - L_chem_shift_diff_abs_tmp_list = [] + L_chem_shift_diff_tmp_list, L_chem_shift_diff_abs_tmp_list = [], [] L_residue_number = residue_number_list[L_start:L_end][central_residue - 1] for L_item in L_list: if L_residue_number == L_item[0]: @@ -6367,8 +6351,7 @@ def __smoothing(self, L_smooth, L_list, l_atom_type): elif miss_number == L_residue_number: bigger_missing += 1 if bigger_missing > 0: - bigger_counter = 0 - bigger_flag = 0 + bigger_counter = bigger_flag = 0 new_end = residue_number_list[L_end - 1] while not bigger_flag: new_end += 1 @@ -6387,8 +6370,7 @@ def __smoothing(self, L_smooth, L_list, l_atom_type): more_smaller = bigger_missing - bigger_counter bigger_flag = 1 if smaller_missing > 0: - smaller_counter = 0 - smaller_flag = 0 + smaller_counter = smaller_flag = 0 new_start = residue_number_list[L_start] while not smaller_flag: new_start -= 1 @@ -6407,8 +6389,7 @@ def __smoothing(self, L_smooth, L_list, l_atom_type): smaller_flag = 1 if more_bigger > 0: - more_bigger_counter = 0 - more_bigger_flag = 0 + more_bigger_counter = more_bigger_flag = 0 new_end = residue_number_list[L_end - 1] while not more_bigger_flag: new_end += 1 @@ -6423,8 +6404,7 @@ def __smoothing(self, L_smooth, L_list, l_atom_type): more_bigger_flag = 1 if more_smaller > 0: - more_smaller_counter = 0 - more_smaller_flag = 0 + more_smaller_counter = more_smaller_flag = 0 new_start = residue_number_list[L_start] while not more_smaller_flag: new_start -= 1 @@ -6444,10 +6424,9 @@ def __smoothing(self, L_smooth, L_list, l_atom_type): L_chem_shift_diff_abs = entry[5] L_chem_shift_diff_tmp_list.append(L_chem_shift_diff) L_chem_shift_diff_abs_tmp_list.append(L_chem_shift_diff_abs) - chem_shift_diff_mean = None + chem_shift_diff_mean = chem_shift_diff_abs_mean = None if len(L_chem_shift_diff_tmp_list) > 0: chem_shift_diff_mean = lmean(L_chem_shift_diff_tmp_list) - chem_shift_diff_abs_mean = None if len(L_chem_shift_diff_abs_tmp_list) > 0: chem_shift_diff_abs_mean = lmean(L_chem_shift_diff_abs_tmp_list) chem_shift_diff_len = len(L_chem_shift_diff_tmp_list) @@ -6459,8 +6438,7 @@ def __smoothing(self, L_smooth, L_list, l_atom_type): chem_shift_diff_mean, chem_shift_diff_abs_mean, l_atom_type, chem_shift_diff_len, smooth_factor]) else: - L_chem_shift_diff_tmp_list = [] - L_chem_shift_diff_abs_tmp_list = [] + L_chem_shift_diff_tmp_list, L_chem_shift_diff_abs_tmp_list = [], [] L_residue_number = residue_number_list[L_start:L_end][central_residue - 1] for L_item in L_list: if L_residue_number == L_item[0]: @@ -6472,10 +6450,9 @@ def __smoothing(self, L_smooth, L_list, l_atom_type): L_chem_shift_diff_abs = entry[5] L_chem_shift_diff_tmp_list.append(L_chem_shift_diff) L_chem_shift_diff_abs_tmp_list.append(L_chem_shift_diff_abs) - chem_shift_diff_mean = None + chem_shift_diff_mean = chem_shift_diff_abs_mean = None if len(L_chem_shift_diff_tmp_list) > 0: chem_shift_diff_mean = lmean(L_chem_shift_diff_tmp_list) - chem_shift_diff_abs_mean = None if len(L_chem_shift_diff_abs_tmp_list) > 0: chem_shift_diff_abs_mean = lmean(L_chem_shift_diff_abs_tmp_list) chem_shift_diff_len = len(L_chem_shift_diff_tmp_list) @@ -6496,10 +6473,8 @@ def __smoothing(self, L_smooth, L_list, l_atom_type): Real_first_residue = L_list[0][0] Real_last_residue = L_list[1][0] Old_first_residue = Real_first_residue - negative_switch = 0 for L_number in range(1, (smooth_factor - N_terminus_smooth_factor + 1)): - L_chem_shift_diff_list = [] - L_chem_shift_diff_abs_list = [] + L_chem_shift_diff_list, L_chem_shift_diff_abs_list = [], [] L_residue_number = L_list[-L_number][0] L_residue_name = L_list[-L_number][1] @@ -6550,10 +6525,9 @@ def __smoothing(self, L_smooth, L_list, l_atom_type): plus_done = 1 else: minus_done = 1 - N_chem_shift_diff_mean = None + N_chem_shift_diff_mean = N_chem_shift_diff_abs_mean = None if len(L_chem_shift_diff_list) > 0: N_chem_shift_diff_mean = lmean(L_chem_shift_diff_list) - N_chem_shift_diff_abs_mean = None if len(L_chem_shift_diff_abs_list) > 0: N_chem_shift_diff_abs_mean = lmean(L_chem_shift_diff_abs_list) N_chem_shift_diff_len = len(L_chem_shift_diff_list) @@ -6568,9 +6542,7 @@ def __grid_search(self, l_all_atoms_smooth, smooth_type, lCOp_list, lCAp_list, l """ Function to do a grid search """ - list_of_files = [] - - CA_CB_CO_HA_all_residues_abs_corr = [] + list_of_files, CA_CB_CO_HA_all_residues_abs_corr = [], [] if self.grid_search_flag == 1: lCOp_list = lCAp_list = lCBp_list = lHAp_list = lHp_list = lNp_list = self.gridsearch_list @@ -6610,8 +6582,7 @@ def __grid_search(self, l_all_atoms_smooth, smooth_type, lCOp_list, lCAp_list, l for coefHpos in lHp_list: for coefHneg in [1]: # pylint: disable=unused-variable - CA_CB_CO_HA_all_residues_abs = [] - list_of_coefficients = [] + CA_CB_CO_HA_all_residues_abs, list_of_coefficients = [], [] if self.CAp_exclude != 1: list_of_coefficients.append(coefCApos) @@ -6880,11 +6851,9 @@ def __grid_search(self, l_all_atoms_smooth, smooth_type, lCOp_list, lCAp_list, l atoms_abs.append(atomabs) elif self.function_flag == 8: - valueabs_list = [] - valueabs_origin = None - valueabs = None + valueabs_list, coef_list = [], [] + valueabs_origin = valueabs = None coef_trigger = f"{CA_found}{CB_found}{CO_found}{NH_found}{N_found}{HA_found}" - coef_list = [] for item in residue_data_abs: resid_name_abs = item[1] valueabs_origin = item[2] @@ -7032,9 +7001,8 @@ def __end_effect(self, l_list): """ Function1 to correct sigma for end effects. """ - result_list = [] + result_list, l_N_end_list, l_C_end_list = [], [], [] l_N_switch = l_C_switch = 0 - l_N_end_list = l_C_end_list = [] l_N_mean = l_C_mean = 9999 for l_item in l_list: l_res_num, l_sigma = l_item[0], l_item[2] @@ -7085,10 +7053,8 @@ def __end_effect2(self, l_list): """ Function2 to correct sigma for end effects. """ - result_list = [] + result_list, l_N_end_list, l_C_end_list = [], [], [] l_N_switch = l_C_switch = 0 - l_N_end_list = [] - l_C_end_list = [] l_N_mean = l_C_mean = 9999 for l_item in l_list: l_res_num, l_sigma = l_item[0], l_item[2] @@ -7139,10 +7105,8 @@ def __end_effect3(self, l_list): """ Function3 to correct sigma for end effects. """ - result_list = [] + result_list, l_N_end_list, l_C_end_list = [], [], [] # l_N_switch = l_C_switch = 0 - l_N_end_list = [] - l_C_end_list = [] l_N_max_place = l_C_max_place = 0 l_N_max = l_C_max = None for l_item in l_list: @@ -7210,11 +7174,8 @@ def __end_effect4(self, l_list): """ Function4 to correct sigma for end effects. """ - result_list = [] - l_N_end_list = [] - l_C_end_list = [] - l_N_max = None - l_C_max = None + result_list, l_N_end_list, l_C_end_list = [], [], [] + l_N_max = l_C_max = None # l_N_min = None for l_item in l_list: l_res_num, l_sigma = l_item[0], l_item[2] @@ -7265,9 +7226,7 @@ def __end_effect5(self, l_list): """ Function5 to correct sigma for end effects. """ - result_list = [] - l_N_end_list = [] - l_C_end_list = [] + result_list, l_N_end_list, l_C_end_list = [], [], [] l_N_max = l_C_max = None for l_item in l_list: l_res_num, l_sigma = l_item[0], l_item[2] @@ -7315,9 +7274,7 @@ def __final_smoothing(self, L_smooth, L_list): """ Smoothing function for final result. """ # Building residue number list - first_residue = 0 - last_residue = 0 - first_residue_flag = 0 + first_residue = last_residue = first_residue_flag = 0 smooth_factor = L_smooth central_residue = (smooth_factor // 2) + 1 N_terminus_smooth_factor = central_residue @@ -7356,8 +7313,7 @@ def __final_smoothing(self, L_smooth, L_list): Real_last_residue = L_list[-1][0] Old_first_residue = Real_first_residue negative_switch = 0 - L_abs_or_true = None - L_first_smooth = None + L_abs_or_true = L_first_smooth = None for L_number in range(0, (smooth_factor - N_terminus_smooth_factor)): L_chem_shift_diff_abs_list = [] L_residue_number = L_list[L_number][0] @@ -7422,14 +7378,10 @@ def __final_smoothing(self, L_smooth, L_list): chem_shift_diff_abs_mean = None if L_end <= (last_residue - offset): # For Ubiquitin - L_smooth_list = [] - missing_chemshift = [] - bigger_missing = 0 - smaller_missing = 0 - new_end = 0 - new_start = 0 - L_residue_number = None - L_residue_name = None + L_smooth_list, missing_chemshift = [], [] + bigger_missing = smaller_missing = 0 + new_end = new_start = 0 + L_residue_number = L_residue_name = None # chem_shift_diff_mean = None chem_shift_diff_abs_mean = None for L_number in residue_number_list[L_start:L_end]: @@ -7440,8 +7392,7 @@ def __final_smoothing(self, L_smooth, L_list): found_flag = 1 if found_flag == 0: missing_chemshift.append(L_number) - more_smaller = 0 - more_bigger = 0 + more_smaller = more_bigger = 0 if len(L_smooth_list) == smooth_factor: @@ -7485,8 +7436,7 @@ def __final_smoothing(self, L_smooth, L_list): elif miss_number == L_residue_number: bigger_missing += 1 if bigger_missing > 0: - bigger_counter = 0 - bigger_flag = 0 + bigger_counter = bigger_flag = 0 new_end = residue_number_list[L_end - 1] while not bigger_flag: new_end += 1 @@ -7507,8 +7457,7 @@ def __final_smoothing(self, L_smooth, L_list): bigger_flag = 1 if smaller_missing > 0: - smaller_counter = 0 - smaller_flag = 0 + smaller_counter = smaller_flag = 0 new_start = residue_number_list[L_start] while not smaller_flag: new_start -= 1 @@ -7528,8 +7477,7 @@ def __final_smoothing(self, L_smooth, L_list): smaller_flag = 1 if more_bigger > 0: - more_bigger_counter = 0 - more_bigger_flag = 0 + more_bigger_counter = more_bigger_flag = 0 new_end = residue_number_list[L_end] while not more_bigger_flag: new_end += 1 @@ -7544,8 +7492,7 @@ def __final_smoothing(self, L_smooth, L_list): more_bigger_flag = 1 if more_bigger > 0: - more_bigger_counter = 0 - more_bigger_flag = 0 + more_bigger_counter = more_bigger_flag = 0 new_end = residue_number_list[L_end] while not more_bigger_flag: new_end += 1 @@ -7560,8 +7507,7 @@ def __final_smoothing(self, L_smooth, L_list): more_bigger_flag = 1 if more_smaller > 0: - more_smaller_counter = 0 - more_smaller_flag = 0 + more_smaller_counter = more_smaller_flag = 0 new_start = residue_number_list[L_start] while not more_smaller_flag: new_start -= 1 @@ -7619,7 +7565,6 @@ def __final_smoothing(self, L_smooth, L_list): Real_first_residue = L_list[0][0] Real_last_residue = L_list[1][0] Old_first_residue = Real_first_residue - negative_switch = 0 for L_number in range(1, (smooth_factor - N_terminus_smooth_factor + 1)): L_chem_shift_diff_abs_list = [] L_residue_number = L_list[-L_number][0] @@ -7725,10 +7670,8 @@ def __rci_only(self, m_list_of_files, m_md_result, m_best_ten_coef_corr_true, l_ m_atoms_real = m_data_type = m_smooth_type = None for filename in m_list_of_files: - correlation_true_MD = [] - correlation_true_Dynamr = [] - md_data = [] - dynamr_data = [] + correlation_true_MD, correlation_true_Dynamr = [], [] + md_data, dynamr_data = [], [] for entry in m_md_result: residue_number = entry[0] residue_name = entry[1] @@ -7746,9 +7689,7 @@ def __rci_only(self, m_list_of_files, m_md_result, m_best_ten_coef_corr_true, l_ md_data.append([residue_number, residue_name, MD_value]) dynamr_data.append([residue_number, residue_name, dynamr_value]) - dynamr_to_md_ratio = 0 - entry_found_true_corr = 0 - counter = 0 + dynamr_to_md_ratio = entry_found_true_corr = counter = 0 corel_coef = l_Pearson_coeff = l_Spearman_coeff = 0 if len(correlation_true_Dynamr) > 0 and len(correlation_true_MD) > 0: compare_list_corr_true = [abs(corel_coef), filename, "correlation", corel_coef, l_coeff_list, md_data, dynamr_data, dynamr_to_md_ratio] @@ -7804,71 +7745,68 @@ def calculate(self, bmrb_to_aa_list, assignment, B_Cys, noshift_res): # pylint: res_i_minus_2 = number - 2 res_i_plus_2 = number + 2 - res_i_found = 0 - res_i_minus_1_found = 0 - res_i_plus_1_found = 0 + res_i_found = res_i_minus_1_found = res_i_plus_1_found = 0 - res_i_found = 0 # res_i_minus_2_found = 0 # res_i_plus_2_found = 0 - dyna_simp_res_num_i = None - dyna_simp_res_name_i = None - dyna_simp_res_num_i_minus_1 = None - dyna_simp_res_name_i_minus_1 = None - dyna_simp_res_num_i_plus_1 = None - dyna_simp_res_name_i_plus_1 = None - dyna_simp_res_num_i_minus_2 = None - dyna_simp_res_name_i_minus_2 = None - dyna_simp_res_num_i_plus_2 = None - dyna_simp_res_name_i_plus_2 = None - - res_num_i_sec_str_found = 0 - res_num_i_minus_1_sec_str_found = 0 - res_num_i_plus_1_sec_str_found = 0 - res_num_i_minus_2_sec_str_found = 0 - res_num_i_plus_2_sec_str_found = 0 - - preceed_res_cor_N = None - preceed_res_cor_CO = None - preceed_res_cor_CA = None - preceed_res_cor_CB = None - preceed_res_cor_NH = None - preceed_res_cor_HA = None - - preceed_preceed_res_cor_N = None - preceed_preceed_res_cor_CO = None - preceed_preceed_res_cor_CA = None - preceed_preceed_res_cor_CB = None - preceed_preceed_res_cor_NH = None - preceed_preceed_res_cor_HA = None - - next_res_cor_N = None - next_res_cor_CO = None - next_res_cor_CA = None - next_res_cor_CB = None - next_res_cor_NH = None - next_res_cor_HA = None - - next_next_res_cor_N = None - next_next_res_cor_CO = None - next_next_res_cor_CA = None - next_next_res_cor_CB = None - next_next_res_cor_NH = None - next_next_res_cor_HA = None - - final_N = None - final_CO = None - final_CA = None - final_CB = None - final_NH = None - final_HA = None - - res_i_csi_sec_str = "C" - res_i_minus_1_csi_sec_str = "C" - res_i_plus_1_csi_sec_str = "C" - res_i_minus_2_csi_sec_str = "C" - res_i_plus_2_csi_sec_str = "C" + dyna_simp_res_num_i =\ + dyna_simp_res_name_i =\ + dyna_simp_res_num_i_minus_1 =\ + dyna_simp_res_name_i_minus_1 =\ + dyna_simp_res_num_i_plus_1 =\ + dyna_simp_res_name_i_plus_1 =\ + dyna_simp_res_num_i_minus_2 =\ + dyna_simp_res_name_i_minus_2 =\ + dyna_simp_res_num_i_plus_2 =\ + dyna_simp_res_name_i_plus_2 = None + + res_num_i_sec_str_found =\ + res_num_i_minus_1_sec_str_found =\ + res_num_i_plus_1_sec_str_found =\ + res_num_i_minus_2_sec_str_found =\ + res_num_i_plus_2_sec_str_found = 0 + + preceed_res_cor_N =\ + preceed_res_cor_CO =\ + preceed_res_cor_CA =\ + preceed_res_cor_CB =\ + preceed_res_cor_NH =\ + preceed_res_cor_HA = None + + preceed_preceed_res_cor_N =\ + preceed_preceed_res_cor_CO =\ + preceed_preceed_res_cor_CA =\ + preceed_preceed_res_cor_CB =\ + preceed_preceed_res_cor_NH =\ + preceed_preceed_res_cor_HA = None + + next_res_cor_N =\ + next_res_cor_CO =\ + next_res_cor_CA =\ + next_res_cor_CB =\ + next_res_cor_NH =\ + next_res_cor_HA = None + + next_next_res_cor_N =\ + next_next_res_cor_CO =\ + next_next_res_cor_CA =\ + next_next_res_cor_CB =\ + next_next_res_cor_NH =\ + next_next_res_cor_HA = None + + final_N =\ + final_CO =\ + final_CA =\ + final_CB =\ + final_NH =\ + final_HA = None + + res_i_csi_sec_str =\ + res_i_minus_1_csi_sec_str =\ + res_i_plus_1_csi_sec_str =\ + res_i_minus_2_csi_sec_str =\ + res_i_plus_2_csi_sec_str = "C" for bmrb_to_aa_entry in self.__bmrb_to_aa_list: dyna_simp_res_num = bmrb_to_aa_entry[1] @@ -8244,8 +8182,7 @@ def calculate(self, bmrb_to_aa_list, assignment, B_Cys, noshift_res): # pylint: self.__real_BMRB_last_res = 0 for atom_type in self.__atom_list: - no_smooth_list = [] - no_smooth_list2 = [] + no_smooth_list, no_smooth_list2 = [], [] for v in assignment: residue_name_init, residue_number, bmrb_atom_name, bmrb_shift = (v[0], v[1], v[2], v[4])