{ "cells": [ { "cell_type": "markdown", "id": "80c641d2", "metadata": {}, "source": [ "# Dataset Management examples" ] }, { "cell_type": "markdown", "id": "7404daf9", "metadata": {}, "source": [ "This notebook shows the basic functions to interact with your dataset\n", "\n", "\n", "\n", "Login to MorphoNet\n", "\n" ] }, { "cell_type": "code", "execution_count": 1, "id": "167098a0", "metadata": {}, "outputs": [], "source": [ "import morphonet" ] }, { "cell_type": "code", "execution_count": null, "id": "21c2ce03", "metadata": {}, "outputs": [], "source": [ "#try correct connextion\n", "mn_login=\"login\"\n", "mn_password=\"password\"\n", "mn=morphonet.Net(mn_login,mn_password)" ] }, { "cell_type": "markdown", "id": "b0537d99", "metadata": {}, "source": [ "\n", "List the user dataset\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "id": "ec55d7d3", "metadata": {}, "outputs": [], "source": [ "print(\"-------------------------------\")\n", "print(\"List of dataset i can access\")\n", "mn.list_dataset()\n", "input(\"Press Enter to continue...\")\n", "print(\"-------------------------------\")\n", "print(\"List of my dataset\")\n", "mn.list_my_dataset()" ] }, { "cell_type": "markdown", "id": "f86b7544", "metadata": {}, "source": [ "Enter your dataset name than select it\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "id": "01d29528", "metadata": {}, "outputs": [], "source": [ "print(\"-------------------------------\")\n", "print(\"Select a dataset by name\")\n", "d_name = \"\"\n", "while d_name != \"next\":\n", " d_name = input(\"Enter a dataset name to select,next to stop this while \")\n", " if d_name != \"next\":\n", " mn.select_dataset_by_name(d_name)\n" ] }, { "cell_type": "markdown", "id": "952f368d", "metadata": {}, "source": [ "Enter your dataset id than select it\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "id": "10b69166", "metadata": {}, "outputs": [], "source": [ "print(\"-------------------------------\")\n", "print(\"Select a dataset by id for test : 1452\")\n", "d_id = 999\n", "while d_id != -1:\n", " d_id = int(input(\"Enter a dataset id to select,-1 to stop this while \"))\n", " if d_id != -1:\n", " mn.select_dataset_by_id(d_id)\n", "print(\"-------------------------------\")" ] }, { "cell_type": "markdown", "id": "160746b1", "metadata": {}, "source": [ "Once it's selected, you can share with a user by its id, in read mode only\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "id": "4757ff7b", "metadata": {}, "outputs": [], "source": [ "print(\"Share with an existing user (reader)\")\n", "mn.share_dataset_with_user(30,0)\n", "input(\"Press Enter to continue...\")" ] }, { "cell_type": "markdown", "id": "81258ef1", "metadata": {}, "source": [ "Or you can share it in edit mode too\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "id": "39a454c9", "metadata": {}, "outputs": [], "source": [ "print(\"-------------------------------\")\n", "print(\"Share with an existing user (manager)\")\n", "mn.share_dataset_with_user(56,1)\n", "input(\"Press Enter to continue...\")\n", "print(\"-------------------------------\")" ] }, { "cell_type": "markdown", "id": "1725ccfd", "metadata": {}, "source": [ "You can share in the exact same way but using a group this time (group can be created or modified in you user page on MorphoNet\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "id": "df170b6f", "metadata": {}, "outputs": [], "source": [ "print(\"-------------------------------\")\n", "print(\"Share with an existing group (reader)\")\n", "mn.share_dataset_with_group(56,0)\n", "input(\"Press Enter to continue...\")\n", "print(\"-------------------------------\")" ] }, { "cell_type": "markdown", "id": "53d5454b", "metadata": {}, "source": [ "You can add a description for your dataset\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "id": "1e4fd4db", "metadata": {}, "outputs": [], "source": [ "print(\"-------------------------------\")\n", "print(\"Update description for the dataset\")\n", "mn.upload_description(\"New description for api test\")\n", "input(\"Press Enter to continue...\")" ] }, { "cell_type": "markdown", "id": "aa403d17", "metadata": {}, "source": [ "You can update different values for your dataset, in order : name, begin time point, end time point , id id NCBI category (if needed) , type of dataset 0 = observated, 1 = simulated , 2=created\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "id": "25ad8517", "metadata": {}, "outputs": [], "source": [ "print(\"-------------------------------\")\n", "print(\"update tests\")\n", "mn.update_dataset(\"TestModifName\",1,12,522,2)" ] }, { "cell_type": "markdown", "id": "1b504420", "metadata": {}, "source": [ "And you can change the owner of the dataset to someone else , using an id of user. If you wish to know how to retrieve the id , refers to TestUser.py file\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "id": "2c462f7a", "metadata": {}, "outputs": [], "source": [ "owner_id = -1\n", "mn.change_dataset_owner(owner_id)" ] }, { "cell_type": "markdown", "id": "90cf1e2e", "metadata": {}, "source": [ "If you don't need it anymore, you can delete the selected dataset \n", "\n" ] }, { "cell_type": "code", "execution_count": null, "id": "09dd5d9e", "metadata": {}, "outputs": [], "source": [ "mn.delete_dataset()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.7" } }, "nbformat": 4, "nbformat_minor": 5 }