# Bio.NMR.xpktools module

Tools to manipulate data from nmrview .xpk peaklist files.

class Bio.NMR.xpktools.XpkEntry(entry, headline)

  Bases: `object`

  Provide dictionary access to single entry from nmrview .xpk file.

  This class is suited for handling single lines of non-header data from an nmrview .xpk file. This class provides methods for extracting data by the field name which is listed in the last line of the peaklist header.

  Parameters:
    xpkentry str

      The line from an nmrview .xpk file.

    xpkheadline str

      The line from the header file that gives the names of the entries. This is typically the sixth line of the header, 1-origin.

  Attributes:
    fields dict

      Dictionary of fields where key is in header line, value is an entry. Variables are accessed by either their name in the header line as in self.field[“H1.P”] will return the H1.P entry for example. self.field[“entrynum”] returns the line number (1st field of line)

  __init__(entry, headline)

    Initialize the class.

  __firstlineno__ = 10
  __static_attributes__ = ('fields',)

class Bio.NMR.xpktools.Peaklist(infn)

  Bases: `object`

  Provide access to header lines and data from a nmrview xpk file.

  Header file lines and file data are available as attributes.

  Parameters:
    infn str

      The input nmrview filename.

  Attributes:
    firstline str

      The first line in the header.

    axislabels str

      The axis labels.

    dataset str

      The label of the dataset.

    sw str

      The sw coordinates.

    sf str

      The sf coordinates.

    datalabels str

      The labels of the entries.

    data list

      File data after header lines.

  Examples

      >>> from Bio.NMR.xpktools import Peaklist
      >>> peaklist = Peaklist('../Doc/examples/nmr/noed.xpk')
      >>> peaklist.firstline
      'label dataset sw sf '
      >>> peaklist.dataset
      'test.nv'
      >>> peaklist.sf
      '{599.8230 } { 60.7860 } { 60.7860 }'
      >>> peaklist.datalabels
      ' H1.L  H1.P  H1.W  H1.B  H1.E  H1.J  15N2.L  15N2.P  15N2.W  15N2.B  15N2.E  15N2.J  N15.L  N15.P  N15.W  N15.B  N15.E  N15.J  vol  int  stat '

  __init__(infn)

    Initialize the class.

  residue_dict(index)

    Return a dict of lines in ‘data’ indexed by residue number or a nucleus.

    The nucleus should be given as the input argument in the same form as it appears in the xpk label line (H1, 15N for example)

    Parameters:
      index str

        The nucleus to index data by.

    Returns:
      resdict dict

        Mappings of index nucleus to data line.

    Examples

        >>> from Bio.NMR.xpktools import Peaklist
        >>> peaklist = Peaklist('../Doc/examples/nmr/noed.xpk')
        >>> residue_d = peaklist.residue_dict('H1')
        >>> sorted(residue_d.keys())
        ['10', '3', '4', '5', '6', '7', '8', '9', 'maxres', 'minres']
        >>> residue_d['10']
        ['8  10.hn   7.663   0.021   0.010   ++   0.000   10.n   118.341   0.324   0.010   +E   0.000   10.n   118.476   0.324   0.010   +E   0.000  0.49840 0.49840 0']

  write_header(outfn)

    Write header lines from input file to handle `outfn`.

  __firstlineno__ = 51
  __static_attributes__ = ('axislabels', 'data', 'datalabels', 'dataset', 'dict', 'firstline', 'sf', 'sw')

Bio.NMR.xpktools.replace_entry(line, fieldn, newentry)

  Replace an entry in a string by the field number.

  No padding is implemented currently. Spacing will change if the original field entry and the new field entry are of different lengths.

Bio.NMR.xpktools.data_table(fn_list, datalabel, keyatom)

  Generate a data table from a list of input xpk files.

  Parameters:
    fn_list list

      List of .xpk file names.

    datalabel str

      The data element reported.

    keyatom str

      The name of the nucleus used as an index for the data table.

  Returns:
    outlist list

      List of table rows indexed by `keyatom`.

Biopython v: 1.85

Versions
  Previous
  Latest
  Develop

Biopython Project
  Homepage
  On GitHub