{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Utility functions for sequences" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## One-hot encoding" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "from chame.util.seq import *" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([[1, 0, 0, 0],\n", " [0, 0, 0, 1],\n", " [0, 0, 0, 1],\n", " [1, 0, 0, 0],\n", " [1, 0, 0, 0],\n", " [1, 0, 0, 0],\n", " [0, 0, 1, 0],\n", " [0, 0, 1, 0],\n", " [0, 0, 0, 1],\n", " [0, 0, 0, 1]], dtype=int32)" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sequence_to_onehot(\"attaaaggtt\".upper())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.8.13" } }, "nbformat": 4, "nbformat_minor": 4 }