API Docs for: 0.0.4
Show:

molfile Class

Defined in: lib\parser.js:13
Module: molfile

Parser for MDL/Symyx CTfile formats

Usage: var molfile = require('molfile');

var parsed = molfile.parseMol(string);

Methods

getVersion

() String

Defined in lib\parser.js:26

Return parser version string.

Returns:

String:

parser version

parseAtomLine

(
  • line
)
Object

Defined in lib\parser.js:82

Parses an atom line. Return value is an object:

 {
    'x': 0.0,
    'y': 0.0,
    'z': 0.0,
    'elname': 'Hf'
    'massDiff': 0,
    'chargeCode': 0,
    'valenceCode': 0,
  }

Note that massDiff, chargeCode and valenceCode should be ignored if there are isotope, charge, or radical entries in the property table which follows the atom and bond tables.

It is easier to read the isotope, charge, and radical information from the properties than to interpret the codes.

Mass difference is an integral difference from the periodic table mass, and is in the range -3..4

Charge code should be interpreted as follows:

Code Meaning
0 no charge (0)
1 +3
2 +2
3 +1
4 doublet (radical)
5 -1
6 -2
7 -3

Valence code should be interpreted as follows:

Code Meaning
0 default valence
1-14 valence = code
15 valence = 0

Parameters:

  • line String

    the line to parse

Returns:

Object:

data from the line

parseBondLine

(
  • line
)
Object

Defined in lib\parser.js:147

Parses a bond line. Return value is an object:

 {
   'from': 3,
   'to': 4,
   'bondType': 1,
   'bondStereo': 0
 }

bondType is a code, and should be interpreted as follows:

Code Meaning
1 single
2 double
3 triple
4 aromatic
5 single or double
6 single or aromatic
7 double or aromatic
8 any

Codes 5-8 are can only be present when the file describes a search. They are never present in a molecule description.

bondStereo is a code, and should be interpreted as follows:

Code Meaning
1 Up
4 Either
6 Down

Parameters:

  • line String

    the line to parse

Returns:

Object:

data from the line

parseCountLine

(
  • line
)
Object

Defined in lib\parser.js:38

Parse the count line of a V2000 format molFile. Returns an object:

{
  'atoms': 15,
  'bonds': 14,
  'chiral': 1,
  'mLines': 999,
  'version': ' V2000'
}

Note that mLines should always be 999 for modern molfiles, to signal the mLines value is ignored. M lines are read until 'M END'.

Note that version will contain leading spaces if the version string is shorter than the 6 bytes alloted.

Parameters:

  • line String

    count line to parse

Returns:

Object:

data from the line

parseMol

(
  • mol
)
Object

Defined in lib\parser.js:397

Parses a V2000 molfile record and returns an Object containing the data therein.

 {
     atoms: [
       { x: 0.0, y: 0.0, z: 0.0, elname: 'Hf' }
       ...
     ],
     bonds: [
         { 3, 4, 1 },
         ...
     }
     properties: {
         CHG: {
            3: -1
         }
         ISO: {
         }
         RAD: {
         }
     }
     data: {
       ID: 'zwitterions_2'
    }
  }

Bonds and properties refer to atoms with 1-based indexes, as in the original file, but the atoms[] array is 0-based.

Parameters:

  • mol String

    the complete molfile, including newlines

Returns:

Object:

an object representing the contents of the molfile

parseProperty

(
  • line
)
Object

Defined in lib\parser.js:203

Parses a property line

Parameters:

  • line String

    the line to parse

Returns:

Object:

data from the line

prescanMol

(
  • mol
)
Object

Defined in lib\parser.js:285

Prescan the molfile data, find the newlines and boundaries of various blocks. Returns an object:

{
  newlines: [],     // offset of each newline
  firstM: 120,      // beginning of properties
  lastM: 154,       // end of properties
  firstAngle: 230,  // beginning of data
  sectionEnd: 500   // end of data
}

Parameters:

  • mol String

    the molfile data

Returns:

Object:

object containing useful offsets