{ "cells": [ { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "# Basics of using bendIt running here\n", "\n", "This notebook just illustrates the basics of using bendIt on the command line in this environment.\n", "\n", "The notebook in which active sessions start with [here](bendit-index.ipynb) is meant to illustrate a realistic pipeline using `bendIt` in conjunction with the Jupyter environment. That is meant to give a taste of what is possible by having the command line version of `bendIt` alongside Jupyter environemnt while providng a basis for adapting your own pipelines. However, you may be familiar with bendIt on the command line already and wondering how to use it in Jupyter in the browser. This is meant to help with that. Plus, it could be useful for those looking to understand why I insist adding in taking advatage in Jupyter makes things better because in this example we'll keep use of things beyond the command line `bendIt` minimal.\n", "\n", "------\n", "\n", "
\n", "

If you haven't used one of these notebooks before, they're basically web pages in which you can write, edit, and run live code. They're meant to encourage experimentation, so don't feel nervous. Just try running a few cells and see what happens!.

\n", "\n", "

\n", " Some tips:\n", "

\n", "

\n", "
\n", "\n", "----\n", "\n", "\n", "## Display USAGE block" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "********************************************************************************\n", "\n", "Usage: bendIt [options]\n", "\n", "To run the program gnuplot have to be installed\n", "\n", "The program will generate two output files: a text file used to run gnuplot and the resulting image\n", "\n", "\n", "bendIt options:\n", "\n", "-h, --help Display this usage information.\n", "-s, --seq File in FASTA with the sequence\n", "-o, --output Output file (Text file used to create the gnuplot script)\n", "-S, --Scale Scale to be used (values: Consensus OR DNaseI OR Nucleosome) Default: Consensus\n", "-c, --cwindows Curvature window size (Default: 31)\n", "-b, --bwindows Bendability/G+C content/Complexity window size (Default: 31)\n", "-t, --type Plot type (values: 1D OR 2D) Default: 1D\n", "-1, --smooth1 Smooth1 (values: none, simple, cubic, bezier) Default: none\n", "-2, --smooth2 Smooth2 (values: none, simple, cubic, bezier) Default: none\n", "-g, --complexity Complexity (values: G (G+C content), B (Bendability), C (Complexity)) Default: G\n", " --xmin X min\n", " --xmax X max\n", " --ymin Y min\n", " --ymax Y max\n", " --y2min Y2 min\n", " --y2max Y2 max\n", "********************************************************************************\n", "\n", " Roberto Vera Alvarez (e-mail: Roberto.Vera@icgeb.org)\n", "\n", "********************************************************************************\n" ] } ], "source": [ "!bendIt --help" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Note that in order execute a command on the command line, we added an exclamation point in front of the command so that the contents of the Jupyter notebook cell are run in a shell process. If this were being used in the terminal here `bendIt --help` would suffice. \n", "\n", "(And other options exist for specifying to run in the shell such as the use of `%%bash` on the first line of a cell to send all contents to the shell.)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Run the test included with bendIt\n", "\n", "The authors provided a `test` directory with a FASTA file that can be used as input, and they also included an example output from running that test for comparing to generated output. Because the command line version makes a couple of files, we'll use the next cell to print the contents of the current working directory to monitor that progress. \n", "\n", "(Note: The shell command `ls` is one of a handful of special shell commands supported in Jupyter notebooks without needing an exclamation point in front of it, and indeed output renders with a richer feature st, such as directories being highlighted with colors, when just `ls` is used as opposed to `!ls`.)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "apt.txt bendit-index.ipynb README.md\n", "basic_bendit_commandline.ipynb demo_sample_set.fa requirements.txt\n", "\u001b[0m\u001b[01;34mbendit\u001b[0m/ index.ipynb\n", "bendIt_analysis.ipy \u001b[01;32mpostBuild\u001b[0m*\n" ] } ], "source": [ "ls" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "As an example of using `bendIt` via the command line, using that input a minimal example that leaves all other settings as the default is run on the next cell. From the USAGE block above, you'll note that all that is needed is to specify the input file and a name of an output file to write. We'll provide the path to the provided FASTA file, `t.fasta` in a sub-directory." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "bend.it @ ICGEB Trieste, (c) 2015, R. Vera & S. Pongor\n", "\n", "This is a result for your query sequence \"CP002684.1\" (2380 bp)\n", "You requested a tabulated output of G+C content and Predicted curvature\n", "Parameters:\n", "Profile: Consensus\n", "Predicted curvature window size: 31\n", "Bendability window size: 31\n", "===================================================\n", "Column 1 = Position\n", "Column 2 = Sequence\n", "Column 3 = Predicted curvature\n", "Column 4 = G+C content\n", "---------------------------------------------------\n", "Ranges:\n", "\tNucleotide: Automatic\n", "\tG+C content:\tAutomatic\n", "\tPredicted curvature: Automatic\n", "Running gnuplot\n" ] } ], "source": [ "!bendIt -s bendit/test/t.fasta -o test_output" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To most easily see it ran, check the contents of the directory again by running the following cell:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "apt.txt bendit-index.ipynb README.md\n", "basic_bendit_commandline.ipynb demo_sample_set.fa requirements.txt\n", "\u001b[0m\u001b[01;34mbendit\u001b[0m/ index.ipynb test_output\n", "bendIt_analysis.ipy \u001b[01;32mpostBuild\u001b[0m* test_output.png\n" ] } ], "source": [ "ls" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Note the addition of `test_output` and `test_output.png` to the files that had been listed in the directory when `ls` was previously run.\n", "\n", "Example the generated plot `test_output.png`. (Normally, I'd suggest running the following code to do that, but becasue it relies on Python/Jupyter and I am trying to keep their use to a minimum for contrast, I leave that to reader to try if desired. It is also possible using the markdown `![](test_output.png)` to view the plot right here in the notebook.)\n", "\n", "```python\n", "from IPython.display import Image\n", "Image(\"test_output.png\")\n", "```\n", "\n", "\n", "I leave it an as exercise for the reader to compare `test_output` to the file `text_out` in `bendit/test` subdirectory." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "----- \n", "\n", "I suggest next checking out the more realistic example of using bendIt [here](bendit-index.ipynb) if you haven't yet.\n", "\n", "Enjoy." ] } ], "metadata": { "celltoolbar": "Slideshow", "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.7.6" }, "livereveal": { "autolaunch": true, "scroll": true } }, "nbformat": 4, "nbformat_minor": 4 }