diff --git a/docs/examples/alignment.ipynb b/docs/examples/alignment.ipynb new file mode 100644 index 00000000..c8f10c3f --- /dev/null +++ b/docs/examples/alignment.ipynb @@ -0,0 +1,160 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Align sequences" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "8b73afa8e8b444578f622d239c439673", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Output()" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
\n"
+      ],
+      "text/plain": []
+     },
+     "metadata": {},
+     "output_type": "display_data"
+    },
+    {
+     "data": {
+      "text/html": [
+       "
\n",
+       "
\n" + ], + "text/plain": [ + "\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "import json\n", + "from pyeed.core import ProteinRecord\n", + "\n", + "\n", + "# load accession ids from json file\n", + "with open(\"ids.json\", \"r\") as f:\n", + " ids = json.load(f)\n", + "\n", + "sequences = ProteinRecord.get_ids(ids)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Multi Sequence Alignment\n", + "\n", + "A multi sequence alignment can be calculated by creating a `MSA` object and passing a list of `ProteinRecord`. The alignment can be executed by calling the `clustalo` method. In order for the `clustalo` method to work, the PyEED Docker Service must be running. The `clustalo` method will return an `AlignmentResult` containing all input `sequences` and `aligned_sequences`." + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "99f840a5cc0a4441a7d936127815ab36", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Output()" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
\n"
+      ],
+      "text/plain": []
+     },
+     "metadata": {},
+     "output_type": "display_data"
+    },
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "✅ Alignment completed\n"
+     ]
+    }
+   ],
+   "source": [
+    "from pyeed.align import MSA\n",
+    "\n",
+    "alignment = MSA(sequences=sequences).clustalo()"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "## Create a HMM profile\n",
+    "\n",
+    "To create a hidden markov model profile, you can use the `HMM` class. This method receives a `MSA` object to create the model. To check if a sequence belongs to the profile, you can use the `search` method. This method takes a `ProteinRecord` object and returns a `HMMResult` object containing the `sequence` and the `score` of the sequence in the profile."
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 6,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "from pyeed.align import HMM\n",
+    "\n",
+    "model = HMM(name=\"random profile\", alignment=alignment)\n",
+    "hits = model.search(sequence=sequences[0])"
+   ]
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "pye",
+   "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.11.5"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
diff --git a/docs/examples/basics.ipynb b/docs/examples/basics.ipynb
new file mode 100644
index 00000000..64e925fb
--- /dev/null
+++ b/docs/examples/basics.ipynb
@@ -0,0 +1,153 @@
+{
+    "cells": [
+        {
+            "cell_type": "markdown",
+            "metadata": {},
+            "source": [
+                "# Get rich sequence information\n",
+                "\n",
+                "## Acquire sequence information based on accession id(s)\n",
+                "\n",
+                "**Single accession ID**\n",
+                "\n",
+                "Single sequences can be retrieved using the `get_id` function. The function takes an accession id as input and returns the sequence as a `ProteinRecord` object.  \n",
+                "The `ProteinRecord` object contains the sequence as a string and additional information such as information on the `Organism`, `Region` or `Site` annotations of the sequence.\n"
+            ]
+        },
+        {
+            "cell_type": "code",
+            "execution_count": 2,
+            "metadata": {},
+            "outputs": [],
+            "source": [
+                "from pyeed.core import ProteinRecord\n",
+                "\n",
+                "matHM = ProteinRecord.get_id(\"MBP1912539.1\")"
+            ]
+        },
+        {
+            "cell_type": "markdown",
+            "metadata": {},
+            "source": [
+                "**Multiple accession IDs**\n",
+                "\n",
+                "To load multiple sequences at once, the `get_ids` function can be used. The function takes a list of accession IDs as input and returns a list of `ProteinRecord` objects."
+            ]
+        },
+        {
+            "cell_type": "code",
+            "execution_count": null,
+            "metadata": {},
+            "outputs": [],
+            "source": [
+                "import json\n",
+                "\n",
+                "# Load the saved ids from json\n",
+                "with open(\"ids.json\", \"r\") as f:\n",
+                "    ids = json.load(f)\n",
+                "\n",
+                "# Get the protein info for each id\n",
+                "proteins = ProteinRecord.get_ids(ids)"
+            ]
+        },
+        {
+            "cell_type": "markdown",
+            "metadata": {},
+            "source": [
+                "## Serach for similar sequences with BLAST\n",
+                "\n",
+                "The `ncbi_blast` method can be used to perform a BLAST search on the NCBI server. The method can be applied to a `ProteinRecord` object and returns a list of `ProteinRecord` objects that represent the hits of the BLAST search.\n",
+                "By specifying the `n_hits`, `e_value`, `db`, `matrix`, and `identity`, the search can be customized to number of hits, E-value, query database, substitution matrix, and identity to accept the hit, respectively.\n",
+                "\n",
+                "
\n", + "

NCBI BLAST service might be slow

\n", + "

Due to the way NCBI handles requests to its BLAST API the service is quite slow. During peak working hours a single search might take more than 15 min.

\n", + "
" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "blast_results = matHM.ncbi_blast(\n", + " n_hits=100,\n", + " e_value=0.05,\n", + " db=\"swissprot\",\n", + " matrix=\"BLOSUM62\",\n", + " identity=0.5,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Inspect objects\n", + "\n", + "Each `pyeed` object has a rich `print` method, displaying all the information available for the object. This can be useful to inspect the object and its attributes." + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[4mProteinRecord\u001b[0m\n", + "├── \u001b[94mid\u001b[0m = MBP1912539.1\n", + "├── \u001b[94mname\u001b[0m = S-adenosylmethionine synthetase\n", + "├── \u001b[94morganism\u001b[0m\n", + "│ └── \u001b[4mOrganism\u001b[0m\n", + "│ ├── \u001b[94mid\u001b[0m = ec01bd4b-490f-4908-aa3c-f8435295e9ef\n", + "│ ├── \u001b[94mtaxonomy_id\u001b[0m = 49900\n", + "│ ├── \u001b[94mname\u001b[0m = Thermococcus stetteri\n", + "│ ├── \u001b[94mdomain\u001b[0m = Archaea\n", + "│ ├── \u001b[94mphylum\u001b[0m = Euryarchaeota\n", + "│ ├── \u001b[94mtax_class\u001b[0m = Thermococci\n", + "│ ├── \u001b[94morder\u001b[0m = Thermococcales\n", + "│ ├── \u001b[94mfamily\u001b[0m = Thermococcaceae\n", + "│ └── \u001b[94mgenus\u001b[0m = Thermococcus\n", + "├── \u001b[94msequence\u001b[0m = MLMAEKIRNIVVEEMVRTPVEMQQVELVERKGIGHPDSIADGIAEAVSRALSREYMKRYGIILHHNTDQVEVVGGRAYPQFGGGEVIKPIYILLSGRAVEMVDREFFPVHEVAIKAAKDYLKKAVRHLDIENHVVIDSRIGQGSVDLVGVFNKAKKNPIPLANDTSFGVGYAPLSETERIVLETEKYLNSDEFKKKWPAVGEDIKVMGLRKGDEIDLTIAAAIVDSEVDNPDDYMAVKEAIYEAAKEIVESHTQRPTNIYVNTADDPKEGIYYITVTGTSAEAGDDGSVGRGNRVNGLITPNRHMSMEAAAGKNPVSHVGKIYNILSMLIANDIAEQIEGVEEVYVRILSQIGKPIDEPLVASVQIIPKKGYSIDVLQKPAYEIADEWLANITKIQKMILEDKINVF\n", + "├── \u001b[94mcoding_sequence\u001b[0m\n", + "│ └── 0\n", + "│ └── \u001b[4mRegion\u001b[0m\n", + "│ ├── \u001b[94mid\u001b[0m = JAGGKB010000004.1\n", + "│ ├── \u001b[94mstart\u001b[0m = 39572\n", + "│ └── \u001b[94mend\u001b[0m = 40795\n", + "└── \u001b[94mec_number\u001b[0m = 2.5.1.6\n", + "\n" + ] + } + ], + "source": [ + "print(matHM)" + ] + } + ], + "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.11.5" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/docs/examples/ids.json b/docs/examples/ids.json new file mode 100644 index 00000000..696336d9 --- /dev/null +++ b/docs/examples/ids.json @@ -0,0 +1,26 @@ +[ + "A1RSD7", + "A8MD44", + "P0CW62", + "A6VHQ4", + "A9A923", + "B6YUL1", + "Q5V2S5", + "Q4JAL1", + "B1YC36", + "P0CW63", + "Q980S9", + "Q3IQF5", + "Q9V1P7", + "Q8PWS4", + "Q5JF22", + "Q8TU57", + "C5A4B7", + "B0R5A8", + "P26498", + "O67275", + "A7I771", + "Q976F3", + "A3MY01", + "Q58605" +] \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index f5b4e7bc..5b878dd6 100644 --- a/docs/index.md +++ b/docs/index.md @@ -4,7 +4,7 @@ The API is currently under construction and is subject to change. -## What is PyEED? +## 🤔 What is PyEED? `pyeed` is a Python toolkit, that allows easy creation, annotation, and analysis of sequence data. All functionalities are based on a data model, which integrates all information on a given nucleotide or protein sequence in a single object. This allows the bundling of all information on a given sequence, making it available in all creation, annotation, and analysis steps. The entire system is generic and applies to various research scenarios. `pyeed` is designed to enable object-oriented programming for bioinformatics. @@ -13,6 +13,6 @@ The data structure of `pyeed` is based on a [data model](https://github.com/PyEED/pyeed/blob/main/specifications/data_model.md)(1), describing the relation between all attributes of a sequence. These attributes include the sequence, the organism, and annotations of the sequence such as sites and regions within the sequence. Furthermore, the information is marked with annotations, marking the origin of the information. -## 🛠️ Tools +## 🧰 Tools `pyeed` implements common tools for clustering, aligning, and visualizing sequences. CLI tools such as `Clustal Omega` are implemented as a Docker Service, allowing easy installation and usage of these tools. \ No newline at end of file diff --git a/examples/network.ipynb b/examples/network.ipynb new file mode 100644 index 00000000..de72e45e --- /dev/null +++ b/examples/network.ipynb @@ -0,0 +1,216 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "import json\n", + "import py4cytoscape as p4c\n", + "from pyeed.core import ProteinRecord\n", + "from pyeed.network import SequenceNetwork" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "bffa16920eb74dd889c477735f364ae0", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Output()" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
/home/niklas/anaconda3/envs/pyeed/lib/python3.11/site-packages/numpy/core/getlimits.py:549: UserWarning: The value \n",
+       "of the smallest subnormal for <class 'numpy.float64'> type is zero.\n",
+       "  setattr(self, word, getattr(machar, word).flat[0])\n",
+       "
\n" + ], + "text/plain": [ + "/home/niklas/anaconda3/envs/pyeed/lib/python3.11/site-packages/numpy/core/getlimits.py:549: UserWarning: The value \n", + "of the smallest subnormal for type is zero.\n", + " setattr(self, word, getattr(machar, word).flat[0])\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
\n"
+      ],
+      "text/plain": []
+     },
+     "metadata": {},
+     "output_type": "display_data"
+    },
+    {
+     "data": {
+      "text/html": [
+       "
\n",
+       "
\n" + ], + "text/plain": [ + "\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "# load ids\n", + "with open('ids.json', 'r') as f:\n", + " ids = json.load(f)\n", + "\n", + "# load sequences\n", + "sequences = ProteinRecord.get_ids(ids[:100])\n", + "\n", + "\n", + "base_url = 'http://cytoscape-desktop:1234/v1'" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "c56bc3a6f2c443e194021f4b9d49d52b", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Output()" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
\n"
+      ],
+      "text/plain": []
+     },
+     "metadata": {},
+     "output_type": "display_data"
+    },
+    {
+     "data": {
+      "text/html": [
+       "
\n",
+       "
\n" + ], + "text/plain": [ + "\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "graph = SequenceNetwork(sequences, base_url=base_url)" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "In cyrest_get: Cannot find local or remote Cytoscape. Start Cytoscape and then proceed.\n" + ] + }, + { + "ename": "RequestException", + "evalue": "Cannot find local or remote Cytoscape. Start Cytoscape and then proceed.", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mRequestException\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[4], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m threshhold \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m0.75\u001b[39m\n\u001b[0;32m----> 3\u001b[0m \u001b[43mgraph\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcreate_cytoscape_graph\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcollection\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mSequenceNetwork\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtitle\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mTest\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mthreshold\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mthreshhold\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 4\u001b[0m graph\u001b[38;5;241m.\u001b[39mset_nodes_size(column_name\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mdegree_with_threshold_\u001b[39m\u001b[38;5;132;01m{}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;241m.\u001b[39mformat(threshhold), min_size\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m20\u001b[39m, max_size\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m100\u001b[39m)\n\u001b[1;32m 5\u001b[0m graph\u001b[38;5;241m.\u001b[39mcolor_nodes(column_name\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mphylum\u001b[39m\u001b[38;5;124m'\u001b[39m)\n", + "File \u001b[0;32m~/Desktop/Job_Niklas/pyeed/pyeed/network/network.py:187\u001b[0m, in \u001b[0;36mSequenceNetwork.create_cytoscape_graph\u001b[0;34m(self, collection, title, threshold)\u001b[0m\n\u001b[1;32m 183\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mcreate_cytoscape_graph\u001b[39m(\n\u001b[1;32m 184\u001b[0m \u001b[38;5;28mself\u001b[39m, collection: \u001b[38;5;28mstr\u001b[39m, title: \u001b[38;5;28mstr\u001b[39m, threshold: \u001b[38;5;28mfloat\u001b[39m \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m0.8\u001b[39m\n\u001b[1;32m 185\u001b[0m ):\n\u001b[1;32m 186\u001b[0m \u001b[38;5;66;03m# assert that the cytoscape API is running and cytoscape is running in the background\u001b[39;00m\n\u001b[0;32m--> 187\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m \u001b[43mp4c\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcytoscape_ping\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 188\u001b[0m \u001b[43m \u001b[49m\u001b[43mbase_url\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_base_url\u001b[49m\n\u001b[1;32m 189\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mCytoscape is not running in the background\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 190\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m p4c\u001b[38;5;241m.\u001b[39mcytoscape_version_info(\n\u001b[1;32m 191\u001b[0m base_url\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_base_url\n\u001b[1;32m 192\u001b[0m ), \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mCytoscape API is not running\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 193\u001b[0m \u001b[38;5;66;03m# create a degree column for the nodes based on the current choosen threshold\u001b[39;00m\n", + "File \u001b[0;32m~/anaconda3/envs/pyeed/lib/python3.11/site-packages/py4cytoscape/py4cytoscape_logger.py:133\u001b[0m, in \u001b[0;36mcy_log..wrapper_log\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 131\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m log_return(func, value)\n\u001b[1;32m 132\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[0;32m--> 133\u001b[0m \u001b[43mlog_exception\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfunc\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43me\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 134\u001b[0m \u001b[38;5;28;01mfinally\u001b[39;00m:\n\u001b[1;32m 135\u001b[0m log_finally()\n", + "File \u001b[0;32m~/anaconda3/envs/pyeed/lib/python3.11/site-packages/py4cytoscape/py4cytoscape_logger.py:130\u001b[0m, in \u001b[0;36mcy_log..wrapper_log\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 128\u001b[0m log_incoming(func, \u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[1;32m 129\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m--> 130\u001b[0m value \u001b[38;5;241m=\u001b[39m \u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m \u001b[38;5;66;03m# Call function being logged\u001b[39;00m\n\u001b[1;32m 131\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m log_return(func, value)\n\u001b[1;32m 132\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n", + "File \u001b[0;32m~/anaconda3/envs/pyeed/lib/python3.11/site-packages/py4cytoscape/cytoscape_system.py:58\u001b[0m, in \u001b[0;36mcytoscape_ping\u001b[0;34m(base_url)\u001b[0m\n\u001b[1;32m 37\u001b[0m \u001b[38;5;250m\u001b[39m\u001b[38;5;124;03m\"\"\"Ping Cytoscape\u001b[39;00m\n\u001b[1;32m 38\u001b[0m \n\u001b[1;32m 39\u001b[0m \u001b[38;5;124;03mTests the connection to Cytoscape via CyREST and verifies that supported versions of Cytoscape and CyREST API are loaded.\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 55\u001b[0m \u001b[38;5;124;03m You are connected to Cytoscape!\u001b[39;00m\n\u001b[1;32m 56\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 57\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mpy4cytoscape_utils\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m verify_supported_versions\n\u001b[0;32m---> 58\u001b[0m \u001b[43mverify_supported_versions\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m3.6\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mbase_url\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mbase_url\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 59\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m narrate(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mYou are connected to Cytoscape!\u001b[39m\u001b[38;5;124m'\u001b[39m)\n", + "File \u001b[0;32m~/anaconda3/envs/pyeed/lib/python3.11/site-packages/py4cytoscape/py4cytoscape_utils.py:819\u001b[0m, in \u001b[0;36mverify_supported_versions\u001b[0;34m(cyrest, cytoscape, base_url, caller)\u001b[0m\n\u001b[1;32m 794\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mverify_supported_versions\u001b[39m(cyrest\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m1\u001b[39m, cytoscape\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m3.6\u001b[39m, base_url\u001b[38;5;241m=\u001b[39mDEFAULT_BASE_URL, caller\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m):\n\u001b[1;32m 795\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"Throws exception if min supported versions of api and cytoscape are not running.\u001b[39;00m\n\u001b[1;32m 796\u001b[0m \n\u001b[1;32m 797\u001b[0m \u001b[38;5;124;03m Extracts numerics from api and major cytoscape versions before making comparison.\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 817\u001b[0m \u001b[38;5;124;03m >>> verify_supported_versions(1, '3.10.1')\u001b[39;00m\n\u001b[1;32m 818\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[0;32m--> 819\u001b[0m nogo \u001b[38;5;241m=\u001b[39m \u001b[43mcheck_supported_versions\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcyrest\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcyrest\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcytoscape\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcytoscape\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mbase_url\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mbase_url\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 821\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m nogo:\n\u001b[1;32m 822\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m caller \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m: caller \u001b[38;5;241m=\u001b[39m sys\u001b[38;5;241m.\u001b[39m_getframe(\u001b[38;5;241m1\u001b[39m)\u001b[38;5;241m.\u001b[39mf_code\u001b[38;5;241m.\u001b[39mco_name\n", + "File \u001b[0;32m~/anaconda3/envs/pyeed/lib/python3.11/site-packages/py4cytoscape/py4cytoscape_utils.py:763\u001b[0m, in \u001b[0;36mcheck_supported_versions\u001b[0;34m(cyrest, cytoscape, base_url, caller, test_cytoscape)\u001b[0m\n\u001b[1;32m 739\u001b[0m \u001b[38;5;250m\u001b[39m\u001b[38;5;124;03m\"\"\"Checks to see if min supported versions of api and cytoscape are running.\u001b[39;00m\n\u001b[1;32m 740\u001b[0m \n\u001b[1;32m 741\u001b[0m \u001b[38;5;124;03mExtracts numerics from api, major and patch cytoscape versions before making comparison, per semantic versioning @ https://semver.org/\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 759\u001b[0m \u001b[38;5;124;03m >>> check_supported_versions(1, '3.10.0')\u001b[39;00m\n\u001b[1;32m 760\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 761\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(cytoscape, \u001b[38;5;28mfloat\u001b[39m): cytoscape \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mstr\u001b[39m(cytoscape)\n\u001b[0;32m--> 763\u001b[0m v \u001b[38;5;241m=\u001b[39m \u001b[43mcytoscape_system\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcytoscape_version_info\u001b[49m\u001b[43m(\u001b[49m\u001b[43mbase_url\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mbase_url\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 764\u001b[0m v_api_str \u001b[38;5;241m=\u001b[39m v[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mapiVersion\u001b[39m\u001b[38;5;124m'\u001b[39m]\n\u001b[1;32m 765\u001b[0m v_cy_str \u001b[38;5;241m=\u001b[39m v[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mcytoscapeVersion\u001b[39m\u001b[38;5;124m'\u001b[39m] \u001b[38;5;28;01mif\u001b[39;00m test_cytoscape \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;28;01melse\u001b[39;00m test_cytoscape\n", + "File \u001b[0;32m~/anaconda3/envs/pyeed/lib/python3.11/site-packages/py4cytoscape/py4cytoscape_logger.py:133\u001b[0m, in \u001b[0;36mcy_log..wrapper_log\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 131\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m log_return(func, value)\n\u001b[1;32m 132\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[0;32m--> 133\u001b[0m \u001b[43mlog_exception\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfunc\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43me\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 134\u001b[0m \u001b[38;5;28;01mfinally\u001b[39;00m:\n\u001b[1;32m 135\u001b[0m log_finally()\n", + "File \u001b[0;32m~/anaconda3/envs/pyeed/lib/python3.11/site-packages/py4cytoscape/py4cytoscape_logger.py:130\u001b[0m, in \u001b[0;36mcy_log..wrapper_log\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 128\u001b[0m log_incoming(func, \u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[1;32m 129\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m--> 130\u001b[0m value \u001b[38;5;241m=\u001b[39m \u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m \u001b[38;5;66;03m# Call function being logged\u001b[39;00m\n\u001b[1;32m 131\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m log_return(func, value)\n\u001b[1;32m 132\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n", + "File \u001b[0;32m~/anaconda3/envs/pyeed/lib/python3.11/site-packages/py4cytoscape/cytoscape_system.py:81\u001b[0m, in \u001b[0;36mcytoscape_version_info\u001b[0;34m(base_url)\u001b[0m\n\u001b[1;32m 61\u001b[0m \u001b[38;5;129m@cy_log\u001b[39m\n\u001b[1;32m 62\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mcytoscape_version_info\u001b[39m(base_url\u001b[38;5;241m=\u001b[39mDEFAULT_BASE_URL):\n\u001b[1;32m 63\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"Return the versions of the current Cytoscape and CyREST API.\u001b[39;00m\n\u001b[1;32m 64\u001b[0m \n\u001b[1;32m 65\u001b[0m \u001b[38;5;124;03m Args:\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 79\u001b[0m \u001b[38;5;124;03m {'apiVersion': 'v1', 'cytoscapeVersion': '3.8.1', 'automationAPIVersion': '0.0.0', 'py4cytoscapeVersion': '0.0.2'}\u001b[39;00m\n\u001b[1;32m 80\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[0;32m---> 81\u001b[0m versions \u001b[38;5;241m=\u001b[39m \u001b[43mcommands\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcyrest_get\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mversion\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mbase_url\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mbase_url\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 82\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(versions) \u001b[38;5;241m==\u001b[39m \u001b[38;5;241m0\u001b[39m:\n\u001b[1;32m 83\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m CyError(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mCyREST connection problem. py4cytoscape cannot continue!\u001b[39m\u001b[38;5;124m'\u001b[39m)\n", + "File \u001b[0;32m~/anaconda3/envs/pyeed/lib/python3.11/site-packages/py4cytoscape/py4cytoscape_logger.py:133\u001b[0m, in \u001b[0;36mcy_log..wrapper_log\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 131\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m log_return(func, value)\n\u001b[1;32m 132\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[0;32m--> 133\u001b[0m \u001b[43mlog_exception\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfunc\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43me\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 134\u001b[0m \u001b[38;5;28;01mfinally\u001b[39;00m:\n\u001b[1;32m 135\u001b[0m log_finally()\n", + "File \u001b[0;32m~/anaconda3/envs/pyeed/lib/python3.11/site-packages/py4cytoscape/py4cytoscape_logger.py:130\u001b[0m, in \u001b[0;36mcy_log..wrapper_log\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 128\u001b[0m log_incoming(func, \u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[1;32m 129\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m--> 130\u001b[0m value \u001b[38;5;241m=\u001b[39m \u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m \u001b[38;5;66;03m# Call function being logged\u001b[39;00m\n\u001b[1;32m 131\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m log_return(func, value)\n\u001b[1;32m 132\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n", + "File \u001b[0;32m~/anaconda3/envs/pyeed/lib/python3.11/site-packages/py4cytoscape/commands.py:159\u001b[0m, in \u001b[0;36mcyrest_get\u001b[0;34m(operation, parameters, base_url, require_json, raw_get)\u001b[0m\n\u001b[1;32m 157\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m r\u001b[38;5;241m.\u001b[39mtext\n\u001b[1;32m 158\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m requests\u001b[38;5;241m.\u001b[39mexceptions\u001b[38;5;241m.\u001b[39mRequestException \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[0;32m--> 159\u001b[0m \u001b[43m_handle_error\u001b[49m\u001b[43m(\u001b[49m\u001b[43me\u001b[49m\u001b[43m)\u001b[49m\n", + "File \u001b[0;32m~/anaconda3/envs/pyeed/lib/python3.11/site-packages/py4cytoscape/commands.py:149\u001b[0m, in \u001b[0;36mcyrest_get\u001b[0;34m(operation, parameters, base_url, require_json, raw_get)\u001b[0m\n\u001b[1;32m 147\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m 148\u001b[0m url \u001b[38;5;241m=\u001b[39m build_url(base_url, operation)\n\u001b[0;32m--> 149\u001b[0m r \u001b[38;5;241m=\u001b[39m \u001b[43m_do_request\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mGET\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43murl\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparams\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mparameters\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mbase_url\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mbase_url\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mraw_request\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mraw_get\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 150\u001b[0m r\u001b[38;5;241m.\u001b[39mraise_for_status()\n\u001b[1;32m 151\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n", + "File \u001b[0;32m~/anaconda3/envs/pyeed/lib/python3.11/site-packages/py4cytoscape/commands.py:695\u001b[0m, in \u001b[0;36m_do_request\u001b[0;34m(method, url, base_url, raw_request, **kwargs)\u001b[0m\n\u001b[1;32m 693\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_do_request\u001b[39m(method, url, base_url\u001b[38;5;241m=\u001b[39mDEFAULT_BASE_URL, raw_request\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs):\n\u001b[1;32m 694\u001b[0m \u001b[38;5;66;03m# Determine whether actual call is local or remote\u001b[39;00m\n\u001b[0;32m--> 695\u001b[0m requester, default_sandbox \u001b[38;5;241m=\u001b[39m \u001b[43m_get_requester\u001b[49m\u001b[43m(\u001b[49m\u001b[43mbase_url\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 697\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m raw_request:\n\u001b[1;32m 698\u001b[0m do_initialize_sandbox(requester, base_url\u001b[38;5;241m=\u001b[39mbase_url) \u001b[38;5;66;03m# make sure there's a sandbox before executing a command\u001b[39;00m\n", + "File \u001b[0;32m~/anaconda3/envs/pyeed/lib/python3.11/site-packages/py4cytoscape/commands.py:779\u001b[0m, in \u001b[0;36m_get_requester\u001b[0;34m(base_url)\u001b[0m\n\u001b[1;32m 777\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_get_requester\u001b[39m(base_url):\n\u001b[1;32m 778\u001b[0m \u001b[38;5;66;03m# Figure out whether CyREST available only via Jupyter-Bridge and what the default sandbox should be\u001b[39;00m\n\u001b[0;32m--> 779\u001b[0m environment \u001b[38;5;241m=\u001b[39m \u001b[43m_find_execution_environment\u001b[49m\u001b[43m(\u001b[49m\u001b[43mbase_url\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 780\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m environment \u001b[38;5;241m==\u001b[39m ExecutionEnvironment\u001b[38;5;241m.\u001b[39mREMOTE_JUPYTER_BRIDGE:\n\u001b[1;32m 781\u001b[0m default_sandbox \u001b[38;5;241m=\u001b[39m set_default_sandbox(\u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39msandbox_initializer(sandboxName\u001b[38;5;241m=\u001b[39mPREDEFINED_SANDBOX_NAME))\n", + "File \u001b[0;32m~/anaconda3/envs/pyeed/lib/python3.11/site-packages/py4cytoscape/commands.py:803\u001b[0m, in \u001b[0;36m_find_execution_environment\u001b[0;34m(base_url)\u001b[0m\n\u001b[1;32m 801\u001b[0m environment \u001b[38;5;241m=\u001b[39m check_execution_environment(base_url)\n\u001b[1;32m 802\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m environment \u001b[38;5;241m==\u001b[39m ExecutionEnvironment\u001b[38;5;241m.\u001b[39mUNKNOWN:\n\u001b[0;32m--> 803\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m requests\u001b[38;5;241m.\u001b[39mexceptions\u001b[38;5;241m.\u001b[39mRequestException(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mCannot find local or remote Cytoscape. Start Cytoscape and then proceed.\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m 804\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m environment\n", + "\u001b[0;31mRequestException\u001b[0m: Cannot find local or remote Cytoscape. Start Cytoscape and then proceed." + ] + } + ], + "source": [ + "threshhold = 0.75\n", + "\n", + "graph.create_cytoscape_graph(collection='SequenceNetwork', title='Test', threshold=threshhold)\n", + "graph.set_nodes_size(column_name=\"degree_with_threshold_{}\".format(threshhold), min_size=20, max_size=100)\n", + "graph.color_nodes(column_name='phylum')\n", + "graph.set_layout(layout_name = \"force-directed\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "p4c.notebook_export_show_image(filename=\"test\", type=\"png\", resolution=600, zoom=100.0, overwrite_file=True, base_url=base_url)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "pyeed", + "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.11.8" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/mkdocs.yml b/mkdocs.yml index 8b3ef8c6..d750e55b 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -6,19 +6,22 @@ site_author: Max Häußler nav: - 🏠 Home: index.md - - ⚡️ Quick Start: + - ⚡️ Examples: + - Basics: examples/basics.ipynb + - Alignments: examples/alignment.ipynb + - 🧰 Tools: - quick_start/index.md - The Sequence objects: quick_start/basics.md - Finding Sequences: quick_start/blast.md - Aligning Sequences: quick_start/alignments.md - Clustering Sequences: quick_start/clustering.md - Creating Sequence Networks: quick_start/networks.md - - 🔎 Examples: - - Basics: usecases/usecase1.md - ⬇️ Installation: - PyEED Docker Service: installation/docker.md - via PIP: installation/via_pip.md - #- deprecated: installation/jupyterlab.md + +plugins: + - mkdocs-jupyter theme: name: material diff --git a/pyeed/core/abstractannotation.py b/pyeed/core/abstractannotation.py index 06f98c82..1f6e3ad4 100644 --- a/pyeed/core/abstractannotation.py +++ b/pyeed/core/abstractannotation.py @@ -51,7 +51,7 @@ class AbstractAnnotation( _repo: Optional[str] = PrivateAttr(default="https://github.com/PyEED/pyeed") _commit: Optional[str] = PrivateAttr( - default="09207e10bb1bfb6e6916b6ef62932c6b08209190" + default="34eec88e986aa525aa9515b66d1b4d0aa46e71d3" ) _raw_xml_data: Dict = PrivateAttr(default_factory=dict) diff --git a/pyeed/core/alignmentresult.py b/pyeed/core/alignmentresult.py index e1533a44..dc6cb9ba 100644 --- a/pyeed/core/alignmentresult.py +++ b/pyeed/core/alignmentresult.py @@ -51,7 +51,7 @@ class AlignmentResult( _repo: Optional[str] = PrivateAttr(default="https://github.com/PyEED/pyeed") _commit: Optional[str] = PrivateAttr( - default="09207e10bb1bfb6e6916b6ef62932c6b08209190" + default="34eec88e986aa525aa9515b66d1b4d0aa46e71d3" ) _raw_xml_data: Dict = PrivateAttr(default_factory=dict) diff --git a/pyeed/core/blastdata.py b/pyeed/core/blastdata.py index 05669432..1a2a79f0 100644 --- a/pyeed/core/blastdata.py +++ b/pyeed/core/blastdata.py @@ -90,7 +90,7 @@ class BlastData( _repo: Optional[str] = PrivateAttr(default="https://github.com/PyEED/pyeed") _commit: Optional[str] = PrivateAttr( - default="09207e10bb1bfb6e6916b6ef62932c6b08209190" + default="34eec88e986aa525aa9515b66d1b4d0aa46e71d3" ) _raw_xml_data: Dict = PrivateAttr(default_factory=dict) diff --git a/pyeed/core/clustalomegaresult.py b/pyeed/core/clustalomegaresult.py index 77f89a50..967d62ce 100644 --- a/pyeed/core/clustalomegaresult.py +++ b/pyeed/core/clustalomegaresult.py @@ -32,7 +32,7 @@ class ClustalOmegaResult( _repo: Optional[str] = PrivateAttr(default="https://github.com/PyEED/pyeed") _commit: Optional[str] = PrivateAttr( - default="09207e10bb1bfb6e6916b6ef62932c6b08209190" + default="34eec88e986aa525aa9515b66d1b4d0aa46e71d3" ) _raw_xml_data: Dict = PrivateAttr(default_factory=dict) diff --git a/pyeed/core/cluster.py b/pyeed/core/cluster.py index 10fd36e1..80200d68 100644 --- a/pyeed/core/cluster.py +++ b/pyeed/core/cluster.py @@ -49,7 +49,7 @@ class Cluster( _repo: Optional[str] = PrivateAttr(default="https://github.com/PyEED/pyeed") _commit: Optional[str] = PrivateAttr( - default="09207e10bb1bfb6e6916b6ef62932c6b08209190" + default="34eec88e986aa525aa9515b66d1b4d0aa46e71d3" ) _raw_xml_data: Dict = PrivateAttr(default_factory=dict) diff --git a/pyeed/core/dnarecord.py b/pyeed/core/dnarecord.py index 8b14fc29..0b688fb9 100644 --- a/pyeed/core/dnarecord.py +++ b/pyeed/core/dnarecord.py @@ -62,7 +62,7 @@ class DNARecord( _repo: Optional[str] = PrivateAttr(default="https://github.com/PyEED/pyeed") _commit: Optional[str] = PrivateAttr( - default="09207e10bb1bfb6e6916b6ef62932c6b08209190" + default="34eec88e986aa525aa9515b66d1b4d0aa46e71d3" ) _raw_xml_data: Dict = PrivateAttr(default_factory=dict) diff --git a/pyeed/core/organism.py b/pyeed/core/organism.py index a6e4770b..5fb380a3 100644 --- a/pyeed/core/organism.py +++ b/pyeed/core/organism.py @@ -108,7 +108,7 @@ class Organism( _repo: Optional[str] = PrivateAttr(default="https://github.com/PyEED/pyeed") _commit: Optional[str] = PrivateAttr( - default="09207e10bb1bfb6e6916b6ef62932c6b08209190" + default="34eec88e986aa525aa9515b66d1b4d0aa46e71d3" ) _raw_xml_data: Dict = PrivateAttr(default_factory=dict) diff --git a/pyeed/core/pairwisealignmentresult.py b/pyeed/core/pairwisealignmentresult.py index 035ee352..a4a8ebcd 100644 --- a/pyeed/core/pairwisealignmentresult.py +++ b/pyeed/core/pairwisealignmentresult.py @@ -60,7 +60,7 @@ class PairwiseAlignmentResult( _repo: Optional[str] = PrivateAttr(default="https://github.com/PyEED/pyeed") _commit: Optional[str] = PrivateAttr( - default="09207e10bb1bfb6e6916b6ef62932c6b08209190" + default="34eec88e986aa525aa9515b66d1b4d0aa46e71d3" ) _raw_xml_data: Dict = PrivateAttr(default_factory=dict) diff --git a/pyeed/core/proteinrecord.py b/pyeed/core/proteinrecord.py index 9c59037a..630f9475 100644 --- a/pyeed/core/proteinrecord.py +++ b/pyeed/core/proteinrecord.py @@ -101,7 +101,7 @@ class ProteinRecord( _repo: Optional[str] = PrivateAttr(default="https://github.com/PyEED/pyeed") _commit: Optional[str] = PrivateAttr( - default="09207e10bb1bfb6e6916b6ef62932c6b08209190" + default="34eec88e986aa525aa9515b66d1b4d0aa46e71d3" ) _raw_xml_data: Dict = PrivateAttr(default_factory=dict) diff --git a/pyeed/core/region.py b/pyeed/core/region.py index bbbb6e2f..20f91c2d 100644 --- a/pyeed/core/region.py +++ b/pyeed/core/region.py @@ -38,7 +38,7 @@ class Region( _repo: Optional[str] = PrivateAttr(default="https://github.com/PyEED/pyeed") _commit: Optional[str] = PrivateAttr( - default="09207e10bb1bfb6e6916b6ef62932c6b08209190" + default="34eec88e986aa525aa9515b66d1b4d0aa46e71d3" ) _raw_xml_data: Dict = PrivateAttr(default_factory=dict) diff --git a/pyeed/core/sequence.py b/pyeed/core/sequence.py index afdfffef..3bd5f3cf 100644 --- a/pyeed/core/sequence.py +++ b/pyeed/core/sequence.py @@ -38,7 +38,7 @@ class Sequence( _repo: Optional[str] = PrivateAttr(default="https://github.com/PyEED/pyeed") _commit: Optional[str] = PrivateAttr( - default="09207e10bb1bfb6e6916b6ef62932c6b08209190" + default="34eec88e986aa525aa9515b66d1b4d0aa46e71d3" ) _raw_xml_data: Dict = PrivateAttr(default_factory=dict) diff --git a/pyeed/core/sequencerecord.py b/pyeed/core/sequencerecord.py index e54cf57c..6ea84b92 100644 --- a/pyeed/core/sequencerecord.py +++ b/pyeed/core/sequencerecord.py @@ -62,7 +62,7 @@ class SequenceRecord( _repo: Optional[str] = PrivateAttr(default="https://github.com/PyEED/pyeed") _commit: Optional[str] = PrivateAttr( - default="09207e10bb1bfb6e6916b6ef62932c6b08209190" + default="34eec88e986aa525aa9515b66d1b4d0aa46e71d3" ) _raw_xml_data: Dict = PrivateAttr(default_factory=dict) diff --git a/pyeed/core/site.py b/pyeed/core/site.py index 5e02ae0d..139b4699 100644 --- a/pyeed/core/site.py +++ b/pyeed/core/site.py @@ -35,7 +35,7 @@ class Site( _repo: Optional[str] = PrivateAttr(default="https://github.com/PyEED/pyeed") _commit: Optional[str] = PrivateAttr( - default="09207e10bb1bfb6e6916b6ef62932c6b08209190" + default="34eec88e986aa525aa9515b66d1b4d0aa46e71d3" ) _raw_xml_data: Dict = PrivateAttr(default_factory=dict) diff --git a/pyeed/core/standardnumbering.py b/pyeed/core/standardnumbering.py index b3b09bed..5527bb37 100644 --- a/pyeed/core/standardnumbering.py +++ b/pyeed/core/standardnumbering.py @@ -47,7 +47,7 @@ class StandardNumbering( _repo: Optional[str] = PrivateAttr(default="https://github.com/PyEED/pyeed") _commit: Optional[str] = PrivateAttr( - default="09207e10bb1bfb6e6916b6ef62932c6b08209190" + default="34eec88e986aa525aa9515b66d1b4d0aa46e71d3" ) _raw_xml_data: Dict = PrivateAttr(default_factory=dict) diff --git a/pyeed/tools/clustalo.py b/pyeed/tools/clustalo.py index 0f890149..3eaa151c 100644 --- a/pyeed/tools/clustalo.py +++ b/pyeed/tools/clustalo.py @@ -4,6 +4,7 @@ import httpx from Bio import AlignIO from Bio.Align import MultipleSeqAlignment +from pydantic import PrivateAttr from pyeed.tools.abstract_tool import AbstractTool, ServiceURL @@ -13,7 +14,7 @@ class ClustalOmega(AbstractTool): Class for ClustalOmega aligner running as a REST service. """ - _service_url = ServiceURL.CLUSTALO.value + _service_url = PrivateAttr(ServiceURL.CLUSTALO.value) def create_file(self, multifasta: List[str]) -> Dict[str, str]: """ @@ -41,8 +42,20 @@ def extract_output_data(self, response) -> MultipleSeqAlignment: return alignment def run_service(self, data) -> httpx.Response: + """Executes the ClustalOmega service.""" file = self.create_file(data) - return httpx.post(self._service_url, files=file, timeout=600) + try: + return httpx.post(self._service_url, files=file, timeout=600) + + except httpx.ConnectError as connect_error: + if connect_error.__context__.args[0].errno == 8: + self._service_url = self._service_url.replace("clustalo", "localhost") + try: + return httpx.post(self._service_url, files=file, timeout=600) + except httpx.ConnectError as connect_error: + raise httpx.ConnectError("PyEED Docker Service is not running.") + + raise httpx.ConnectError("PyEED Docker Service is not running.") def align(self, sequences: List[str]): """ diff --git a/pyproject.toml b/pyproject.toml index 8f89f556..ae6d32a9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pyeed" -version = "0.3.0" +version = "0.3.1" description = "Enzyme engineering toolkit" authors = ["haeussma <83341109+haeussma@users.noreply.github.com>"] license = "MIT" @@ -8,7 +8,7 @@ readme = "README.md" packages = [{ include = "pyeed" }] [tool.poetry.dependencies] -python = ">=3.10,<3.12" +python = ">=3.10,<3.13" biopython = "^1.81" sdrdm-database = { extras = [ "postgres",