Skip to content

Instantly share code, notes, and snippets.

@ajasja
Created August 26, 2014 18:34
Show Gist options
  • Save ajasja/a77acd8a69c9eeb77bd1 to your computer and use it in GitHub Desktop.
Save ajasja/a77acd8a69c9eeb77bd1 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": [
{
"output_type": "pyout",
"prompt_number": 1,
"metadata": {},
"text": "'56891:56891:6efc58f8abb54611ace5a6cdd7e69e6c970a01ef'"
}
],
"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",
"stream": "stdout",
"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"
},
{
"output_type": "stream",
"stream": "stdout",
"text": "\n-0.259848550164"
},
{
"output_type": "stream",
"stream": "stdout",
"text": "\n"
}
],
"language": "python",
"trusted": true,
"collapsed": false
},
{
"metadata": {},
"cell_type": "code",
"input": "#see the turning\nimport time\nnumrun=100;\nfor i in xrange(numrun):\n pose.set_chi(random.randint(1,5),6,(random.random()-0.5)*180)\n pmm.apply(pose)\n time.sleep(0.3)",
"prompt_number": 5,
"outputs": [],
"language": "python",
"trusted": true,
"collapsed": false
},
{
"metadata": {},
"cell_type": "code",
"input": "#test the scoring\nimport time\nimport random\n\nstart = time.time()\nminscore = +100000000 \nnumrun=10000;\nfor i in xrange(numrun):\n pose.set_chi(random.randint(1,5),6,(random.random()-0.5)*180)\n score = scorefxn(pose)\n if score<minscore:\n minscore=score\n \nend = time.time()\nelapsed = end - start\n\npmm.apply(pose)\nprint \"Time taken: \", elapsed, \"seconds.\"\nprint \"Min Score is: \", minscore\nprint \"Time per run: \", elapsed*1000.0/numrun, \"msec\"",
"prompt_number": 6,
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": "Time taken: 5.41593599319 seconds.\nMin Score is: -0.419016908953\nTime per run: 0.541593599319 msec\n"
}
],
"language": "python",
"trusted": true,
"collapsed": false
},
{
"metadata": {},
"cell_type": "code",
"input": "pose.chi(5,6)",
"prompt_number": 12,
"outputs": [
{
"output_type": "pyout",
"prompt_number": 12,
"metadata": {},
"text": "-66.71631713715759"
}
],
"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": 4,
"outputs": [
{
"output_type": "pyout",
"prompt_number": 4,
"metadata": {},
"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']"
}
],
"language": "python",
"trusted": true,
"collapsed": false
},
{
"metadata": {},
"cell_type": "code",
"input": "pose.residue(6).chi_rotamers(1)",
"prompt_number": 15,
"outputs": [
{
"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-15-158dd2789ef6>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\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> > >"
],
"output_type": "pyerr"
}
],
"language": "python",
"trusted": true,
"collapsed": false
},
{
"metadata": {},
"cell_type": "code",
"input": "b = r.utility.OStringStream()\npose.residue(6).show(b)\nprint b.str()",
"prompt_number": 30,
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": "Residue 6: R1A (R1A, Z):\n Properties: POLYMER PROTEIN\n Main-chain atoms: N CA C \n Backbone atoms: N CA C O H HA \n Side-chain atoms: CB SG SD CE C3 C2 C9 C8 N1 C5 C7 C6 C4 O1 1HB 2HB H14 H13 H7 H8 H9 H10 H11 H12 H4 H5 H6 H1 H2 H3 H15\nAtom Coordinates:\n N : 4.73535, 6.03179, 2.7135\n CA : 4.71557, 7.44807, 3.05925\n C : 4.79753, 7.6482, 4.56707\n O : 5.58926, 8.45552, 5.05367\n CB : 3.35635, 7.90605, 2.52821\n SG : 2.90733, 9.59945, 2.9762\n SD : 4.13694, 10.7721, 1.808\n CE : 5.62379, 11.0055, 2.84069\n C3 : 6.73832, 11.8328, 2.26721\n C2 : 7.01779, 13.264, 2.66155\n C9 : 5.83844, 14.168, 2.31004\n C8 : 7.38488, 13.3621, 4.14028\n N1 : 8.15973, 13.5822, 1.83492\n C5 : 8.59625, 12.4982, 0.988776\n C7 : 8.47293, 12.8858, -0.484088\n C6 : 10.0212, 12.079, 1.34215\n C4 : 7.61056, 11.4088, 1.34274\n O1 : 8.70173, 14.6513, 1.85346\n H : 3.96683, 5.64347, 2.1856\n HA : 5.57892, 7.92885, 2.59827\n1HB : 3.34664, 7.86878, 1.43813\n2HB : 2.5649, 7.26919, 2.92187\n H14: 5.29147, 11.4592, 3.76321\n H13: 5.99949, 9.99875, 3.01778\n H7 : 5.6029, 14.1145, 1.2409\n H8 : 6.06802, 15.215, 2.53664\n H9 : 4.94027, 13.888, 2.87071\n H10: 7.64815, 14.3913, 4.4101\n H11: 8.25198, 12.7359, 4.37559\n H12: 6.55341, 13.0462, 4.78014\n H4 : 7.45531, 13.2151, -0.723631\n H5 : 8.72164, 12.0451, -1.14208\n H6 : 9.14454, 13.7164, -0.725283\n H1 : 10.3373, 11.203, 0.76355\n H2 : 10.1102, 11.8324, 2.40708\n H3 : 10.7275, 12.8914, 1.1412\n H15: 7.61107, 10.4175, 0.905064\n\n"
}
],
"language": "python",
"trusted": true,
"collapsed": false
},
{
"metadata": {},
"cell_type": "code",
"input": "[attr for attr in dir(pose) if \"clO\" in attr]",
"prompt_number": 22,
"outputs": [
{
"output_type": "pyout",
"prompt_number": 22,
"metadata": {},
"text": "[]"
}
],
"language": "python",
"trusted": true,
"collapsed": false
},
{
"metadata": {},
"cell_type": "code",
"input": "b = r.utility.OStringStream()\nprint dir(pose.conformation().fold_tree())\nprint b.str()",
"prompt_number": 35,
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": "['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__instance_size__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'add_edge', 'append_residue', 'append_residue_by_chemical_bond', 'apply_sequence_mapping', 'assign', 'begin', 'boundary_left', 'boundary_right', 'check_edges_for_atom_info', 'check_fold_tree', 'clear', 'clone', 'connected', 'count_fixed_residues', 'cutpoint', 'cutpoint_by_jump', 'cutpoint_map', 'cutpoints', 'delete_edge', 'delete_extra_vertices', 'delete_jump_and_intervening_cutpoint', 'delete_segment', 'delete_self_edges', 'delete_seqpos', 'delete_unordered_edge', 'downstream_atom', 'downstream_jump_residue', 'edge_label', 'empty', 'end', 'get_jump_that_builds_residue', 'get_outgoing_edges', 'get_parent_residue', 'get_polymer_residue_direction', 'get_residue_edge', 'hash_value', 'insert_fold_tree_by_jump', 'insert_polymer_residue', 'insert_residue_by_jump', 'is_cutpoint', 'is_jump_point', 'is_root', 'is_simple_tree', 'jump_edge', 'jump_exists', 'jump_nr', 'jump_point', 'new_chemical_bond', 'new_jump', 'nres', 'num_cutpoint', 'num_jump', 'partition_by_jump', 'partition_by_residue', 'possible_root', 'put_jump_stubs_intra_residue', 'random_tree_from_jump_points', 'reassign_atoms_for_intra_residue_stubs', 'renumber_jumps', 'reorder', 'root', 'set_jump_atoms', 'show', 'simple_tree', 'size', 'slide_cutpoint', 'slide_jump', 'to_string', 'tree_from_jumps_and_cuts', 'update_edge_label', 'upstream_atom', 'upstream_jump_residue']\n\n"
}
],
"language": "python",
"trusted": true,
"collapsed": false
},
{
"metadata": {},
"cell_type": "code",
"input": "[attr for attr in dir(pose) if \"g\" in attr]",
"prompt_number": 38,
"outputs": [
{
"output_type": "pyout",
"prompt_number": 38,
"metadata": {},
"text": "['__getattribute__',\n '__getstate__',\n 'assign',\n 'batch_get_xyz',\n 'clear_stacking_map',\n 'copy_segment',\n 'energies',\n 'gamma',\n 'get',\n 'get_stacking_map',\n 'omega',\n 'record_stacking_interaction',\n 'scoring_begin',\n 'scoring_end',\n 'set_gamma',\n 'set_new_energies_object',\n 'set_omega',\n 'set_ring_conformation',\n 'update_residue_neighbors']"
}
],
"language": "python",
"trusted": true,
"collapsed": false
},
{
"metadata": {},
"cell_type": "code",
"input": "import rosetta.core.pack.dunbrack as dr",
"prompt_number": 39,
"outputs": [],
"language": "python",
"trusted": true,
"collapsed": false
},
{
"metadata": {},
"cell_type": "code",
"input": "dir(dr)\nrot = dr.SingleResidueDunbrackLibrary().get()\nprint rot",
"prompt_number": 52,
"outputs": [
{
"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-52-febdfaa92c70>\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[0mget\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"
],
"output_type": "pyerr"
}
],
"language": "python",
"trusted": true,
"collapsed": false
},
{
"metadata": {},
"cell_type": "code",
"input": "",
"outputs": [],
"language": "python",
"trusted": true,
"collapsed": false
}
],
"metadata": {}
}
],
"metadata": {
"name": "",
"signature": "sha256:6ec5b5c392d7b3f506a2efa2586cea4096f1a4a35589705583cbdd0da786eda7"
},
"nbformat": 3
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment