Skip to content
Snippets Groups Projects
pybis demo.ipynb 139 KiB
Newer Older
  • Learn to ignore specific revisions
  •    "execution_count": null,
       "metadata": {
        "collapsed": true
       },
       "outputs": [],
       "source": [
        "e2 = o.new_experiment()"
       ]
      },
      {
       "cell_type": "code",
       "execution_count": 4,
       "metadata": {
        "collapsed": false
       },
       "outputs": [
        {
         "data": {
          "text/html": [
           "\n",
           "            <table border=\"1\" class=\"dataframe\">\n",
           "            <thead>\n",
           "                <tr style=\"text-align: right;\">\n",
           "                <th>attribute</th>\n",
           "                <th>value</th>\n",
           "                </tr>\n",
           "            </thead>\n",
           "            <tbody>\n",
           "        <tr> <td>code</td> <td>MY_EXPERIMENT04</td> </tr><tr> <td>permId</td> <td>20161006121402181-379</td> </tr><tr> <td>identifier</td> <td>/MATERIALS/YEASTS/MY_EXPERIMENT04</td> </tr><tr> <td>type</td> <td>DEFAULT_EXPERIMENT</td> </tr><tr> <td>space</td> <td></td> </tr><tr> <td>project</td> <td>/MATERIALS/YEASTS</td> </tr><tr> <td>tags</td> <td>['another_nice_tag', 'too_late']</td> </tr><tr> <td>samples</td> <td></td> </tr><tr> <td>datasets</td> <td></td> </tr><tr><td>attachments</td><td></td></tr>\n",
           "            </tbody>\n",
           "            </table>\n",
           "        "
          ],
          "text/plain": [
           "<pybis.pybis.Experiment at 0x7fdbc73485f8>"
    
         "execution_count": 4,
    
         "metadata": {},
         "output_type": "execute_result"
        }
       ],
       "source": [
    
        "e=o.get_experiment('20161006121402181-379')\n",
        "e"
       ]
      },
      {
       "cell_type": "code",
       "execution_count": 119,
       "metadata": {
        "collapsed": false
       },
       "outputs": [],
       "source": [
        "e.add_tags('blblblblblb')"
       ]
      },
      {
       "cell_type": "code",
       "execution_count": 44,
       "metadata": {
        "collapsed": true
       },
       "outputs": [],
       "source": [
        "e3.delete(reason='it was just an experiment')"
    
       ]
      },
      {
       "cell_type": "markdown",
       "metadata": {},
       "source": [
    
        "## working with samples"
    
       "execution_count": 1,
       "metadata": {
        "collapsed": false
       },
       "outputs": [],
       "source": [
        "from pybis import Openbis\n",
        "o = Openbis(url='https://localhost:8443', verify_certificates=False)"
       ]
      },
      {
       "cell_type": "code",
       "execution_count": 2,
    
       "metadata": {
        "collapsed": false
       },
       "outputs": [
        {
         "data": {
          "text/html": [
           "<div>\n",
           "<table border=\"1\" class=\"dataframe\">\n",
           "  <thead>\n",
           "    <tr style=\"text-align: right;\">\n",
           "      <th></th>\n",
           "      <th>identifier</th>\n",
    
           "      <th>permId</th>\n",
           "      <th>experiment</th>\n",
           "      <th>sample_type</th>\n",
    
           "      <th>registrator</th>\n",
           "      <th>registrationDate</th>\n",
           "      <th>modifier</th>\n",
           "      <th>modificationDate</th>\n",
           "    </tr>\n",
           "  </thead>\n",
           "  <tbody>\n",
           "    <tr>\n",
           "      <th>0</th>\n",
    
           "      <td>/VERMEUL/ANOTHER_SAMPLE1</td>\n",
           "      <td>20160706001644827-208</td>\n",
           "      <td>None</td>\n",
           "      <td>UNKNOWN</td>\n",
    
           "      <td>2016-07-06 00:16:45</td>\n",
           "      <td></td>\n",
           "      <td>2016-11-09 10:18:18</td>\n",
           "    </tr>\n",
           "    <tr>\n",
           "      <th>1</th>\n",
           "      <td>/VERMEUL/BLAJLSD</td>\n",
           "      <td>20160630111949369-89</td>\n",
           "      <td>None</td>\n",
           "      <td>UNKNOWN</td>\n",
           "      <td></td>\n",
           "      <td>2016-06-30 17:19:49</td>\n",
           "      <td></td>\n",
           "      <td>2016-06-30 17:19:49</td>\n",
           "    </tr>\n",
           "    <tr>\n",
           "      <th>2</th>\n",
           "      <td>/VERMEUL/CHILD_OF_SAMPLE1</td>\n",
           "      <td>20160705234504004-206</td>\n",
           "      <td>/VERMEUL/VERMEUL_PROJECT/MY_EXPERIMENT4</td>\n",
           "      <td>UNKNOWN</td>\n",
           "      <td></td>\n",
           "      <td>2016-07-05 23:45:04</td>\n",
           "      <td></td>\n",
           "      <td>2016-10-07 01:05:46</td>\n",
           "    </tr>\n",
           "    <tr>\n",
           "      <th>3</th>\n",
           "      <td>/VERMEUL/HOW_WONDERFUL</td>\n",
           "      <td>20160630105304285-81</td>\n",
           "      <td>/VERMEUL/VERMEUL_PROJECT/MY_EXPERIMENT4</td>\n",
           "      <td>UNKNOWN</td>\n",
           "      <td></td>\n",
           "      <td>2016-06-30 16:53:04</td>\n",
           "      <td></td>\n",
           "      <td>2016-11-21 00:53:59</td>\n",
           "    </tr>\n",
           "    <tr>\n",
           "      <th>4</th>\n",
           "      <td>/VERMEUL/MY_WONDERFUL_SAMPLE_NAME</td>\n",
           "      <td>20160720225637704-262</td>\n",
           "      <td>None</td>\n",
           "      <td>UNKNOWN</td>\n",
           "      <td></td>\n",
           "      <td>2016-07-20 22:56:38</td>\n",
           "      <td></td>\n",
           "      <td>2016-07-20 22:56:38</td>\n",
           "    </tr>\n",
           "    <tr>\n",
           "      <th>5</th>\n",
           "      <td>/VERMEUL/OH_WIE_SCHOEN_IST_PANAMA</td>\n",
           "      <td>20160630110733527-86</td>\n",
           "      <td>None</td>\n",
           "      <td>UNKNOWN</td>\n",
           "      <td></td>\n",
           "      <td>2016-06-30 17:07:34</td>\n",
           "      <td></td>\n",
           "      <td>2016-07-06 00:11:45</td>\n",
           "    </tr>\n",
           "    <tr>\n",
           "      <th>6</th>\n",
           "      <td>/VERMEUL/OH_WIE_SCHOEN_IST_PANAMA3</td>\n",
           "      <td>20160630112720553-90</td>\n",
           "      <td>None</td>\n",
           "      <td>UNKNOWN</td>\n",
           "      <td></td>\n",
           "      <td>2016-06-30 17:27:21</td>\n",
           "      <td></td>\n",
           "      <td>2016-06-30 17:27:21</td>\n",
           "    </tr>\n",
           "    <tr>\n",
           "      <th>7</th>\n",
           "      <td>/VERMEUL/OH_WIE_SCHOEN_IST_PANAMA5</td>\n",
           "      <td>20160706231053756-211</td>\n",
           "      <td>None</td>\n",
           "      <td>UNKNOWN</td>\n",
           "      <td></td>\n",
           "      <td>2016-07-06 23:10:54</td>\n",
           "      <td></td>\n",
           "      <td>2016-07-06 23:10:54</td>\n",
           "    </tr>\n",
           "    <tr>\n",
           "      <th>8</th>\n",
           "      <td>/VERMEUL/YEA21</td>\n",
           "      <td>20161025010638912-382</td>\n",
           "      <td>/VERMEUL/VERMEUL_PROJECT/MY_SPECIAL_EXPERIMENT</td>\n",
           "      <td>YEAST</td>\n",
           "      <td></td>\n",
           "      <td>2016-10-25 01:06:39</td>\n",
           "      <td></td>\n",
           "      <td>2016-12-01 22:44:21</td>\n",
           "    </tr>\n",
           "    <tr>\n",
           "      <th>9</th>\n",
           "      <td>/VERMEUL/YET_ANOTHER_SAMPLE1</td>\n",
           "      <td>20160706002555747-209</td>\n",
           "      <td>None</td>\n",
           "      <td>UNKNOWN</td>\n",
    
           "      <td>2016-07-06 00:25:56</td>\n",
           "      <td></td>\n",
           "      <td>2016-11-09 10:18:18</td>\n",
    
           "    </tr>\n",
           "  </tbody>\n",
           "</table>\n",
           "</div>"
          ],
          "text/plain": [
    
           "<pybis.pybis.Things at 0x7efe60bb8978>"
    
         "execution_count": 2,
    
         "metadata": {},
         "output_type": "execute_result"
        }
       ],
       "source": [
    
        "o.get_samples(space='VERMEUL', tags=['*'])"
    
       ]
      },
      {
       "cell_type": "markdown",
       "metadata": {},
       "source": [
    
        "get the first sample of the above list and just display the basic attributes"
    
       "execution_count": 10,
    
        "collapsed": false
    
       },
       "outputs": [
        {
         "data": {
          "text/html": [
           "\n",
    
           "            <table border=\"1\" class=\"dataframe\">\n",
           "            <thead>\n",
           "                <tr style=\"text-align: right;\">\n",
           "                <th>attribute</th>\n",
           "                <th>value</th>\n",
           "                </tr>\n",
           "            </thead>\n",
           "            <tbody>\n",
           "        <tr> <td>code</td> <td>YEA21</td> </tr><tr> <td>permId</td> <td>20161025010638912-382</td> </tr><tr> <td>identifier</td> <td>/VERMEUL/YEA21</td> </tr><tr> <td>type</td> <td>YEAST</td> </tr><tr> <td>container</td> <td></td> </tr><tr> <td>components</td> <td></td> </tr><tr> <td>space</td> <td>VERMEUL</td> </tr><tr> <td>project</td> <td></td> </tr><tr> <td>experiment</td> <td>/VERMEUL/VERMEUL_PROJECT/MY_SPECIAL_EXPERIMENT</td> </tr><tr> <td>parents</td> <td>[]</td> </tr><tr> <td>children</td> <td>[]</td> </tr><tr> <td>container</td> <td></td> </tr><tr> <td>components</td> <td></td> </tr><tr> <td>tags</td> <td>['do', 'fa', 're']</td> </tr><tr><td>attachments</td><td></td></tr>\n",
           "            </tbody>\n",
           "            </table>\n",
    
           "<pybis.pybis.Sample at 0x7ff35e95d198>"
    
         "execution_count": 10,
    
         "metadata": {},
         "output_type": "execute_result"
        }
       ],
       "source": [
    
        "s = o.get_sample('/VERMEUL/YEA21')\n",
        "s"
    
       "execution_count": 4,
    
       "metadata": {
        "collapsed": false
       },
       "outputs": [
        {
         "data": {
          "text/html": [
           "\n",
           "<table border=\"1\" class=\"dataframe\">\n",
           "  <thead>\n",
           "    <tr style=\"text-align: right;\">\n",
           "      <th>attribute</th>\n",
           "      <th>value</th>\n",
           "    </tr>\n",
           "  </thead>\n",
           "  <tbody>\n",
    
           "    <tr> <th>permId</th> <td>20161121013609807-402</td> </tr>\n",
           "    <tr> <th>identifier</th> <td>/VERMEUL/VERMEUL_PROJECT/MY_SPECIAL_EXPERIMENT</td> </tr>\n",
           "    <tr> <th>project</th> <td>VERMEUL_PROJECT</td> </tr>\n",
           "    <tr> <th>properties</th> <td>{}</td> </tr>\n",
           "    <tr> <th>tags</th> <td>[]</td> </tr>\n",
    
           "    <tr> <th>attachments</th> <td>[]</td> </tr>\n",
           "  </tbody>\n",
           "</table>\n",
           "        "
          ],
          "text/plain": [
    
           "{'properties': {}, 'tags': [], 'permId': '20161121013609807-402', 'identifier': '/VERMEUL/VERMEUL_PROJECT/MY_SPECIAL_EXPERIMENT'}"
    
         "execution_count": 4,
    
         "metadata": {},
         "output_type": "execute_result"
        }
       ],
       "source": [
    
        "ex = s.get_experiment()\n",
        "ex"
    
       "execution_count": 5,
    
       "metadata": {
        "collapsed": false
       },
       "outputs": [],
       "source": [
    
        "s.a.tags = ['fa', 'do','re']"
    
       "execution_count": 88,
    
        "collapsed": false
    
       "outputs": [
        {
         "name": "stdout",
         "output_type": "stream",
         "text": [
          "Sample successfully updated\n"
         ]
        }
       ],
    
        "s.save()"
    
       "cell_type": "code",
       "execution_count": 6,
       "metadata": {
        "collapsed": true
       },
       "outputs": [],
    
        "s = o.get_sample('/VERMEUL/YEA21')"
    
       "execution_count": 7,
    
       "metadata": {
        "collapsed": false
       },
       "outputs": [],
       "source": [
    
        "s.p.mating_type = 'A'"
    
       "execution_count": 12,
    
       "metadata": {
        "collapsed": false
       },
       "outputs": [
        {
         "data": {
          "text/html": [
    
           "\n",
           "<p>SampleType: <b>YEAST</b>\n",
           "<p>description: </p>\n",
           "<p>Code autogenerated: True</p>\n",
    
           "<table border=\"1\" class=\"dataframe\">\n",
           "  <thead>\n",
           "    <tr style=\"text-align: right;\">\n",
    
           "      <th>property</th>\n",
           "      <th>label</th>\n",
           "      <th>description</th>\n",
           "      <th>dataType</th>\n",
           "      <th>mandatory</th>\n",
    
           "    </tr>\n",
           "  </thead>\n",
           "  <tbody>\n",
    
           "        <tr> <th>name</th> <td>Name</td> <td>Name</td> <td>VARCHAR</td> <td>False</td> </tr><tr> <th>show_in_project_overview</th> <td>Show in project overview</td> <td>Show in project overview</td> <td>BOOLEAN</td> <td>False</td> </tr><tr> <th>owner</th> <td>Owner</td> <td>Who produced/owned the sample</td> <td>CONTROLLEDVOCABULARY</td> <td>False</td> </tr><tr> <th>owner_number</th> <td>Owner number</td> <td>Owner number</td> <td>MULTILINE_VARCHAR</td> <td>False</td> </tr><tr> <th>genetic_modification</th> <td>Genetic modifications</td> <td>Genetic modifications composed by the Plasmid ancestors</td> <td>MULTILINE_VARCHAR</td> <td>False</td> </tr><tr> <th>genetic_background</th> <td>Genetic Background</td> <td>Genetic background of the yeast strain</td> <td>CONTROLLEDVOCABULARY</td> <td>False</td> </tr><tr> <th>mating_type</th> <td>Mating Type</td> <td>Mating type or ploidy of the yeast strain</td> <td>CONTROLLEDVOCABULARY</td> <td>False</td> </tr><tr> <th>background-specific_markers</th> <td>Background-specific markers</td> <td>Background-specific markers available in the strain for further genetic modifications</td> <td>CONTROLLEDVOCABULARY</td> <td>False</td> </tr><tr> <th>common_markers</th> <td>Common markers</td> <td>Common markers available in the strain for further genetic modifications</td> <td>CONTROLLEDVOCABULARY</td> <td>False</td> </tr><tr> <th>endogenous_plasmid</th> <td>Endogenous 2micron plasmid in yeast</td> <td>Presence of an endogenous cir 2micron plasmid</td> <td>CONTROLLEDVOCABULARY</td> <td>False</td> </tr><tr> <th>origin</th> <td>Origin</td> <td>How the strain/cell line was produced</td> <td>CONTROLLEDVOCABULARY</td> <td>False</td> </tr><tr> <th>strain_check</th> <td>Strain Check</td> <td>Check done to verify the modifications introduced in the strain</td> <td>CONTROLLEDVOCABULARY</td> <td>False</td> </tr><tr> <th>source</th> <td>Source</td> <td>Source from where the construct/strain/cell line obtained or purchased, if it was not produced in the lab</td> <td>VARCHAR</td> <td>False</td> </tr><tr> <th>publication</th> <td>Publication</td> <td>Publication from where the information was first found OR technical sheet given by the manufacturer</td> <td>MULTILINE_VARCHAR</td> <td>False</td> </tr><tr> <th>notes</th> <td>Notes</td> <td>Notes regarding the dataset</td> <td>MULTILINE_VARCHAR</td> <td>False</td> </tr><tr> <th>xmlcomments</th> <td>Comments List</td> <td>Several comments can be added by different users</td> <td>XML</td> <td>False</td> </tr><tr> <th>annotations_state</th> <td>Annotations State</td> <td>Annotations State</td> <td>XML</td> <td>False</td> </tr><tr> <th>storage_names</th> <td>Storage Name</td> <td>Storage Name</td> <td>CONTROLLEDVOCABULARY</td> <td>False</td> </tr><tr> <th>storage_row</th> <td>Storage Row</td> <td>Storage Row</td> <td>INTEGER</td> <td>False</td> </tr><tr> <th>storage_column</th> <td>Storage Column</td> <td>Storage Column</td> <td>INTEGER</td> <td>False</td> </tr><tr> <th>storage_box_name</th> <td>Storage Box Name</td> <td>Storage Box Name</td> <td>VARCHAR</td> <td>False</td> </tr><tr> <th>storage_box_size</th> <td>Storage Box Size</td> <td>Storage Box Size</td> <td>CONTROLLEDVOCABULARY</td> <td>False</td> </tr><tr> <th>storage_user</th> <td>Storage User Id</td> <td>Storage User Id</td> <td>VARCHAR</td> <td>False</td> </tr><tr> <th>storage_position</th> <td>Storage Position</td> <td>Storage Position</td> <td>VARCHAR</td> <td>False</td> </tr>\n",
           "            </tbody>\n",
           "            </table>\n",
           "        "
    
           "<pybis.pybis.PropertyAssignments at 0x7efe6097a198>"
    
         "execution_count": 12,
         "metadata": {},
         "output_type": "execute_result"
        }
       ],
       "source": [
        "s.get_type()"
       ]
      },
      {
       "cell_type": "code",
       "execution_count": 33,
       "metadata": {
        "collapsed": false
       },
       "outputs": [
        {
         "data": {
          "text/plain": [
           "[]"
          ]
         },
         "execution_count": 33,
    
         "metadata": {},
         "output_type": "execute_result"
        }
       ],
       "source": [
    
        "s.identifier\n",
        "s.code\n",
        "s.type\n",
        "s.space\n",
        "s.tags"
    
       ]
      },
      {
       "cell_type": "markdown",
       "metadata": {},
       "source": [
    
        "list all the properties (p) of a given sample"
    
       "execution_count": 13,
    
       "metadata": {
        "collapsed": false
       },
       "outputs": [
        {
         "data": {
          "text/html": [
           "\n",
           "            <table border=\"1\" class=\"dataframe\">\n",
           "            <thead>\n",
           "                <tr style=\"text-align: right;\">\n",
    
           "                <th>vocabulary term</th>\n",
           "                <th>label</th>\n",
           "                <th>description</th>\n",
           "                <th>vocabulary</th>\n",
    
           "                </tr>\n",
           "            </thead>\n",
           "            <tbody>\n",
    
           "        <tr> <td>URA3_HIS3_LEU2</td> <td>ura3- his3- leu2-</td> <td>The strain is a uracil, histidine, and leucine auxotroph</td> <td>COMMON_MARKERS</td> </tr><tr> <td>URA3_HIS3</td> <td>ura3- his3-</td> <td>The strain is a uracil and histidine auxotroph</td> <td>COMMON_MARKERS</td> </tr><tr> <td>URA3_LEU2</td> <td>ura3- leu2-</td> <td>The strain is a uracil and leucine auxotroph</td> <td>COMMON_MARKERS</td> </tr><tr> <td>URA3</td> <td>ura3-</td> <td>The strain is a uracil auxotroph</td> <td>COMMON_MARKERS</td> </tr><tr> <td>HIS3_LEU2</td> <td>his3- leu2-</td> <td>The strain is a histidine and leucine auxotroph</td> <td>COMMON_MARKERS</td> </tr><tr> <td>HIS3</td> <td>his3-</td> <td>The strain is a histidine auxotroph</td> <td>COMMON_MARKERS</td> </tr><tr> <td>LEU2</td> <td>leu2-</td> <td>The strain is a leucine auxotroph</td> <td>COMMON_MARKERS</td> </tr><tr> <td>NONE</td> <td>none</td> <td>The strain does not have any background-specific auxotrophies</td> <td>COMMON_MARKERS</td> </tr><tr> <td>UNKNOWN</td> <td>unknown</td> <td>No information about the auxotrophy</td> <td>COMMON_MARKERS</td> </tr>\n",
    
           "            </tbody>\n",
           "            </table>\n",
           "        "
          ],
          "text/plain": [
    
           "<pybis.pybis.Vocabulary at 0x7efe6097feb8>"
    
         "execution_count": 13,
    
         "metadata": {},
         "output_type": "execute_result"
        }
       ],
       "source": [
    
        "s.p.common_markers_"
       ]
      },
      {
       "cell_type": "markdown",
       "metadata": {
        "collapsed": false
       },
       "source": [
        "fetch just a single property: sample.p.«property_name»"
    
       "execution_count": 14,
       "metadata": {
        "collapsed": false
       },
       "outputs": [
        {
         "data": {
          "text/plain": [
           "'comments: publication in my office'"
          ]
         },
         "execution_count": 14,
         "metadata": {},
         "output_type": "execute_result"
        }
       ],
       "source": [
        "s.p.publication"
       ]
      },
      {
       "cell_type": "markdown",
       "metadata": {},
       "source": [
        "if you don't know the controlled vocabulary of a property, just add an underscore and press shift-enter:"
       ]
      },
      {
       "cell_type": "code",
       "execution_count": 15,
    
       "metadata": {
        "collapsed": false
       },
       "outputs": [
        {
         "data": {
          "text/html": [
           "\n",
           "            <table border=\"1\" class=\"dataframe\">\n",
           "            <thead>\n",
           "                <tr style=\"text-align: right;\">\n",
    
           "                <th>vocabulary term</th>\n",
           "                <th>label</th>\n",
           "                <th>description</th>\n",
           "                <th>vocabulary</th>\n",
    
           "                </tr>\n",
           "            </thead>\n",
           "            <tbody>\n",
    
           "        <tr> <td>A</td> <td>a</td> <td>None</td> <td>MATING_TYPE</td> </tr><tr> <td>ALPHA</td> <td>alpha</td> <td>None</td> <td>MATING_TYPE</td> </tr><tr> <td>DIPLOID</td> <td>diploid</td> <td>None</td> <td>MATING_TYPE</td> </tr><tr> <td>UNKNOWN</td> <td>unknown</td> <td>None</td> <td>MATING_TYPE</td> </tr>\n",
    
           "            </tbody>\n",
           "            </table>\n",
           "        "
          ],
          "text/plain": [
    
           "<pybis.pybis.Vocabulary at 0x7efe6097d828>"
    
         "execution_count": 15,
    
         "metadata": {},
         "output_type": "execute_result"
        }
       ],
       "source": [
    
        "s.p.mating_type_"
    
       "cell_type": "markdown",
       "metadata": {},
    
        "pybis will automatically check the controlled vocabulary when you assign a value to it:"
    
       "execution_count": 24,
    
       "metadata": {
        "collapsed": false
       },
       "outputs": [
        {
    
         "ename": "ValueError",
         "evalue": "Value must be one of these terms: A, ALPHA, DIPLOID, UNKNOWN",
         "output_type": "error",
         "traceback": [
          "\u001b[1;31m\u001b[0m",
          "\u001b[1;31mValueError\u001b[0mTraceback (most recent call last)",
          "\u001b[1;32m<ipython-input-24-d4d5f6a664c5>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0ms\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmating_type\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;34m'invalid content'\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
          "\u001b[1;32m/vagrant_python/PyBis/pybis/pybis.py\u001b[0m in \u001b[0;36m__setattr__\u001b[1;34m(self, name, value)\u001b[0m\n\u001b[0;32m   2122\u001b[0m             \u001b[0mvoc\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_openbis\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_terms\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mname\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   2123\u001b[0m             \u001b[1;32mif\u001b[0m \u001b[0mvalue\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mvoc\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mterms\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 2124\u001b[1;33m                 \u001b[1;32mraise\u001b[0m \u001b[0mValueError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Value must be one of these terms: \"\u001b[0m \u001b[1;33m+\u001b[0m \u001b[1;34m\", \"\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mjoin\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mvoc\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mterms\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   2125\u001b[0m         \u001b[1;32melif\u001b[0m \u001b[0mdata_type\u001b[0m \u001b[1;32min\u001b[0m \u001b[1;33m(\u001b[0m\u001b[1;34m'INTEGER'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'BOOLEAN'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'VARCHAR'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   2126\u001b[0m             \u001b[1;32mif\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0mcheck_datatype\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdata_type\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mvalue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
          "\u001b[1;31mValueError\u001b[0m: Value must be one of these terms: A, ALPHA, DIPLOID, UNKNOWN"
    
        "s.p.mating_type = 'invalid content'"
       ]
      },
      {
       "cell_type": "markdown",
       "metadata": {},
       "source": [
        "some properties are of a general type. Again, you can list it by adding an underscore _ :"
    
       "execution_count": 16,
    
       "metadata": {
        "collapsed": false
       },
       "outputs": [
        {
         "data": {
          "text/plain": [
    
           "{'Storage Column': 'INTEGER'}"
    
         "execution_count": 16,
    
         "metadata": {},
         "output_type": "execute_result"
        }
       ],
       "source": [
    
        "s.p.storage_column_"
    
       "metadata": {
        "collapsed": true
       },
    
        "### alter a sample and its properties"
    
       "execution_count": 1,
       "metadata": {
        "collapsed": false
       },
       "outputs": [],
       "source": [
        "from pybis import Openbis\n",
        "o = Openbis(url='https://localhost:8443', verify_certificates=False)"
       ]
      },
      {
       "cell_type": "code",
       "execution_count": 2,
    
       "metadata": {
        "collapsed": false
       },
       "outputs": [
        {
         "data": {
          "text/html": [
           "\n",
           "            <table border=\"1\" class=\"dataframe\">\n",
           "            <thead>\n",
           "                <tr style=\"text-align: right;\">\n",
    
           "                <th>attribute</th>\n",
    
           "                <th>value</th>\n",
           "                </tr>\n",
           "            </thead>\n",
           "            <tbody>\n",
    
           "        <tr> <td>code</td> <td>FLY45</td> </tr><tr> <td>permId</td> <td>20170104000847172-405</td> </tr><tr> <td>identifier</td> <td>/MATERIALS/FLY45</td> </tr><tr> <td>type</td> <td>FLY</td> </tr><tr> <td>parents</td> <td>['/MATERIALS/FLY43']</td> </tr><tr> <td>children</td> <td>[]</td> </tr><tr> <td>space</td> <td>MATERIALS</td> </tr><tr> <td>project</td> <td></td> </tr><tr> <td>experiment</td> <td>/MATERIALS/YEASTS/MY_EXPERIMENT007</td> </tr><tr> <td>container</td> <td></td> </tr><tr> <td>components</td> <td></td> </tr><tr> <td>tags</td> <td>[]</td> </tr><tr><td>attachments</td><td>openBIS JSON-RPC.md</td></tr>\n",
    
           "            </tbody>\n",
           "            </table>\n",
           "        "
          ],
          "text/plain": [
    
           "<pybis.pybis.Sample at 0x7fd4d7f4b7b8>"
    
         "execution_count": 2,
    
         "metadata": {},
         "output_type": "execute_result"
        }
       ],
       "source": [
    
        "sample = o.get_sample('/MATERIALS/FLY45')\n",
        "sample"
    
       "cell_type": "code",
       "execution_count": 3,
    
       "metadata": {
        "collapsed": false
       },
    
       "outputs": [
        {
         "data": {
          "text/html": [
           "\n",
           "            <table border=\"1\" class=\"dataframe\">\n",
           "            <thead>\n",
           "                <tr style=\"text-align: right;\">\n",
           "                <th>property</th>\n",
           "                <th>value</th>\n",
           "                </tr>\n",
           "            </thead>\n",
           "            <tbody>\n",
           "        <tr> <td>name</td> <td>a fly45 which is the child of fly43</td> </tr><tr> <td>show_in_project_overview</td> <td>False</td> </tr><tr> <td>owner</td> <td></td> </tr><tr> <td>owner_number</td> <td></td> </tr><tr> <td>genetic_modification</td> <td></td> </tr><tr> <td>fly_genotype</td> <td></td> </tr><tr> <td>associated_gene</td> <td></td> </tr><tr> <td>markers</td> <td></td> </tr><tr> <td>origin</td> <td></td> </tr><tr> <td>strain_check</td> <td></td> </tr><tr> <td>source</td> <td></td> </tr><tr> <td>mating_partners</td> <td></td> </tr><tr> <td>publication</td> <td></td> </tr><tr> <td>notes</td> <td></td> </tr><tr> <td>xmlcomments</td> <td><root>\n",
           "  <commentEntry date=\"1483484927350\" person=\"vermeul\"/>\n",
           "</root>\n",
           "</td> </tr><tr> <td>annotations_state</td> <td>�(undefined)</td> </tr><tr> <td>storage_names</td> <td></td> </tr><tr> <td>storage_row</td> <td></td> </tr><tr> <td>storage_column</td> <td></td> </tr><tr> <td>storage_box_name</td> <td></td> </tr><tr> <td>storage_box_size</td> <td></td> </tr><tr> <td>storage_user</td> <td></td> </tr><tr> <td>storage_position</td> <td></td> </tr>\n",
           "            </tbody>\n",
           "            </table>\n",
           "        "
          ],
          "text/plain": [
           "<pybis.pybis.PropertyHolder at 0x7fd4d7f4bf98>"
          ]
         },
         "execution_count": 3,
         "metadata": {},
         "output_type": "execute_result"
        }
       ],
    
        "sample.props"
    
       "execution_count": 4,
    
       "metadata": {
        "collapsed": false
       },
       "outputs": [
        {
         "data": {
    
          "text/html": [
           "<div>\n",
           "<table border=\"1\" class=\"dataframe\">\n",
           "  <thead>\n",
           "    <tr style=\"text-align: right;\">\n",
           "      <th></th>\n",
           "      <th>identifier</th>\n",
           "      <th>permId</th>\n",
           "      <th>experiment</th>\n",
           "      <th>sample_type</th>\n",
           "      <th>registrator</th>\n",
           "      <th>registrationDate</th>\n",
           "      <th>modifier</th>\n",
           "      <th>modificationDate</th>\n",
           "    </tr>\n",
           "  </thead>\n",
           "  <tbody>\n",
           "    <tr>\n",
           "      <th>0</th>\n",
           "      <td>/MATERIALS/FLY43</td>\n",
           "      <td>20170104000802333-404</td>\n",
           "      <td>/MATERIALS/YEASTS/MY_EXPERIMENT007</td>\n",
           "      <td>FLY</td>\n",
           "      <td></td>\n",
           "      <td>2017-01-04 00:08:02</td>\n",
           "      <td></td>\n",
           "      <td>2017-01-04 00:08:47</td>\n",
           "    </tr>\n",
           "  </tbody>\n",
           "</table>\n",
           "</div>"
          ],
    
           "<pybis.pybis.Things at 0x7fd4d7f66358>"
    
         "execution_count": 4,
    
         "metadata": {},
         "output_type": "execute_result"
        }
       ],
       "source": [
    
        "sample.get_parents()"
    
       "execution_count": 5,
    
       "metadata": {
        "collapsed": false
       },
       "outputs": [
        {
         "data": {
          "text/html": [
           "\n",
           "            <table border=\"1\" class=\"dataframe\">\n",
           "            <thead>\n",
           "                <tr style=\"text-align: right;\">\n",
    
           "                <th>attribute</th>\n",
           "                <th>value</th>\n",
    
           "                </tr>\n",
           "            </thead>\n",
           "            <tbody>\n",
    
           "        <tr> <td>code</td> <td>FLY45</td> </tr><tr> <td>permId</td> <td>20170104000847172-405</td> </tr><tr> <td>identifier</td> <td>/MATERIALS/FLY45</td> </tr><tr> <td>type</td> <td>FLY</td> </tr><tr> <td>parents</td> <td>['/MATERIALS/FLY43']</td> </tr><tr> <td>children</td> <td>[]</td> </tr><tr> <td>space</td> <td>MATERIALS</td> </tr><tr> <td>project</td> <td></td> </tr><tr> <td>experiment</td> <td>/MATERIALS/YEASTS/MY_EXPERIMENT007</td> </tr><tr> <td>container</td> <td></td> </tr><tr> <td>components</td> <td></td> </tr><tr> <td>tags</td> <td>[]</td> </tr><tr><td>attachments</td><td>openBIS JSON-RPC.md</td></tr>\n",
    
           "            </tbody>\n",
           "            </table>\n",
           "        "
          ],
          "text/plain": [
    
           "<pybis.pybis.Sample at 0x7fd4d7f4b7b8>"
    
         "execution_count": 5,
    
         "metadata": {},
         "output_type": "execute_result"
        }
       ],
       "source": [
    
        "sample"
    
       "execution_count": 6,
    
       "metadata": {
        "collapsed": false
       },
       "outputs": [
        {
         "data": {
    
          "text/html": [
           "<div>\n",
           "<table border=\"1\" class=\"dataframe\">\n",
           "  <thead>\n",
           "    <tr style=\"text-align: right;\">\n",
           "      <th></th>\n",
           "      <th>code</th>\n",
           "      <th>properties</th>\n",
           "      <th>type</th>\n",
           "      <th>sample</th>\n",
           "      <th>registrationDate</th>\n",
           "      <th>modificationDate</th>\n",
           "    </tr>\n",
           "  </thead>\n",
           "  <tbody>\n",
           "    <tr>\n",
           "      <th>0</th>\n",
           "      <td>20170104003608559-406</td>\n",
           "      <td>{'NAME': 'some analyzed data'}</td>\n",
           "      <td>ANALYZED_DATA</td>\n",
           "      <td>/MATERIALS/FLY45</td>\n",
           "      <td>2017-01-04 00:36:09</td>\n",
           "      <td>2017-01-04 00:36:09</td>\n",
           "    </tr>\n",
           "  </tbody>\n",
           "</table>\n",
           "</div>"
          ],
    
           "<pybis.pybis.Things at 0x7fd4d7d04dd8>"
    
         "execution_count": 6,
    
         "metadata": {},
         "output_type": "execute_result"
        }
       ],
       "source": [
    
        "sample.get_datasets()"
    
       "cell_type": "code",
       "execution_count": 29,
    
        "collapsed": false
    
       "outputs": [
        {
         "name": "stdout",
         "output_type": "stream",
         "text": [
          "Files downloaded to: localhost/20170104003608559-406\n"
         ]
        }
       ],
    
        "sample.get_datasets()[0].download()"
    
       "execution_count": 26,
    
       "metadata": {
        "collapsed": false
       },
    
       "outputs": [
        {
         "name": "stdout",
         "output_type": "stream",
         "text": [
          "jupyter_useage_lab.zip\r\n"
         ]
        }
       ],
    
        "ls localhost/20170104003608559-406/original"
    
       "execution_count": 19,
    
        "collapsed": true
    
       "outputs": [],
    
        "s_up = o.get_sample('/VERMEUL/MY_WONDERFUL_SAMPLE_NAME')"
    
       "execution_count": 20,
    
       "metadata": {
        "collapsed": true
       },
       "outputs": [],
       "source": [
        "s_up.space = 'ANOTHER_SPACE_NAME'"
       ]
      },
      {
       "cell_type": "code",
    
       "execution_count": 21,
    
       "metadata": {
        "collapsed": true
       },
       "outputs": [],
       "source": [
        "s_up.tags = ['one', 'two', 'three']"
       ]
      },
      {
       "cell_type": "code",
    
       "execution_count": 22,
    
       "metadata": {
        "collapsed": false
       },
       "outputs": [
        {
         "data": {
          "text/html": [
           "\n",
           "            <table border=\"1\" class=\"dataframe\">\n",
           "            <thead>\n",
           "                <tr style=\"text-align: right;\">\n",
           "                <th>attribute</th>\n",
           "                <th>value</th>\n",
           "                </tr>\n",
           "            </thead>\n",
           "            <tbody>\n",
    
           "        <tr> <td>identifier</td> <td>/VERMEUL/MY_WONDERFUL_SAMPLE_NAME</td> </tr><tr> <td>permId</td> <td>20160720225637704-262</td> </tr><tr> <td>code</td> <td>MY_WONDERFUL_SAMPLE_NAME</td> </tr><tr> <td>type</td> <td>UNKNOWN</td> </tr><tr> <td>space</td> <td>ANOTHER_SPACE_NAME</td> </tr><tr> <td>project</td> <td>None</td> </tr><tr> <td>experiment</td> <td></td> </tr><tr> <td>parents</td> <td>[]</td> </tr><tr> <td>children</td> <td>[]</td> </tr><tr> <td>tags</td> <td>['one', 'two', 'three']</td> </tr>\n",
    
           "            </tbody>\n",
           "            </table>\n",
           "        "
          ],
          "text/plain": [
    
           "<pybis.pybis.Sample at 0x7efe60915668>"
    
         "execution_count": 22,
    
         "metadata": {},
         "output_type": "execute_result"
        }
       ],
       "source": [
        "s_up"
       ]
      },
      {
       "cell_type": "code",
    
       "execution_count": 23,
    
       "metadata": {
        "collapsed": false
       },
       "outputs": [
        {
         "name": "stdout",
         "output_type": "stream",
         "text": [
          "Sample successfully updated\n"
         ]
        }
       ],
       "source": [
        "s_up.save()"
       ]
      },