You are here: Home V2 Software Software More ... Python Macro Scripts Renumber chain sequence

Renumber chain sequence

Renumber the seqCodes in a chain optionally allowing 0 to be skipped — Python Source, 835 bytes

File contents

from ccpnmr.analysis.core.DataAnalysisBasic import calcT2List

def renumberChainSeqCodes(argServer):
  chain = argServer.getChain()
  if not chain: # None avail or aborted
    msg = 'Stopping: Script cancelled or no chain available.'

  firstSeqCode = argServer.askInteger('Enter starting seqCode:', 1)
  if firstSeqCode is None:
    msg = 'Stopping: Script cancelled.'
    argServer.showWarning(msg )
  if firstSeqCode < 0 and firstSeqCode+len(chain.residues) >= 0:
    skipZeroSeqCode = argServer.askYesNo('Do you want to skip 0 in numbering?')
    skipZeroSeqCode = False # arbitrary
  from ccp.util.Molecule import renumberChainSeqCodes as renumber

  renumber(chain, firstSeqCode, skipZeroSeqCode)

  argServer.showInfo('Chain renumbered successfully')