Giter Site home page Giter Site logo

sdftosvg's Introduction

SDF to SVG

Build Status

This is a javascript package for rendering SDF chemical structure files as SVGs.

sdftosvg is built with PubChem SDF files in mind, because PubChem includes extra helpful annotations in their structure files.

Examples

HBCDD Lindane PFOS

Command Line Usage

$ sdftosvg ./input.sdf ./output.svg

Command Line Arguments

  Usage: convert [options] <input> <output>

  Options:

    -h, --help                     output usage information
    -V, --version                  output the version number
    -w, --width <n>                Output width
    -h, --height <n>               Output height
    -b, --background <background>  Background color

NPM Package Usage

var renderer = require('sdftosvg');

// Convert SDF as string to SVG
var fs = require('fs');
var sdf = fs.readFileSync('./pcb-138.sdf');
renderer.renderSdfToSvg(sdf, {}, function(svg) {
  console.log(svg);
});

// Convert SDF file to SVG file
renderer.renderSdfToSvgFile('./pcb-138.sdf', './pcb-138.svg');

Methods

renderSdfToSvg(sdf, options, callback)

Renders an SDF string to an SVG string.

  • sdf: string containing SDF file contents
  • options: options object, defined below
  • callback: function called after rendering that is given output SVG as a string

renderSdfToSvgFile(inputFile, outputFile, options)

Renders an SDF file to an SVG file.

  • inputFile: path to input SDF file
  • outputFile: path to save output SVG file
  • options: options object, defined below

Options

The options object can contain the following keys:

  • width: output width, in pixels

  • height: output height, in pixels

  • atomRadius: radius of atom circles

  • bondStrokeWidth: stroke width of bond lines

  • backgroundColor: background color

  • colors: object mapping chemical abbreviations to colors. By default, sdftosvg uses the JMol color scheme. For example, to override:

    {
      "C": "red",
      "O": "blue",
      "H": "green"
    }

Todo

A number of features remain to be added:

  • Allow specifying custom color scheme on the command line.
  • Allow further customization of output

sdftosvg's People

Contributors

herbps10 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.