Skip to content

Commit

Permalink
DAOTHER-8905: Atom nomenclature mismatch in spectral peak list should…
Browse files Browse the repository at this point in the history
… be allowed
  • Loading branch information
yokochi47 committed Jan 20, 2025
1 parent 7b70c19 commit a4cbccb
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 147 deletions.
61 changes: 21 additions & 40 deletions wwpdb/utils/nmr/CifToNmrStar.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def get_first_sf_tag(sf: pynmrstar.Saveframe, tag: str, default: str = '') -> An


def set_sf_tag(sf: pynmrstar.Saveframe, tag: str, value: Any):
""" Set saveframe tag.
""" Set saveframe tag with a given value.
"""

tagNames = [t[0] for t in sf.tags]
Expand All @@ -130,6 +130,23 @@ def set_sf_tag(sf: pynmrstar.Saveframe, tag: str, value: Any):
sf.tags[tagNames.index(tag)][1] = value


def set_lp_tag(lp: pynmrstar.Loop, tag: str, value: Any):
""" Set loop tag with a given value.
"""

if tag not in lp.tags:
lp.add_tag(tag)

for row in lp:
row.append(value)

else:
col = lp.tags.index(tag)

for row in lp:
row[col] = value


def retrieve_symbolic_labels(strData: pynmrstar.Entry):
""" Retrieve symbolic label representations that serve as saveframe pointers in NMR-STAR.
"""
Expand Down Expand Up @@ -665,19 +682,7 @@ def set_entry_id(self, strData: Union[pynmrstar.Entry, pynmrstar.Saveframe, pynm
pass

if not filled:
if 'Entry_ID' not in lp.tags:
entry_id_tag = lp.category + '.Entry_ID'

lp.add_tag(entry_id_tag)

for row in lp:
row.append(entryId)

else:
col = lp.tags.index('Entry_ID')

for row in lp:
row[col] = entryId
set_lp_tag(lp, 'Entry_ID', entryId)

modified = True

Expand Down Expand Up @@ -725,19 +730,7 @@ def set_entry_id(self, strData: Union[pynmrstar.Entry, pynmrstar.Saveframe, pynm
pass

if not filled:
if 'Entry_ID' not in lp.tags:
entry_id_tag = lp.category + '.Entry_ID'

lp.add_tag(entry_id_tag)

for row in lp:
row.append(entryId)

else:
col = lp.tags.index('Entry_ID')

for row in lp:
row[col] = entryId
set_lp_tag(lp, 'Entry_ID', entryId)

modified = True

Expand All @@ -759,19 +752,7 @@ def set_entry_id(self, strData: Union[pynmrstar.Entry, pynmrstar.Saveframe, pynm
pass

if not filled:
if 'Entry_ID' not in lp.tags:
entry_id_tag = lp.category + '.Entry_ID'

lp.add_tag(entry_id_tag)

for row in lp:
row.append(entryId)

else:
col = lp.tags.index('Entry_ID')

for row in lp:
row[col] = entryId
set_lp_tag(lp, 'Entry_ID', entryId)

modified = True

Expand Down
Loading

0 comments on commit a4cbccb

Please sign in to comment.