Skip to content

Commit

Permalink
make PyRosetta and Rosetta import work and still be documented.
Browse files Browse the repository at this point in the history
  • Loading branch information
jadolfbr committed Feb 14, 2018
1 parent d66aa28 commit a469838
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 39 deletions.
25 changes: 11 additions & 14 deletions apps/pilot/jadolfbr/glycan_basic_LCM_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@
import os,sys
from argparse import ArgumentParser

from rosetta import *
from pyrosetta import *
from rosetta.protocols.carbohydrates import LinkageConformerMover
from rosetta.protocols.carbohydrates import SimpleGlycosylateMover
from rosetta.core.pose import parse_resnum
import rosetta
import pyrosetta

init("-include_sugars -write_pdb_link_records")
pyrosetta.init("-include_sugars -write_pdb_link_records")


def get_parser():
Expand Down Expand Up @@ -47,24 +44,24 @@ def get_parser():



p = pose_from_file(options.infile)
scorefxn = get_score_function()
p = pyrosetta.pose_from_pdb(options.infile)
scorefxn = pyrosetta.get_score_function()
KT = 1.0




LCM = LinkageConformerMover()
LCM = rosetta.protocols.carbohydrates.LinkageConformerMover()
LCM.set_x_standard_deviations(2)
SGM = SimpleGlycosylateMover()
SGM = rosetta.protocols.carbohydrates.SimpleGlycosylateMover()

resnum = parse_resnum(options.glycosylation_position, p)
resnum = rosetta.core.pose.parse_resnum(options.glycosylation_position, p)
SGM.set_position(resnum)
SGM.set_glycosylation(options.glycosylation_name)
SGM.apply(p)

### This will be unnessessary very soon!
mm = MoveMap()
mm = pyrosetta.MoveMap()
for i in range(1, p.total_residue() + 1):
if (p.residue_type(i).is_carbohydrate()):
mm.set_bb(i, True)
Expand All @@ -73,9 +70,9 @@ def get_parser():


for i in range(1, int(options.nstruct) + 1 ):
p_copy = Pose(p)
p_copy = pyrosetta.Pose(p)

MC = MonteCarlo(p_copy, scorefxn, KT)
MC = pyrosetta.MonteCarlo(p_copy, scorefxn, KT)
outname = os.path.basename(options.infile).replace(".pdb", "")+"_out_"+repr(i)+".pdb"
for x in range(1, int(options.cycles)+1):
print "LCM Round "+repr(x)
Expand Down
8 changes: 4 additions & 4 deletions apps/public/pyrosetta/build_loop_pyrosetta.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
from jade.rosetta_jade.flag_util import get_common_flags_string_for_init
from jade.basic.path import get_decoy_name

from rosetta import *
from pyrosetta import *
import pyrosetta
import rosetta

init( get_common_flags_string_for_init() )
pyrosetta.init( get_common_flags_string_for_init() )


def get_parser():
Expand Down Expand Up @@ -62,7 +62,7 @@ def get_parser():
options = parser.parse_args()

print(options)
pose = pose_from_pdb(options.pdb)
pose = pyrosetta.pose_from_pdb(options.pdb)

refpose_name = "starting_model_refpose"
pose.reference_pose_from_current(refpose_name, True)
Expand Down
8 changes: 4 additions & 4 deletions apps/public/pyrosetta/find_my_glycans.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python

from rosetta import *
from pyrosetta import *
import pyrosetta
import rosetta

import sys
import os
Expand All @@ -20,7 +20,7 @@ def get_parser():

if __name__ == "__main__":

init("-include_sugars -write_pdb_link_records")
pyrosetta.init("-include_sugars -write_pdb_link_records")
if len(sys.argv) == 1:
sys.exit("Please specify a PDB on the command line as the only argument")

Expand All @@ -29,7 +29,7 @@ def get_parser():
print "Please specifiy a PDB as the only argument to this script.\n"
sys.exit()

pose = pose_from_pdb(sys.argv[1])
pose = pyrosetta.pose_from_pdb(sys.argv[1])

for resnum in range(1, pose.total_residue() +1 ):
if pose.residue( resnum ).is_carbohydrate():
Expand Down
9 changes: 5 additions & 4 deletions apps/public/pyrosetta/find_my_residues.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import sys
from argparse import ArgumentParser

from rosetta import *
from pyrosetta import *
init("-include_sugars -ignore_unrecognized_res -ignore_zero_occupancy false")
import rosetta
import pyrosetta

pyrosetta.init("-include_sugars -ignore_unrecognized_res -ignore_zero_occupancy false")


def get_parser():
Expand All @@ -32,7 +33,7 @@ def get_parser():
options = parser.parse_args()


pose = pose_from_pdb(options.pdb_file)
pose = pyrosetta.pose_from_pdb(options.pdb_file)

print "#resnum chain_num pdb_num chain "
for i in range(1, pose.total_residue() +1 ):
Expand Down
25 changes: 13 additions & 12 deletions apps/public/pyrosetta/get_mutation_energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@

#Instructions: Look at the input options. Set at least --pdb and --region. (python get_mutation_energy.py --pdb mypdbfile.pdb --region 1:10:B)

from rosetta import *
from pyrosetta import *
import pyrosetta
import rosetta

from argparse import ArgumentParser
import os
import sys
Expand All @@ -21,7 +22,7 @@

opts = [ '-ex1' , '-ex2', '-ignore_unrecognized_res', '-use_input_sc']

init(" ".join(opts))
pyrosetta.init(" ".join(opts))


##Setup Options and Script Inputs:
Expand Down Expand Up @@ -67,7 +68,7 @@ def get_parser():

##Check that options are set.
parser = get_parser()
(options, args) = parser.parse_args()
options = parser.parse_args()

if not options.pdb:
sys.exit("Input PDB Required")
Expand All @@ -93,16 +94,16 @@ def get_parser():
OUTFILE = open(options.outpath+"/"+options.filename, 'w')

#Load the PDB
pose = Pose()
pose_from_pdb(pose, options.pdb)
pose = pyrosetta.Pose()
pyrosetta.pose_from_pdb(pose, options.pdb)

#Create the Scorefunction
scorefxn = create_score_function("talaris2014")
scorefxn.set_weight(chainbreak, 100)
scorefxn = pyrosetta.get_fa_scorefxn()
scorefxn.set_weight(rosetta.core.scoring.chainbreak, 100)


#Create the objects we need
rel = FastRelax(scorefxn)
rel = rosetta.protocols.relax.FastRelax(scorefxn)
codes = RestypeDefinitions()

if options.alanine_scan:
Expand All @@ -114,7 +115,7 @@ def get_parser():
#Set movemap if nessessary
if not options.relax_whole_structure:
print "\nSetting backbone movement for chain "+chain+" only.\n"
mm = MoveMap()
mm = pyrosetta.MoveMap()
for i in range(1, pose.total_residue()+1):
if pose.pdb_info().chain(i) == chain:
mm.set_bb(i, True)
Expand All @@ -134,7 +135,7 @@ def get_parser():
rosetta_end = pose.total_residue();


pose_copy = Pose()
pose_copy = pyrosetta.Pose()
pose_copy.assign(pose)


Expand Down Expand Up @@ -170,7 +171,7 @@ def get_parser():
print "\n Starting mutant "+pdbSP[0]+"_"+pdbSP[1]+"_"+residue+".pdb\n"
#Start at the same structure.
pose.assign(pose_copy)
mutate_residue(pose, i, residue)
pyrosetta.toolbox.mutate_residue(pose, i, residue)



Expand Down
22 changes: 21 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
# Skip non-pip-installable dependencies
#Python3.3 only:

autodoc_mock_imports = ["rosetta", 'pyrosetta']
autodoc_mock_imports = ["rosetta", 'pyrosetta'] #This did not work.

"""
from unittest.mock import MagicMock
Expand All @@ -73,6 +73,26 @@ def __init__(self):
sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)
"""

import mock

MOCK_MODULES = ['rosetta',
'pyrosetta',
'pyrosetta.toolbox',
'rosetta.protocols.carbohydrates',
'rosetta.core.pose',
'rosetta.core.conformation',
'rosetta.protocols.loops',
'rosetta.protocols.antibody',
'rosetta.protocols.carbohydrates',
'rosetta.core.kinematics',
'rosetta.protocols.loops.loop_closure.ccd',
'rosetta.core.chemical',
'rosetta.protocols.relax']

for mod_name in MOCK_MODULES:
sys.modules[mod_name] = mock.Mock()



# Get the project root dir, which is the parent dir of this
cwd = os.getcwd()
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ sphinxcontrib-websupport==1.0.1
statsmodels==0.8.0
weblogo>=3.4
xmltodict>=0.10.2
mock>=2.0.0

0 comments on commit a469838

Please sign in to comment.