Package MolKit :: Module pdbWriter :: Class PdbWriter
[hide private]
[frames] | no frames]

Class PdbWriter

source code

moleculeWriter.MoleculeWriter --+
                                |
                               PdbWriter
Known Subclasses:
PdbqWriter

Class to write data records from a molecule tree to a pdb file. Has methods for the user to add own records and to write the record.

Instance Methods [hide private]
  __init__(self)
Constructor: userRecords contains input from user to be written to file.
  write(self, filename, nodes, sort=False, sortFunc=None, records=['ATOM','CONECT'], bondOrigin=('File',), ssOrigin='File')
required argument: filename -- path to the new file, a .pdb extension will be added when missing.
  write_atom(self, f, atm)
Takes a file object and an Atom instance.
  formatName(self, at)
  addRecord(self, key, record=[])
Allows user to enter own record for the record type given by key.
  defineHYDBNDRecords(self, atoms)
  defineHELIXRecords(self, helix)
Takes a list of Helix objects and define the corresponding HELIX records
  defineSHEETRecords(self, sheet)
Takes a set of Strand objects and define the SHEET records
  defineTURNRecords(self, turn)
Takes a set of Turn objects and define the TURN records
  defineATOM_HETATMRecord(self, atm)
Define the ATOM or HETATM rec for the given atm
  defineTERRecord(self, atom)
TER record to the file.
  defineSecondaryStructureSection(self, mol, origin='')
The Secondary structure section contains the following records: HELIX, SHEET, TURN Information will taken from either the file or the data structure required argument: origin can either be '', File or Stride
  defineCoordsSection(self, nodes, sort=False, sortFunc=None, atmRec=True, hetRec=True)
The coordinate section should contain the following records: MODEL, ATOM, SIGATM, ANISOU, SIGUIJ, TER, HETATM, ENDMDL Here we only save the current conformation and only the ATOM, TER, and HETATM records.
  defineConnectSection(self, atms, bondOrigin=('File',))
The Connectivity section contains the following records: CONECT bondOrigin -- either a string 'all' or a tuple of string describing the origin of the bonds: 'File' : CONECT records of the originating file describing the molecule 'BuiltByDistance': Bonds created by distance.

Method Details [hide private]

__init__(self)
(Constructor)

source code 
Constructor: userRecords contains input from user to be written to file. missingRecords contains types of mandatory records that are missing from userReconds and PdbParser records

write(self, filename, nodes, sort=False, sortFunc=None, records=['ATOM','CONECT'], bondOrigin=('File',), ssOrigin='File')

source code 

required argument:
filename  -- path to the new file, a .pdb extension will be added
             when missing.
nodes     -- TreeNode, TreeNodeSet instance to save as PDB

optional arguments:
sort  -- (False) Boolean flag to specify whether or not to sort the
         given nodes
sortFunc  -- (None) sort function that will be used to sort the nodes
             when specified.This function has to return (-1, 0 or 1).
records -- list of PDB record to write out
bondOrigin -- (('File', )) This will be used if the CONECT records are
              written out. Can be any combination of 'File',
              'BuiltByDistance' and 'UserDefined'.
ssOrigin -- 'File' This will be used if the TURN, HELIX and SHEET
             records are written. Can be either from the originating
             PDB file or from the data structure.

write_atom(self, f, atm)

source code 
Takes a file object and an Atom instance. Writes the atom record to the given file.

formatName(self, at)

source code 
None

addRecord(self, key, record=[])

source code 
Allows user to enter own record for the record type given by key. record should be a list of tuples with a tuple for each line in the record for that type. The method checks that the user's record fits the PDB format, else there is an assertion error. If if a type is entered but no record, when write() is called, it writes the record given by the molecule's parser records.

defineHYDBNDRecords(self, atoms)

source code 
None

defineHELIXRecords(self, helix)

source code 
Takes a list of Helix objects and define the corresponding HELIX records

defineSHEETRecords(self, sheet)

source code 
Takes a set of Strand objects and define the SHEET records

defineTURNRecords(self, turn)

source code 
Takes a set of Turn objects and define the TURN records

defineATOM_HETATMRecord(self, atm)

source code 
Define the ATOM or HETATM rec for the given atm

defineTERRecord(self, atom)

source code 
TER record to the file.

defineSecondaryStructureSection(self, mol, origin='')

source code 
The Secondary structure section contains the following records: HELIX, SHEET, TURN Information will taken from either the file or the data structure required argument: origin can either be '', File or Stride

defineCoordsSection(self, nodes, sort=False, sortFunc=None, atmRec=True, hetRec=True)

source code 
The coordinate section should contain the following records: MODEL, ATOM, SIGATM, ANISOU, SIGUIJ, TER, HETATM, ENDMDL Here we only save the current conformation and only the ATOM, TER, and HETATM records.

defineConnectSection(self, atms, bondOrigin=('File',))

source code 

The Connectivity section contains the following records:
CONECT
bondOrigin -- either a string 'all' or a tuple of string describing the
              origin of the bonds:
              'File' : CONECT records of the originating file describing the molecule
              'BuiltByDistance': Bonds created by distance.
              'UserDefined' : Bonds added by the user.