Skip to content

Instantly share code, notes, and snippets.

View fredludlow's full-sized avatar

Fred Ludlow fredludlow

  • Astex
  • Cambridge, UK
View GitHub Profile
@fredludlow
fredludlow / gist:e0a2a4af29d902350c872162315538d1
Last active May 23, 2024 06:30
Run NGL.autoLoad on whole PDB (usuing local mirror)
/**
* Quick script to check cif parsing in NGL by attempting to
* autoLoad all entries from a local mirror.
* Smoke test rather than thorough validation!
*/
const _ = require('browser-env')()
const fs = require('fs');
const path = require('path');
@fredludlow
fredludlow / atom-monitor.js
Created November 7, 2017 14:58
Sketch of an atom monitor for NGL
/**
* Watches a structure component and maintains a list of atoms
* currently displayed in atomistic form.
*
* Provides a signal AtomMonitor.signals.updated
*/
const COMPONENT_SIGNALS = [
'representationAdded',
'representationRemoved',
@fredludlow
fredludlow / thumbnail2.js
Last active March 21, 2017 14:31
Thumbnail method for NGL
// These functions pulled out of prototype method, `this` has `stage` attribute
{
/** Returns a promise that resolves to an Image object/element */
getImage: function( params ) {
params = Object.assign( {
trim: false,
antialias: true,
transparent: false }, params );
@fredludlow
fredludlow / thumbnail.js
Created March 14, 2017 15:47
Create a thumbnail from an NGL stage instance
function getThumbnail(stage) {
var canvas, context, image = new Image();
function setupCanvas() {
canvas = document.createElement( 'canvas' );
canvas.style.visibility = "hidden";
canvas.width = 100;
canvas.height = 100;
document.body.append( canvas );
@fredludlow
fredludlow / bond-store.js
Created August 2, 2016 15:12
Sketch of atomIndex in bond-store
/**
* @file Bond Store
* @author Alexander Rose <alexander.rose@weirdbyte.de>
* @private
*/
import Store from "./store.js";
import BondProxy from "../proxy/bond-proxy.js";