Skip to content

Instantly share code, notes, and snippets.

View maxentile's full-sized avatar

Josh Fass maxentile

  • Relay Therapeutics
  • Cambridge, MA
View GitHub Profile
@maxentile
maxentile / output.txt
Created July 8, 2020 22:16
molecules and SMIRKS patterns where RDKit and OpenEye chemical_environment_matches disagree
openforcefield version: 0.7.0
rdkit version: 2020.03.4
openeye version: 2019.Oct.2
[... suppressing stereochem warnings ...]
CN(=O)=O
[#1:1]-[#6X4]~[*+1,*+2] (3 in RDKit, 0 in OpenEye)
[*:1]-[#6X4:2]-[#7X3:3]-[*:4] (3 in RDKit, 0 in OpenEye)
[*:1]-[#7X4,#7X3,#7X2-1:2]-[*:3] (2 in RDKit, 0 in OpenEye)
##geometric functions
using LinearAlgebra:dot, norm, atan, acos, ×, ⋅
distance(x, y) = norm(x - y)
∠(a, b, c) = acos(-dot((b-a)/norm(b-a), (c-b)/norm(c-b)))
function dihedral_angle(a, b, c, d)
b1 = b - a
# b2 = c - b # mdtraj convention
b2 = b - c # openmm convention
b3 = d - c
@maxentile
maxentile / smirkalizer.py
Created May 29, 2020 18:58
[wip] interpreting a restricted smirks subset
"""parse subset of smirks that covers "self-contained" patterns
like [<atom>:1] <bond> [<atom>:2]
but not like [<atom>:1] <bond> [<atom>:2]=[<atom>]
or [<atom>:1] <bond> [<atom>$(*~[#6]):2]
later, it's straightforward to extend to handle recursive smarts (like "$(*~[#6])")
but less straightforward to handle extended chemical environments
@maxentile
maxentile / [WIP] Rose trees + Zanella process.ipynb
Created May 6, 2020 21:59
[wip] aiming to apply informed / accelerated MCMC to Bayesian rose tree model
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@maxentile
maxentile / locally_balanced_proposals.py
Last active March 27, 2020 14:50
implementation of informed discrete proposals following [Zanella, 2017] https://arxiv.org/abs/1711.07424
# Implementation of balanced locally informed proposals, following:
# [Zanella, 2017] "Informed proposals for local MCMC in discrete spaces"
# https://arxiv.org/abs/1711.07424
# Usage: define a neighborhood_fxn(x) that returns an iterable of x's neighbors.
# Where you would have made uninformed proposals using this neighborhood, you
# can now make target-informed proposals using this neighborhood.
# Assumption: neighborhood_fxn is deterministic
# Assumption: if y is in neighborhood_fxn(x), then x is in neighborhood_fxn(y)
@maxentile
maxentile / topological_symmetry_perception_task.ipynb
Created March 1, 2020 04:15
try to assign unique labels to each unique-up-to-symmetry atom in a partially symmetric molecule
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@maxentile
maxentile / dolly_the_ligand.py
Last active March 5, 2020 02:10
you've got clones!
from openmmtools.testsystems import HostGuestVacuum
from simtk import openmm as mm
testsystem = HostGuestVacuum(constraints=None)
ligand_residue = list(testsystem.topology.residues())[1]
atoms_in_ligand = [atom.index for atom in ligand_residue.atoms()]
def filter_from_subset(atom_subset=None):
if type(atom_subset) == type(None):
import numpy as np
from numba import jit
AND = np.bitwise_and
def off_mol_to_arrays(mol):
"""accept an openforcefield.topology.Molecule
return
* an (n_atoms, 2) integer array containing (atomic_number, formal_charge) for each atom
@maxentile
maxentile / water14_no_local_energy_minimization.py
Created December 12, 2019 02:08
MB-Pol spurious energy minima?
from simtk.openmm import app
import simtk.openmm as mm
from simtk import unit
import mbpol
import numpy as np
import mdtraj as md
import matplotlib.pyplot as plt
# create simulation
pdb = app.PDBFile("water14_cluster.pdb")
# simplified from GP structure learning example, section 7.2
# https://github.com/probcomp/pldi2019-gen-experiments/tree/master/gp -- `cov_tree.jl` and `lightweight.jl`
using Gen
# abstract types for binary expression tree
abstract type Node end
abstract type LeafNode <: Node end
abstract type BinaryOpNode <: Node end
num_children(node::LeafNode) = 0