Skip to content

Instantly share code, notes, and snippets.

@ajasja
Created August 26, 2014 18:34
Show Gist options
  • Save ajasja/7987aeb1ea70417b6971 to your computer and use it in GitHub Desktop.
Save ajasja/7987aeb1ea70417b6971 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"worksheets": [
{
"cells": [
{
"metadata": {},
"cell_type": "code",
"input": "import os\nimport numpy as np\nimport rosetta as r\nimport random\nr.init()\nr.__version__",
"prompt_number": 1,
"outputs": [
{
"text": "'56891:56891:6efc58f8abb54611ace5a6cdd7e69e6c970a01ef'",
"output_type": "pyout",
"metadata": {},
"prompt_number": 1
}
],
"language": "python",
"trusted": true,
"collapsed": false
},
{
"metadata": {},
"cell_type": "code",
"input": "pmm = r.PyMOLMover(target_host=\"127.0.0.1\")",
"prompt_number": 2,
"outputs": [],
"language": "python",
"trusted": true,
"collapsed": false
},
{
"metadata": {},
"cell_type": "code",
"input": "#Makin a mutation after the helix is created also works\n#Create sequence \nseq = 'R'*5 + 'R'+'R'*5; print seq\npose = r.pose_from_sequence(seq, res_type=\"fa_standard\") \nscorefxn = r.get_fa_scorefxn()\n\n#Create perfect alpha helix\n#phi = -57.8, Psi -47.0\nfor i in range(1, pose.total_residue()+1):\n pose.set_phi(i, -57.9)\n pose.set_psi(i, -47.9)\n\n#Make mutation \nmut = r.MutateResidue(6 , 'R1A')\nmut.apply(pose) \n \n#pack side chains\npacker_task = r.standard_packer_task(pose)\npacker_task.restrict_to_repacking() \nprint packer_task\npack_mover = r.PackRotamersMover(scorefxn, packer_task) \npack_mover.apply(pose) \n\n#show the resuls\nprint scorefxn(pose)\npmm.apply(pose)",
"prompt_number": 3,
"outputs": [
{
"output_type": "stream",
"text": "RRRRRRRRRRR\n#Packer_Task\n\nresid\tpack?\tdesign?\tallowed_aas\n1\tTRUE\tFALSE\tARG:NtermProteinFull\n2\tTRUE\tFALSE\tARG\n3\tTRUE\tFALSE\tARG\n4\tTRUE\tFALSE\tARG\n5\tTRUE\tFALSE\tARG\n6\tTRUE\tFALSE\tR1A\n7\tTRUE\tFALSE\tARG\n8\tTRUE\tFALSE\tARG\n9\tTRUE\tFALSE\tARG\n10\tTRUE\tFALSE\tARG\n11\tTRUE\tFALSE\tARG:CtermProteinFull\n",
"stream": "stdout"
},
{
"output_type": "stream",
"text": "\n-1.05767090814",
"stream": "stdout"
},
{
"output_type": "stream",
"text": "\n",
"stream": "stdout"
}
],
"language": "python",
"trusted": true,
"collapsed": false
},
{
"metadata": {},
"cell_type": "code",
"input": "pose.chi(5,6)",
"prompt_number": 4,
"outputs": [
{
"text": "-100.07056096817568",
"output_type": "pyout",
"metadata": {},
"prompt_number": 4
}
],
"language": "python",
"trusted": true,
"collapsed": false
},
{
"metadata": {},
"cell_type": "code",
"input": "[attr for attr in dir(pose.residue(6)) if \"ch\" in attr]",
"prompt_number": 5,
"outputs": [
{
"text": "['atomic_charge',\n 'attached_H_begin',\n 'attached_H_end',\n 'chain',\n 'chi',\n 'chi_atoms',\n 'chi_rotamers',\n 'connections_match',\n 'first_sidechain_atom',\n 'first_sidechain_hydrogen',\n 'is_branch_lower_terminus',\n 'is_charged',\n 'mainchain_atom',\n 'mainchain_atoms',\n 'mainchain_torsion',\n 'mainchain_torsions',\n 'n_mainchain_atoms',\n 'nchi',\n 'set_all_chi',\n 'set_chi',\n 'sidechainAtoms_begin']",
"output_type": "pyout",
"metadata": {},
"prompt_number": 5
}
],
"language": "python",
"trusted": true,
"collapsed": false
},
{
"metadata": {},
"cell_type": "code",
"input": "#First try the obvious chi_rotamers!\npose.residue(6).chi_rotamers(1)",
"prompt_number": 6,
"outputs": [
{
"output_type": "pyerr",
"ename": "TypeError",
"evalue": "No Python class registered for C++ class utility::vector1<std::pair<double, double>, std::allocator<std::pair<double, double> > >",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-6-8a0ba53d69e7>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[1;31m#First try the obvious chi_rotamers!\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0mpose\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mresidue\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m6\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mchi_rotamers\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[1;31mTypeError\u001b[0m: No Python class registered for C++ class utility::vector1<std::pair<double, double>, std::allocator<std::pair<double, double> > >"
]
}
],
"language": "python",
"trusted": true,
"collapsed": false
},
{
"metadata": {},
"cell_type": "code",
"input": "# Try advice from https://www.rosettacommons.org/content/rotamer-libraries-pyrosetta\nimport rosetta.core.pack.dunbrack as dr",
"prompt_number": 7,
"outputs": [],
"language": "python",
"trusted": true,
"collapsed": false
},
{
"metadata": {},
"cell_type": "code",
"input": "dir(dr)\nrot = dr.SingleResidueDunbrackLibrary()\nprint rot",
"prompt_number": 8,
"outputs": [
{
"output_type": "pyerr",
"ename": "RuntimeError",
"evalue": "This class cannot be instantiated from Python",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mRuntimeError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-8-7f65fdefc8df>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[0mdir\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdr\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0mrot\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mdr\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mSingleResidueDunbrackLibrary\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 3\u001b[0m \u001b[1;32mprint\u001b[0m \u001b[0mrot\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;31mRuntimeError\u001b[0m: This class cannot be instantiated from Python"
]
}
],
"language": "python",
"trusted": true,
"collapsed": false
},
{
"metadata": {},
"cell_type": "code",
"input": "#As per the FAQ this should work\n#http://www.pyrosetta.org/faq#TOC-5.-How-do-I-convert-AP-or-CAP-objects-to-regular-class-objects-\nrot = dr.SingleResidueDunbrackLibraryCAP().get()\nprint rot\n#But it just return None",
"prompt_number": 9,
"outputs": [
{
"output_type": "stream",
"text": "None\n",
"stream": "stdout"
}
],
"language": "python",
"trusted": true,
"collapsed": false
},
{
"metadata": {},
"cell_type": "code",
"input": "#Maybe it's in the pack_mover\nb = r.utility.OStringStream()\npack_mover.show(b)\nprint b.str()\npack_mover.rotamer_sets()",
"prompt_number": 10,
"outputs": [
{
"output_type": "stream",
"text": "Mover name: PackRotamersMover, Mover type: PackRotamersMover, Mover current tag:NoTag\nScore function: talaris2013\n\n",
"stream": "stdout"
},
{
"output_type": "pyerr",
"ename": "TypeError",
"evalue": "No to_python (by-value) converter found for C++ type: utility::pointer::owning_ptr<core::pack::rotamer_set::RotamerSets const>",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-10-07a6709b0baa>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 3\u001b[0m \u001b[0mpack_mover\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mshow\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mb\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[1;32mprint\u001b[0m \u001b[0mb\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mstr\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 5\u001b[1;33m \u001b[0mpack_mover\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mrotamer_sets\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[1;31mTypeError\u001b[0m: No to_python (by-value) converter found for C++ type: utility::pointer::owning_ptr<core::pack::rotamer_set::RotamerSets const>"
]
}
],
"language": "python",
"trusted": true,
"collapsed": false
}
],
"metadata": {}
}
],
"metadata": {
"gist_id": "7987aeb1ea70417b6971",
"name": "",
"signature": "sha256:fe859b7a6ad56c70ca9f723a9f2d89f0ac80bc660054d5b3c1ca463a50628706"
},
"nbformat": 3
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment