In [1]:
import os
import numpy as np
import rosetta as r
import random
r.init()
r.__version__
Out[1]:
'56891:56891:6efc58f8abb54611ace5a6cdd7e69e6c970a01ef'
In [2]:
pmm = r.PyMOLMover(target_host="127.0.0.1")
In [3]:
#Makin a mutation after the helix is created also works
#Create sequence 
seq = 'R'*5 + 'R'+'R'*5; print seq
pose = r.pose_from_sequence(seq, res_type="fa_standard") 
scorefxn = r.get_fa_scorefxn()

#Create perfect alpha helix
#phi = -57.8, Psi -47.0
for i in range(1, pose.total_residue()+1):
    pose.set_phi(i, -57.9)
    pose.set_psi(i, -47.9)

#Make mutation    
mut = r.MutateResidue(6 , 'R1A')
mut.apply(pose)    
    
#pack side chains
packer_task = r.standard_packer_task(pose)
packer_task.restrict_to_repacking() 
print packer_task
pack_mover = r.PackRotamersMover(scorefxn, packer_task) 
pack_mover.apply(pose) 

#show the resuls
print scorefxn(pose)
pmm.apply(pose)
RRRRRRRRRRR
#Packer_Task

resid	pack?	design?	allowed_aas
1	TRUE	FALSE	ARG:NtermProteinFull
2	TRUE	FALSE	ARG
3	TRUE	FALSE	ARG
4	TRUE	FALSE	ARG
5	TRUE	FALSE	ARG
6	TRUE	FALSE	R1A
7	TRUE	FALSE	ARG
8	TRUE	FALSE	ARG
9	TRUE	FALSE	ARG
10	TRUE	FALSE	ARG
11	TRUE	FALSE	ARG:CtermProteinFull

-1.05767090814
In [4]:
pose.chi(5,6)
Out[4]:
-100.07056096817568
In [5]:
[attr for attr in dir(pose.residue(6)) if "ch" in attr]
Out[5]:
['atomic_charge',
 'attached_H_begin',
 'attached_H_end',
 'chain',
 'chi',
 'chi_atoms',
 'chi_rotamers',
 'connections_match',
 'first_sidechain_atom',
 'first_sidechain_hydrogen',
 'is_branch_lower_terminus',
 'is_charged',
 'mainchain_atom',
 'mainchain_atoms',
 'mainchain_torsion',
 'mainchain_torsions',
 'n_mainchain_atoms',
 'nchi',
 'set_all_chi',
 'set_chi',
 'sidechainAtoms_begin']
In [6]:
#First try the obvious chi_rotamers!
pose.residue(6).chi_rotamers(1)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-6-8a0ba53d69e7> in <module>()
      1 #First try the obvious chi_rotamers!
----> 2 pose.residue(6).chi_rotamers(1)

TypeError: No Python class registered for C++ class utility::vector1<std::pair<double, double>, std::allocator<std::pair<double, double> > >
In [7]:
# Try advice from https://www.rosettacommons.org/content/rotamer-libraries-pyrosetta
import rosetta.core.pack.dunbrack as dr
In [8]:
dir(dr)
rot = dr.SingleResidueDunbrackLibrary()
print rot
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-8-7f65fdefc8df> in <module>()
      1 dir(dr)
----> 2 rot = dr.SingleResidueDunbrackLibrary()
      3 print rot

RuntimeError: This class cannot be instantiated from Python
In [9]:
#As per the FAQ this should work
#http://www.pyrosetta.org/faq#TOC-5.-How-do-I-convert-AP-or-CAP-objects-to-regular-class-objects-
rot = dr.SingleResidueDunbrackLibraryCAP().get()
print rot
#But it just return None
None
In [10]:
#Maybe it's in the pack_mover
b = r.utility.OStringStream()
pack_mover.show(b)
print b.str()
pack_mover.rotamer_sets()
Mover name: PackRotamersMover, Mover type: PackRotamersMover, Mover current tag:NoTag
Score function: talaris2013

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-10-07a6709b0baa> in <module>()
      3 pack_mover.show(b)
      4 print b.str()
----> 5 pack_mover.rotamer_sets()

TypeError: No to_python (by-value) converter found for C++ type: utility::pointer::owning_ptr<core::pack::rotamer_set::RotamerSets const>