Giter Club home page Giter Club logo

chemfilesviewer.jl's Introduction

ChemfilesViewer

Stable Dev Build Status Coverage Twitter

A julia library to visualize chemical molecules and other structures in the Chemfiles format.

The structures can be rendered in Jupyter or in an external window (via Blink). Pluto should work if WebIO support is implemented.

Demo

demo

Usage

using ChemfilesViewer

# read molecule
mol = load_moelcule("mol.sdf")

# render molecule
render_molecule(mol)
# render another molecule in the same window
render_molecule!(mol)

# save reference to last used output
viewer_id = get_current_chemviewer_id()
    
# change properties
d = generate_dict_molecule(mol)
d["atoms"][1]["color"] = "#f00000"
d["atoms"][1]["label"] = "Important atom"
d["atoms"][1]["radius"] = 1.0
render_dict_molecule(d, chemviewer_id=viewer_id)

# add labels
d["labels"] = [
    Dict(
        "label" => "porphyrin",
        "location" => [0,0,2],
        "color" => "#600000"
    ),
    Dict(
        "label" => "pyrrole",
        "location" => [-0.6, 3.2, 0],
        "style" => "font-size:80%;opacity:0.5;"
    )
]
render_dict_molecule!(d, options=Dict("showLabels" => true))

# change view
set_camera_position!("x", "-")
set_options!(Dict("drawingType" => "wireframe"))
set_camera_position!("c", "+")
set_options!(Dict("drawingType" => "ball and stick"))

# change style
set_options!(Dict("styles" => Dict(
    "H" => Dict("color" => "#c0c0c0", "radius" => 0.4),
    "N" => Dict("color" => "#241571"),
    "bond" => Dict("color" => "#ffffff", "radius" => 0.3)
)))

# clar labels (atom-labels are kept, though)
clear_labels!()

# add label
add_label!(Dict(
    "label" => "some other text",
    "location" => [2,5,5],
    "style" => "font-weight:bold;color:blue;font-size:3em;"
))

# save image
save_image("test.png")
# save labels (this is somewhat experimental)
save_image_labels("test_labels.png")
# save the overlay of the render and the labels
save_overlay("test.png", "test_labels.png", "test_both.png")

# create a nice fadeout effect
save("test_fadeout.png", fadeout_img("test_both.png"))

Use mouse to rotate, zoom and pan. Keyboard shortcuts x, y, z set the view along the x, y and z axis. Analogously, a, b, c set the view along the unit cell vectors. Uppercase letters (X, Y, Z, A, B, C) set the opposite view direction.

Notes

The javascript rendering is based on Patrick Fuller's imolecule.

Get in touch

Please post issues, suggestions, and pull requests on github. Follow me on twitter for updates and more information about this project: Twitter

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.