Skip to main content

A python package for generating interactive views of chemical spaces.

Project description

Faerun (Python)

Faerun (Python) is based on the Lore.js 3D WebGL engine for interactive big data rendering and the FUn project. It facilitates the creation of interactive (2D and 3D) HTML plots of chemical data (or chemical spaces). Molecular structures are rendered using SmilesDrawer.

Associated Publication: https://academic.oup.com/bioinformatics/article/34/8/1433/4657075

Faerun Python

Installation

pip install faerun

Examples

The code of the examples shown above for creating interactive 2D and 3D maps from Drugbank can be found in the examples directory. Following, a simple example of plotting any data:

import numpy as np
from faerun import Faerun

faerun = Faerun(view='free')

t = np.linspace(0, 12.0, 326)
s = np.sin(np.pi * t)
c = np.cos(np.pi * t)

faerun.add_scatter('my_scatter',  { 'x': t, 'y': s, 'z': c, 'c': t / max(t) })
faerun.plot()

The code above writes two files to the current directory: index.html and data.js. These files can be used locally or be moved to a (even minimalistic) web server.

TODO

  • Add the abilty to draw shapes as well as colours
  • Make output templatable

Documentation

Faerun(title='python-faerun', clear_color='#111111', coords=True, coords_color='#888888', view='free', shader='circle')
Parameter Default Description
title 'python-faerun' The title of the HTML document.
clear_color '#111111' The clear colour, or background colour is used to clear the canvas after each rendering step.
coords True Whether or not to draw the coordinate axes.
coords_color '#888888' The colour used to draw the coordinate axes.
coords_box False Whether or not to show an encosing box as part of the coordinates.
view 'free' The view mode. Available options: free, front, back, left, right, bottom, top
Faerun.add_scatter(self, name, data, mapping={'x': 'x', 'y': 'y', 'z': 'z', 'c': 'c', 's': 's', 'labels': 'labels'},
                   colormap='plasma', shader='sphere', point_scale=1.0, max_point_size=100, fog_intensity=0.0, interactive=True)
Parameter Default Description
name The name of the plot (has to be unique, if another plot with the same name is added, the existing one will be overwritten).
data A dict or a Pandas DataFrame containing the data.
mapping {'x': 'x', 'y': 'y', 'z': 'z', 'c': 'c', 's': 's', 'labels': 'labels'} The mapping from the dict or DataFrame to the plot attributes.
colormap 'plasma' The colour map to be used. Valid values are matplotlib colormap names.
shader circle The name of the shader used to draw the points. Available options: circle, smoothCircle, sphere
point_scale 1.0 The scale of the points, which is also the radius for raycaster intersections.
max_point_size 100 The maximum size of a point when zooming in.
fog_intensity 0.0 The intensity of the fog (points further away fade to the background colour).
interactive True Whether the points are interactive (can be hovered).
, shader='circle'
Faerun.add_tree(self, name, data, mapping={'form': 'form', 'to': 'to', 'x': 'x', 'y': 'y', 'z': 'z', 'c': 'c'},
                color='#666666', colormap='plasma', fog_intensity=0.0, point_helper=None)
Parameter Default Description
name The name of the plot (has to be unique, if another plot with the same name is added, the existing one will be overwritten).
data A dict or a Pandas DataFrame containing the data.
mapping {'form': 'form', 'to': 'to', 'x': 'x', 'y': 'y', 'z': 'z', 'c': 'c', 's': 's', 'labels': 'labels'} The mapping from the dict or DataFrame to the plot attributes.
color '#666666' The default colour used when no colour values are supplied.
colormap 'plasma' The colour map to be used. Valid values are matplotlib colormap names.
fog_intensity 0.0 The intensity of the fog (points further away fade to the background colour).
point_helper None Using coordinates from a point helper (specified by name) via indices.
Faerun.plot(file_name='index', path='./', template='default')
Parameter Default Description
file_name 'index' The file name that is given to both the html and js file.
path './' The path to which the HTML and data files will be written.
template 'default' The HTML template to use. Currently the following templates are available: 'default', 'url_image', and 'smiles'

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

faerun-0.1.40.tar.gz (22.5 kB view details)

Uploaded Source

Built Distribution

faerun-0.1.40-py3-none-any.whl (34.4 kB view details)

Uploaded Python 3

File details

Details for the file faerun-0.1.40.tar.gz.

File metadata

  • Download URL: faerun-0.1.40.tar.gz
  • Upload date:
  • Size: 22.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.29.1 CPython/3.6.8

File hashes

Hashes for faerun-0.1.40.tar.gz
Algorithm Hash digest
SHA256 51ba03ee148898ef7c9b1575831d32aaa735da1ab3f46bc9f78ff21c443918ba
MD5 a3951da5ebd329659469e9e91bfb3ba4
BLAKE2b-256 ea3df5415dcdf647c84002873130883bdb62dc73c6376c296f472d04117a65ce

See more details on using hashes here.

File details

Details for the file faerun-0.1.40-py3-none-any.whl.

File metadata

  • Download URL: faerun-0.1.40-py3-none-any.whl
  • Upload date:
  • Size: 34.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.29.1 CPython/3.6.8

File hashes

Hashes for faerun-0.1.40-py3-none-any.whl
Algorithm Hash digest
SHA256 d88506dcc4528b3ec7e5a13e89aaf2e9963f52b8e5affa9cf3063a206b68197b
MD5 0b8f9b149eb732b99ea518a01c9a4680
BLAKE2b-256 0128ee04f633ce0a581a4be577de8ce514fe2ece6f931220e88a724c823848cd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page