Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Facade #71

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 0 additions & 62 deletions fold.py

This file was deleted.

27 changes: 27 additions & 0 deletions foldFacade.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env python3
from simtk.openmm.app import *
from simtk.openmm import *
from simtk.unit import *
from sys import stdout
import os
import sys
import argparse

from parser import Parser
from unfold import Unfold
from simulate import Simulate
from modeller import ModellerF

args = Parser(argparse).parse()

try:
platform = Platform.getPlatformByName("CUDA")
except Exception:
platform = Platform.getPlatformByName("OpenCL")

pdb = Unfold(args).unfold
forcefield = ForceField('amber03.xml', 'amber03_obc.xml')

ModellerF(forcefield).model()

Simulate(forcefield, modeller, args).simulate()
12 changes: 12 additions & 0 deletions modeller.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import sys


class ModellerF:
def __init__(self, forcefield):
self.forcefield = forcefield

def model(self):
#forcefield = ForceField('amber99sb.xml', 'tip3p.xml')
modeller = Modeller(pdb.topology, pdb.positions)
modeller.addHydrogens(self.forcefield)
print(modeller.topology)
29 changes: 29 additions & 0 deletions simulate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import sys


class Simulate:
def __init__(self, forcefield, modeller, args):
self.forcefield = forcefield
self.modeller = modeller
self.args = args

def simulate(self):
system = self.forcefield.createSystem(self.modeller.topology,
# matches https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2980750/#bib39
implicitSolvent=OBC2,
nonbondedMethod=NoCutoff, nonbondedCutoff=1*nanometer,
constraints=HBonds)
integrator = LangevinIntegrator(
self.args.temp*kelvin, 1/picosecond, 2*femtoseconds)
simulation = Simulation(
self.modeller.topology, system, integrator, platform)
simulation.context.setPositions(self.modeller.positions)
simulation.minimizeEnergy()

steps = self.args.steps
steps_write = max(1, steps//self.args.writes)
print("writing every %d steps" % steps_write)
simulation.reporters.append(PDBReporter(args.out, steps_write))
simulation.reporters.append(StateDataReporter(
stdout, steps_write, step=True, potentialEnergy=True, temperature=True))
simulation.step(steps)
23 changes: 23 additions & 0 deletions unfold.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import sys


class Unfold:
def __init__(self, args):
self.args = args

def unfold(self):
if self.args.scratch:
# unfolded protein
if self.args.fasta is not None:
fasta = self.args.fasta
else:
protein_fasta = "proteins/villin/1vii.fasta"
fasta = open(protein_fasta).read().split("\n")[1]
print("folding %s" % fasta)
from lib import write_unfolded
write_unfolded(fasta, "/tmp/unfolded.pdb")
pdb = PDBFile("/tmp/unfolded.pdb")
else:
# already folded protein
pdb = PDBFile(self.args.pdb)
return pdb