Skip to content

Commit

Permalink
(1) Preserve _Atom_chem_shift.Original_PDB_atom_name values for atom …
Browse files Browse the repository at this point in the history
…name mapping history, (2) Code refactoring
  • Loading branch information
yokochi47 committed Nov 26, 2024
1 parent 46f1381 commit 67c930d
Show file tree
Hide file tree
Showing 21 changed files with 606 additions and 1,122 deletions.
93 changes: 30 additions & 63 deletions wwpdb/utils/nmr/AlignUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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']:
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -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():

Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:

Expand Down Expand Up @@ -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:

Expand Down
4 changes: 0 additions & 4 deletions wwpdb/utils/nmr/BMRBChemShiftStat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down
Loading

0 comments on commit 67c930d

Please sign in to comment.