{ "metadata": { "name": "InstallingBLAST" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "code", "collapsed": false, "input": [ "#change to the etc/profile.d directory\n", "#have to use \"//\" before \"etc\"; first \"/\" moves up to the \"/root\" directory\n", "#second slash moves down to the \"etc\" directory\n", "cd //etc/profile.d" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "/etc/profile.d\n" ] } ], "prompt_number": 1 }, { "cell_type": "code", "collapsed": false, "input": [ "#write BLAST program directory to new scipt file\n", "!echo '#!/bin/bash' > myenvvars.sh" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "/bin/sh: 1: cannot create myenvvars.sh: Permission denied\r\n" ] } ], "prompt_number": 2 }, { "cell_type": "code", "collapsed": false, "input": [ "#check permissions of directory\n", "ls -ld" ], "language": "python", "metadata": {}, "outputs": [ { "ename": "NameError", "evalue": "name 'ls' is not defined", "output_type": "pyerr", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;31m#check permissions of directory\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mls\u001b[0m \u001b[0;34m-\u001b[0m\u001b[0mld\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[0;31mNameError\u001b[0m: name 'ls' is not defined" ] } ], "prompt_number": 3 }, { "cell_type": "code", "collapsed": false, "input": [ "!ls -ld" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "drwxr-xr-x 2 root root 4096 Oct 16 12:02 .\r\n" ] } ], "prompt_number": 4 }, { "cell_type": "raw", "metadata": {}, "source": [ "Don't have permissions, so have to use \"sudo\" to do this, which I can't do in IPython because it doens't allow password entry. \n", "Be right back; going to Terminal to do this.\n", "Ran this command in Terminal: samb@Mephisto://etc/profile.d$ sudo chmod -R 775 /etc/profile.d" ] }, { "cell_type": "code", "collapsed": false, "input": [ "#check directory permissions now\n", "!ls -ld" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "drwxrwxr-x 2 root root 4096 Oct 16 12:02 .\r\n" ] } ], "prompt_number": 6 }, { "cell_type": "code", "collapsed": false, "input": [ "#let's try making and writing to the script file again\n", "!echo '#!/bin/bash' > myenvvars.sh" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "/bin/sh: 1: cannot create myenvvars.sh: Permission denied\r\n" ] } ], "prompt_number": 8 }, { "cell_type": "raw", "metadata": {}, "source": [ "After Googling, changed permissions back to 755 using: samb@Mephisto://etc/profile.d$ sudo chmod -R 755 /etc/profile.d" ] }, { "cell_type": "code", "collapsed": false, "input": [ "!ls -ld" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "drwxr-xr-x 2 root root 4096 Mar 7 16:57 .\r\n" ] } ], "prompt_number": 9 }, { "cell_type": "raw", "metadata": {}, "source": [ "Created file called \"myenvvars.sh\" using: samb@Mephisto://etc/profile.d$ sudo touch myenvvars.sh" ] }, { "cell_type": "code", "collapsed": false, "input": [ "!ls" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "bash_completion.sh myenvvars.sh vte.sh\r\n" ] } ], "prompt_number": 10 }, { "cell_type": "raw", "metadata": {}, "source": [ "Couldn't figure out how to write to the file using Terminal; permission denied on all my various attempts.\n", "Tried each of these:\n", "sudo cat '#!/bin/bash' > myenvvars.sh\n", "sudo echo '#!/bin/bash' > myenvvars.sh\n", "sudo '#!/bin/bash' > myenvvars.sh\n", "\n", "Got this output from all of them:\n", "bash: myenvvars.sh: Permission denied\n", "\n", "So, I resorted to using the program gedit:\n", "sudo gedit myenvvars.sh\n", "\n", "This opens the gedit visual text editor. Added these three lines to make the script file:\n", "!#/bin/bash\n", "export PATH=$PATH:/media/B0FE4B1FFE4ADD6A/BioinformaticsTools/ncbi-blast-2.2.29+/bin:\n", "export BLASTDB=/media/B0FE4B1FFE4ADD6A/BioinformaticsTools/ncbi-blast-2.2.29+/dbs\n", "\n", "Probably have to restart the Terminal or even the computer to have these changes be implemented. Try just restarting Terminal first." ] }, { "cell_type": "code", "collapsed": false, "input": [ "#see if BLAST is listed in PATH\n", "!echo $PATH" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games\r\n" ] } ], "prompt_number": 3 }, { "cell_type": "raw", "metadata": {}, "source": [ "Not listed. Will restart computer. BRB..." ] }, { "cell_type": "code", "collapsed": false, "input": [ "#see if BLAST is listed in PATH after computer restart\n", "!echo $PATH" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/media/B0FE4B1FFE4ADD6A/BioinformaticsTools/ncbi-blast-2.2.29+/bin:\r\n" ] } ], "prompt_number": 1 }, { "cell_type": "raw", "metadata": {}, "source": [ "Cool! Restarting worked! Let's just do a quick BLAST check." ] }, { "cell_type": "code", "collapsed": false, "input": [ "!blastn -h" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "/bin/sh: 1: blastn: Permission denied\r\n" ] } ], "prompt_number": 2 }, { "cell_type": "code", "collapsed": false, "input": [ "!blastn --help" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "/bin/sh: 1: blastn: Permission denied\r\n" ] } ], "prompt_number": 3 }, { "cell_type": "code", "collapsed": false, "input": [ "!blastn -help" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "/bin/sh: 1: blastn: Permission denied\r\n" ] } ], "prompt_number": 4 }, { "cell_type": "code", "collapsed": false, "input": [ "#let's check permissions of the BLAST folder\n", "ls -ld /media/B0FE4B1FFE4ADD6A/BioinformaticsTools/ncbi-blast-2.2.29+/bin" ], "language": "python", "metadata": {}, "outputs": [ { "ename": "SyntaxError", "evalue": "invalid syntax (, line 2)", "output_type": "pyerr", "traceback": [ "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m2\u001b[0m\n\u001b[0;31m ls -ld /media/B0FE4B1FFE4ADD6A/BioinformaticsTools/ncbi-blast-2.2.29+/bin\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n" ] } ], "prompt_number": 5 }, { "cell_type": "code", "collapsed": false, "input": [ "!ls -ld /media/B0FE4B1FFE4ADD6A/BioinformaticsTools/ncbi-blast-2.2.29+/bin" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "drwx------ 1 samb samb 4096 Dec 10 12:20 /media/B0FE4B1FFE4ADD6A/BioinformaticsTools/ncbi-blast-2.2.29+/bin\r\n" ] } ], "prompt_number": 6 }, { "cell_type": "raw", "metadata": {}, "source": [ "Well, this is discouraging. Tried running blast in just the Terminal. Typing \"blastn\" simply printed\n", "out the PATH to the blast folder. At the end of that output there was a colon; removed that colon from \n", "myenvvars.sh file using gedit. Restarting computer." ] }, { "cell_type": "code", "collapsed": false, "input": [ "#check the PATH again\n", "!echo $PATH" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/media/B0FE4B1FFE4ADD6A/BioinformaticsTools/ncbi-blast-2.2.29+/bin\r\n" ] } ], "prompt_number": 1 }, { "cell_type": "code", "collapsed": false, "input": [ "#try blast again\n", "!blastn -help" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "/bin/sh: 1: blastn: Permission denied\r\n" ] } ], "prompt_number": 2 }, { "cell_type": "raw", "metadata": {}, "source": [ "Well, I think this is an issue of trying to use the Windows partition (which is the larger of the two partitions;\n", "thus why I want to have blast and its databases stored there). Guess I'll have to move blast to the Linux partition." ] }, { "cell_type": "code", "collapsed": false, "input": [ "#moving (mv) blast folder to Linux partition, using the verbose (-v) argument\n", "mv -v /media/B0FE4B1FFE4ADD6A/BioinformaticsTools/ncbi-blast-2.2.29+ /home/samb" ], "language": "python", "metadata": {}, "outputs": [ { "ename": "SyntaxError", "evalue": "invalid syntax (, line 2)", "output_type": "pyerr", "traceback": [ "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m2\u001b[0m\n\u001b[0;31m mv -v /media/B0FE4B1FFE4ADD6A/BioinformaticsTools/ncbi-blast-2.2.29+ /home/samb\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n" ] } ], "prompt_number": 3 }, { "cell_type": "code", "collapsed": false, "input": [ "#forgot the stupid \"!\" needed in IPython\n", "!mv -v /media/B0FE4B1FFE4ADD6A/BioinformaticsTools/ncbi-blast-2.2.29+ /home/samb/BioinformaticsTools" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "mv: cannot stat \u2018/media/B0FE4B1FFE4ADD6A/BioinformaticsTools/ncbi-blast-2.2.29+\u2019: No such file or directory\r\n" ] } ], "prompt_number": 6 }, { "cell_type": "raw", "metadata": {}, "source": [ "Whoops! I HAD moved the blast folder to the \"/home/samb\" directory, but should've moved it\n", "to the BioinformaticsTools folder, but forgot. Then, I edited the above line and that's why the\n", "error message is spit out. Manually moved the blast folder from \"/home/samb\" to \"/home/samb/BioinformaticsTools\"" ] }, { "cell_type": "raw", "metadata": {}, "source": [ "Change the PATH in the myenvvars.sh file using gedit. Need to restart computer for changes to take effect." ] }, { "cell_type": "code", "collapsed": false, "input": [ "#check new PATH\n", "!echo $PATH" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/samb/BioinformaticsTools/ncbi-blast-2.2.29+/bin\r\n" ] } ], "prompt_number": 1 }, { "cell_type": "raw", "metadata": {}, "source": [ "Looks good. Let's see if we can get a quick BLAST command to run." ] }, { "cell_type": "code", "collapsed": false, "input": [ "!blastn -h" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "/bin/sh: 1: blastn: Permission denied\r\n" ] } ], "prompt_number": 2 }, { "cell_type": "raw", "metadata": {}, "source": [ "Well, this blows. Going to just try reinstalling BLAST, but in this directory. \n", "Maybe problem is that you can't just move the BLAST directory?" ] }, { "cell_type": "code", "collapsed": false, "input": [ "#testing \"fresh\" install of BLAST package on Linux partition\n", "!blastn -h" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "USAGE\r\n", " blastn [-h] [-help] [-import_search_strategy filename]\r\n", " [-export_search_strategy filename] [-task task_name] [-db database_name]\r\n", " [-dbsize num_letters] [-gilist filename] [-seqidlist filename]\r\n", " [-negative_gilist filename] [-entrez_query entrez_query]\r\n", " [-db_soft_mask filtering_algorithm] [-db_hard_mask filtering_algorithm]\r\n", " [-subject subject_input_file] [-subject_loc range] [-query input_file]\r\n", " [-out output_file] [-evalue evalue] [-word_size int_value]\r\n", " [-gapopen open_penalty] [-gapextend extend_penalty]\r\n", " [-perc_identity float_value] [-xdrop_ungap float_value]\r\n", " [-xdrop_gap float_value] [-xdrop_gap_final float_value]\r\n", " [-searchsp int_value] [-max_hsps int_value] [-sum_statistics]\r\n", " [-penalty penalty] [-reward reward] [-no_greedy]\r\n", " [-min_raw_gapped_score int_value] [-template_type type]\r\n", " [-template_length int_value] [-dust DUST_options]\r\n", " [-filtering_db filtering_database]\r\n", " [-window_masker_taxid window_masker_taxid]\r\n", " [-window_masker_db window_masker_db] [-soft_masking soft_masking]\r\n", " [-ungapped] [-culling_limit int_value] [-best_hit_overhang float_value]\r\n", " [-best_hit_score_edge float_value] [-window_size int_value]\r\n", " [-off_diagonal_range int_value] [-use_index boolean] [-index_name string]\r\n", " [-lcase_masking] [-query_loc range] [-strand strand] [-parse_deflines]\r\n", " [-outfmt format] [-show_gis] [-num_descriptions int_value]\r\n", " [-num_alignments int_value] [-html] [-max_target_seqs num_sequences]\r\n", " [-num_threads int_value] [-remote] [-version]\r\n", "\r\n", "DESCRIPTION\r\n", " Nucleotide-Nucleotide BLAST 2.2.29+\r\n", "\r\n", "Use '-help' to print detailed descriptions of command line arguments\r\n" ] } ], "prompt_number": 1 }, { "cell_type": "raw", "metadata": {}, "source": [ "Yes! FINALLY! It works. Looks like BLAST package needs to be installed in the desired directory for it to function properly; can't simply move files to a new location after an initial install. Now, let's try an actual BLAST to see if the database directory works, too." ] }, { "cell_type": "code", "collapsed": false, "input": [ "!blastn -task blastn -query /home/samb/BioinformaticsTools/ncbi-blast-2.2.29+/queries/AllAbDenovo7118contigs.fa -db RickettsiaGBnt20140228 -outfmt 6 -max_target_seqs 1 -num_threads 16 -out /home/samb/BioinformaticsTools/ncbi-blast-2.2.29+/outputs/test.txt" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "BLAST Database error: No alias or index file found for nucleotide database [RickettsiaGBnt20140228] in search path [/media/B0FE4B1FFE4ADD6A/Users/Samb/Dropbox/Lab/IPython_nbs/Sam::]\r\n" ] } ], "prompt_number": 1 }, { "cell_type": "code", "collapsed": false, "input": [ "#hadn't restarted the computer since I changed the \"myenvvars.sh\" file to reflect update db location\n", "#let's try again\n", "!blastn -task blastn -query /home/samb/BioinformaticsTools/ncbi-blast-2.2.29+/queries/AllAbDenovo7118contigs.fa -db RickettsiaGBnt20140228 -outfmt 6 -max_target_seqs 1 -num_threads 16 -out /home/samb/BioinformaticsTools/ncbi-blast-2.2.29+/outputs/test.txt" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "BLAST Database error: No alias or index file found for nucleotide database [RickettsiaGBnt20140228] in search path [/media/B0FE4B1FFE4ADD6A/Users/Samb/Dropbox/Lab/IPython_nbs/Sam::]\r\n" ] } ], "prompt_number": 1 }, { "cell_type": "raw", "metadata": {}, "source": [ "Wait, I didn't read the error message correctly. It's searching in the IPython Notebook directory? That's weird. Time for more troubleshooting.\n", "OK, I think I fixed it. It turns out that the \"myenvvars.sh\" file was lacking the \"export\" command for the BLASTDB variable/location. Will restart\n", "computer and try again." ] }, { "cell_type": "code", "collapsed": false, "input": [ "#Another try with the \"myenvvars.sh\" file fixed\n", "!blastn -task blastn -query /home/samb/BioinformaticsTools/ncbi-blast-2.2.29+/queries/AllAbDenovo7118contigs.fa -db RickettsiaGBnt20140228 -outfmt 6 -max_target_seqs 1 -num_threads 16 -out /home/samb/BioinformaticsTools/ncbi-blast-2.2.29+/outputs/test.txt" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 1 }, { "cell_type": "raw", "metadata": {}, "source": [ "Sweet! That worked; we're all set! Now, want to try using the \"time\" command with this, just for fun. The \"time\" command should\n", "tell me how long it takes for a task to run." ] }, { "cell_type": "code", "collapsed": false, "input": [ "!time blastn -task blastn -query /home/samb/BioinformaticsTools/ncbi-blast-2.2.29+/queries/AllAbDenovo7118contigs.fa -db RickettsiaGBnt20140228 -outfmt 6 -max_target_seqs 1 -num_threads 16 -out /home/samb/BioinformaticsTools/ncbi-blast-2.2.29+/outputs/test.txt" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "1863.92user 9.40system 8:00.18elapsed 390%CPU (0avgtext+0avgdata 448928maxresident)k\r\n", "0inputs+1720outputs (0major+7522623minor)pagefaults 0swaps\r\n" ] } ], "prompt_number": 2 }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] } ], "metadata": {} } ] }