{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# What is about ? \n\nSequences alignments are extremely important algorithms used in modern bioinformatics: https://en.wikipedia.org/wiki/Sequence_alignment \nAnd can be of use in some Kaggle challenges like Novoenzymes or CAFA5.\n\nThere is new package \"pyalign\": https://github.com/poke1024/pyalign , discussed e.g. here: https://www.biostars.org/p/9505903/ , \nMany aligners are slow and that one seems to be quite fast.\n\nIt is not simple to install it on Kaggle, however the author ( Bernhard Liebl ) kindly provided a way to do it:\nhttps://www.kaggle.com/code/lieblb/pyalign-example/notebook  - please upvote. \n\nThe direct ways to pip install it does not work -  that is shown in the present notebook. \n\nBernhard Liebl kindly commented on that: \n\n\"installing via pip seems to fail because the xtensor libraries are missing, however I'm not sure why this happens (they should be precompiled into the pip wheel).\n\nI managed to get it to run, however unfortunately it takes 8 minutes to compile\"\n","metadata":{}},{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-06-07T12:05:38.094829Z","iopub.execute_input":"2023-06-07T12:05:38.095256Z","iopub.status.idle":"2023-06-07T12:05:38.102586Z","shell.execute_reply.started":"2023-06-07T12:05:38.095204Z","shell.execute_reply":"2023-06-07T12:05:38.101284Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Trial 1","metadata":{}},{"cell_type":"code","source":"!pip install pyalign","metadata":{"execution":{"iopub.status.busy":"2023-06-07T11:59:22.494591Z","iopub.execute_input":"2023-06-07T11:59:22.495027Z","iopub.status.idle":"2023-06-07T11:59:55.120982Z","shell.execute_reply.started":"2023-06-07T11:59:22.49499Z","shell.execute_reply":"2023-06-07T11:59:55.11967Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pyalign","metadata":{"execution":{"iopub.status.busy":"2023-06-07T11:59:55.12315Z","iopub.execute_input":"2023-06-07T11:59:55.123654Z","iopub.status.idle":"2023-06-07T11:59:55.657138Z","shell.execute_reply.started":"2023-06-07T11:59:55.123615Z","shell.execute_reply":"2023-06-07T11:59:55.654739Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Trial 2","metadata":{}},{"cell_type":"code","source":"!git clone https://github.com/poke1024/pyalign\n!cd pyalign\n!conda env create -f environment.yml\n!conda activate pyalign\n!python setup.py install","metadata":{"execution":{"iopub.status.busy":"2023-06-07T12:08:46.584773Z","iopub.execute_input":"2023-06-07T12:08:46.585185Z","iopub.status.idle":"2023-06-07T12:08:54.966771Z","shell.execute_reply.started":"2023-06-07T12:08:46.585151Z","shell.execute_reply":"2023-06-07T12:08:54.965688Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pyalign\n\nprint( dir(pyalign) )\n\nalignment = pyalign.global_alignment(\"INDUSTRY\", \"INTEREST\", gap_cost=0, eq=1, ne=-1)\nalignment","metadata":{"execution":{"iopub.status.busy":"2023-06-07T12:09:01.576201Z","iopub.execute_input":"2023-06-07T12:09:01.576884Z","iopub.status.idle":"2023-06-07T12:09:01.987711Z","shell.execute_reply.started":"2023-06-07T12:09:01.576848Z","shell.execute_reply":"2023-06-07T12:09:01.986417Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Trial 3 with environment.yml","metadata":{}},{"cell_type":"code","source":"!wget https://github.com/poke1024/pyalign/blob/main/environment.yml","metadata":{"execution":{"iopub.status.busy":"2023-06-07T12:05:49.725619Z","iopub.execute_input":"2023-06-07T12:05:49.72605Z","iopub.status.idle":"2023-06-07T12:05:51.356036Z","shell.execute_reply.started":"2023-06-07T12:05:49.726015Z","shell.execute_reply":"2023-06-07T12:05:51.354854Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!git clone https://github.com/poke1024/pyalign\n!cd pyalign\n!conda env create -f environment.yml\n!conda activate pyalign\n!python setup.py install","metadata":{"execution":{"iopub.status.busy":"2023-06-07T12:06:03.861449Z","iopub.execute_input":"2023-06-07T12:06:03.861874Z","iopub.status.idle":"2023-06-07T12:06:40.67772Z","shell.execute_reply.started":"2023-06-07T12:06:03.861839Z","shell.execute_reply":"2023-06-07T12:06:40.676265Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pyalign\n\nprint( dir(pyalign) )\n\nalignment = pyalign.global_alignment(\"INDUSTRY\", \"INTEREST\", gap_cost=0, eq=1, ne=-1)\nalignment","metadata":{"execution":{"iopub.status.busy":"2023-06-07T12:06:40.679559Z","iopub.execute_input":"2023-06-07T12:06:40.679929Z","iopub.status.idle":"2023-06-07T12:06:41.199759Z","shell.execute_reply.started":"2023-06-07T12:06:40.679895Z","shell.execute_reply":"2023-06-07T12:06:41.198203Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}