Commit 4e9d7b51 authored by Bharath Ramsundar's avatar Bharath Ramsundar
Browse files

Bugfixes

parent 5692a18f
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -22,14 +22,14 @@ install:
- conda install h5py
- pip install keras
- export KERAS_BACKEND=tensorflow
- conda install seaborn
- conda install six
- conda install dill
- conda install runipy
- pip install runipy
- pip install nglview
- conda install -c omnia mdtraj
- python setup.py install
#- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.12.0rc1-cp27-none-linux_x86_64.whl;
#  -O else export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.12.0rc1-cp35-cp35m-linux_x86_64.whl;
#  -O fi 
#- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then pip install --ignore-installed --upgrade $TF_BINARY_URL;
#  -O else pip3 install --ignore-installed --upgrade $TF_BINARY_URL;
#  -O fi
- conda install -c https://conda.anaconda.org/jjhelmus tensorflow=0.10.0rc0
script:
- nosetests -v deepchem --nologcapture
+1 −1
Original line number Diff line number Diff line
@@ -10,7 +10,6 @@ import pandas as pd
import numpy as np
import csv
import numbers
import dill
import tempfile
from rdkit import Chem
import time
@@ -84,6 +83,7 @@ def get_user_specified_features(df, featurizer, verbose=True):
    2) Complex featurization
      -) PDB files for interacting molecules.
    3) User specified featurizations.

  """
  time1 = time.time()
  df[featurizer.feature_fields] = df[featurizer.feature_fields].apply(pd.to_numeric)
+73 −72
Original line number Diff line number Diff line
import nglview
import tempfile
import os
import mdtraj as md
import numpy as np
import tempfile
from rdkit import Chem
from rdkit.Chem import Draw
from itertools import islice
from IPython.display import Image, HTML, display

def combine_mdtraj(protein, ligand):
  chain = protein.topology.add_chain()
  residue = protein.topology.add_residue("LIG", chain, resSeq=1)
  for atom in ligand.topology.atoms:
      protein.topology.add_atom(atom.name, atom.element, residue)
  protein.xyz = np.hstack([protein.xyz, ligand.xyz])
  protein.topology.create_standard_bonds()
  return protein

def visualize_complex(complex_mdtraj):
  ligand_atoms = [a.index for a in complex_mdtraj.topology.atoms if "LIG" in str(a.residue)]
  binding_pocket_atoms = md.compute_neighbors(complex_mdtraj, 0.5, ligand_atoms)[0]
  binding_pocket_residues = list(set([complex_mdtraj.topology.atom(a).residue.resSeq for a in binding_pocket_atoms]))
  binding_pocket_residues = [str(r) for r in binding_pocket_residues]
  binding_pocket_residues = " or ".join(binding_pocket_residues)

  traj = nglview.MDTrajTrajectory( complex_mdtraj ) # load file from RCSB PDB
  ngltraj = nglview.NGLWidget( traj )
  ngltraj.representations = [
  { "type": "cartoon", "params": {
  "sele": "protein", "color": "residueindex"
  } },
  { "type": "licorice", "params": {
  "sele": "(not hydrogen) and (%s)" %  binding_pocket_residues
  } },
  { "type": "ball+stick", "params": {
  "sele": "LIG"
  } }
  ]
  return ngltraj

def visualize_ligand(ligand_mdtraj):
  traj = nglview.MDTrajTrajectory( ligand_mdtraj ) # load file from RCSB PDB
  ngltraj = nglview.NGLWidget( traj )
  ngltraj.representations = [
    { "type": "ball+stick", "params": {"sele": "all" } } ]
  return ngltraj

def convert_lines_to_mdtraj(molecule_lines):
  tempdir = tempfile.mkdtemp()
  molecule_file = os.path.join(tempdir, "molecule.pdb")
  with open(molecule_file, "wb") as f:
    f.writelines(molecule_lines)
  molecule_mdtraj = md.load(molecule_file)
  return molecule_mdtraj

def display_images(filenames):
    """Helper to pretty-print images."""
    imagesList=''.join(
        ["<img style='width: 140px; margin: 0px; float: left; border: 1px solid black;' src='%s' />"
         % str(s) for s in sorted(filenames)])
    display(HTML(imagesList))

def mols_to_pngs(mols, basename="test"):
    """Helper to write RDKit mols to png files."""
    filenames = []
    for i, mol in enumerate(mols):
        filename = "%s%d.png" % (basename, i)
        Draw.MolToFile(mol, filename)
        filenames.append(filename)
    return filenames
# TODO(rbharath): Commenting out this file for now. Will be moved to a new repository.
#import nglview
#import tempfile
#import os
#import mdtraj as md
#import numpy as np
#import tempfile
#from rdkit import Chem
#from rdkit.Chem import Draw
#from itertools import islice
#from IPython.display import Image, HTML, display
#
#def combine_mdtraj(protein, ligand):
#  chain = protein.topology.add_chain()
#  residue = protein.topology.add_residue("LIG", chain, resSeq=1)
#  for atom in ligand.topology.atoms:
#      protein.topology.add_atom(atom.name, atom.element, residue)
#  protein.xyz = np.hstack([protein.xyz, ligand.xyz])
#  protein.topology.create_standard_bonds()
#  return protein
#
#def visualize_complex(complex_mdtraj):
#  ligand_atoms = [a.index for a in complex_mdtraj.topology.atoms if "LIG" in str(a.residue)]
#  binding_pocket_atoms = md.compute_neighbors(complex_mdtraj, 0.5, ligand_atoms)[0]
#  binding_pocket_residues = list(set([complex_mdtraj.topology.atom(a).residue.resSeq for a in binding_pocket_atoms]))
#  binding_pocket_residues = [str(r) for r in binding_pocket_residues]
#  binding_pocket_residues = " or ".join(binding_pocket_residues)
#
#  traj = nglview.MDTrajTrajectory( complex_mdtraj ) # load file from RCSB PDB
#  ngltraj = nglview.NGLWidget( traj )
#  ngltraj.representations = [
#  { "type": "cartoon", "params": {
#  "sele": "protein", "color": "residueindex"
#  } },
#  { "type": "licorice", "params": {
#  "sele": "(not hydrogen) and (%s)" %  binding_pocket_residues
#  } },
#  { "type": "ball+stick", "params": {
#  "sele": "LIG"
#  } }
#  ]
#  return ngltraj
#
#def visualize_ligand(ligand_mdtraj):
#  traj = nglview.MDTrajTrajectory( ligand_mdtraj ) # load file from RCSB PDB
#  ngltraj = nglview.NGLWidget( traj )
#  ngltraj.representations = [
#    { "type": "ball+stick", "params": {"sele": "all" } } ]
#  return ngltraj
#
#def convert_lines_to_mdtraj(molecule_lines):
#  tempdir = tempfile.mkdtemp()
#  molecule_file = os.path.join(tempdir, "molecule.pdb")
#  with open(molecule_file, "wb") as f:
#    f.writelines(molecule_lines)
#  molecule_mdtraj = md.load(molecule_file)
#  return molecule_mdtraj
#
#def display_images(filenames):
#    """Helper to pretty-print images."""
#    imagesList=''.join(
#        ["<img style='width: 140px; margin: 0px; float: left; border: 1px solid black;' src='%s' />"
#         % str(s) for s in sorted(filenames)])
#    display(HTML(imagesList))
#
#def mols_to_pngs(mols, basename="test"):
#    """Helper to write RDKit mols to png files."""
#    filenames = []
#    for i, mol in enumerate(mols):
#        filename = "%s%d.png" % (basename, i)
#        Draw.MolToFile(mol, filename)
#        filenames.append(filename)
#    return filenames
+7 −10
Original line number Diff line number Diff line
echo '$TRAVIS_PULL_REQUEST $TRAVIS_BRANCH'
echo $TRAVIS_PULL_REQUEST $TRAVIS_BRANCH

############################################################ DEBUG
## TODO(rbharath): UNCOMMENT BEFORE MERGE!
#if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then
#    echo "This is a pull request. No deployment will be done."; exit 0
#fi
#
#if [[ "$TRAVIS_BRANCH" != "master" ]]; then
#    echo "No deployment on BRANCH='$TRAVIS_BRANCH'"; exit 0
#fi
############################################################ DEBUG
if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then
    echo "This is a pull request. No deployment will be done."; exit 0
fi

if [[ "$TRAVIS_BRANCH" != "master" ]]; then
    echo "No deployment on BRANCH='$TRAVIS_BRANCH'"; exit 0
fi

# Create the docs and push them to S3
# -----------------------------------