Exact Mass Database Manager (emdb)

3.5.0 · active · verified Wed Apr 22

emdb is a JavaScript/TypeScript library designed for managing and querying databases of molecular formulas, primarily focused on exact mass calculations in cheminformatics. It is part of the larger 'mass-tools' monorepo maintained by cheminfo. The library is currently stable at version 7.56.0 (as of April 2026), demonstrating a rapid release cadence with multiple updates often shipped monthly, indicating very active development. Key functionalities include loading various predefined chemical databases (e.g., test, KnapSack, commercial, contaminants), creating custom molecular formula databases from structured arrays or Google Sheets, and providing robust utility modules for generating molecular formulas from peptide or nucleotide sequences. It enhances cheminformatics applications by offering precise mass calculations and comprehensive molecular formula manipulation, including detailed information such as exact mass, molecular weight, charge, OCL (Open Chemistry Libre), and mass spectrometry filter data.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates loading a test database, using the MF utility, generating molecular formulas from peptide and nucleotide sequences, and creating a custom database from an array.

import emdb from 'emdb';

// 1. Initialize the EMDB manager and load a test database
const dbManager = emdb;
dbManager.loadTest(); // Loads a database named 'test' with MFs from C1 to C100

console.log('Test database loaded. Number of entries (approx):', Object.keys(dbManager.db.test).length);

// 2. Use the Molecular Formula utility to parse and get information
const mfParser = new dbManager.Util.MF('C6H6O');
console.log('MF Parser info for C6H6O:', mfParser.getInfo());

// 3. Generate a molecular formula from a peptide sequence
const peptideSequence = 'VALINE';
const peptideMF = dbManager.Util.Peptide.sequenceToMF(peptideSequence);
console.log(`Molecular formula for peptide '${peptideSequence}': ${peptideMF}`);

// 4. Generate a molecular formula from a DNA nucleotide sequence
const dnaSequence = 'GATTACA';
const dnaMF = dbManager.Util.Nucleotide.mfFromSequence(dnaSequence, { kind: 'dna', circular: false });
console.log(`Molecular formula for DNA sequence '${dnaSequence}': ${dnaMF}`);

// 5. Example of loading a database from an array of molecular formulas
const customMFs = ['C2H4O2', 'C3H8O'];
dbManager.fromArray(customMFs, { database: 'myCustomDB' });
console.log('Custom database loaded. Entries:', dbManager.db.myCustomDB);

view raw JSON →