In [1]:
#change to the etc/profile.d directory
#have to use "//" before "etc"; first "/" moves up to the "/root" directory
#second slash moves down to the "etc" directory
cd //etc/profile.d
/etc/profile.d
In [2]:
#write BLAST program directory to new scipt file
!echo '#!/bin/bash' > myenvvars.sh
/bin/sh: 1: cannot create myenvvars.sh: Permission denied
In [3]:
#check permissions of directory
ls -ld
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-3-1c01af6a0009> in <module>()
      1 #check permissions of directory
----> 2 ls -ld

NameError: name 'ls' is not defined
In [4]:
!ls -ld
drwxr-xr-x 2 root root 4096 Oct 16 12:02 .
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. Be right back; going to Terminal to do this. Ran this command in Terminal: [email protected]://etc/profile.d$ sudo chmod -R 775 /etc/profile.d
In [6]:
#check directory permissions now
!ls -ld
drwxrwxr-x 2 root root 4096 Oct 16 12:02 .
In [8]:
#let's try making and writing to the script file again
!echo '#!/bin/bash' > myenvvars.sh
/bin/sh: 1: cannot create myenvvars.sh: Permission denied
After Googling, changed permissions back to 755 using: [email protected]://etc/profile.d$ sudo chmod -R 755 /etc/profile.d
In [9]:
!ls -ld
drwxr-xr-x 2 root root 4096 Mar  7 16:57 .
Created file called "myenvvars.sh" using: [email protected]://etc/profile.d$ sudo touch myenvvars.sh
In [10]:
!ls
bash_completion.sh  myenvvars.sh  vte.sh
Couldn't figure out how to write to the file using Terminal; permission denied on all my various attempts. Tried each of these: sudo cat '#!/bin/bash' > myenvvars.sh sudo echo '#!/bin/bash' > myenvvars.sh sudo '#!/bin/bash' > myenvvars.sh Got this output from all of them: bash: myenvvars.sh: Permission denied So, I resorted to using the program gedit: sudo gedit myenvvars.sh This opens the gedit visual text editor. Added these three lines to make the script file: !#/bin/bash export PATH=$PATH:/media/B0FE4B1FFE4ADD6A/BioinformaticsTools/ncbi-blast-2.2.29+/bin: export BLASTDB=/media/B0FE4B1FFE4ADD6A/BioinformaticsTools/ncbi-blast-2.2.29+/dbs Probably have to restart the Terminal or even the computer to have these changes be implemented. Try just restarting Terminal first.
In [3]:
#see if BLAST is listed in PATH
!echo $PATH
/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
Not listed. Will restart computer. BRB...
In [1]:
#see if BLAST is listed in PATH after computer restart
!echo $PATH
/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:
Cool! Restarting worked! Let's just do a quick BLAST check.
In [2]:
!blastn -h
/bin/sh: 1: blastn: Permission denied
In [3]:
!blastn --help
/bin/sh: 1: blastn: Permission denied
In [4]:
!blastn -help
/bin/sh: 1: blastn: Permission denied
In [5]:
#let's check permissions of the BLAST folder
ls -ld /media/B0FE4B1FFE4ADD6A/BioinformaticsTools/ncbi-blast-2.2.29+/bin
  File "<ipython-input-5-10d9a82f3d19>", line 2
    ls -ld /media/B0FE4B1FFE4ADD6A/BioinformaticsTools/ncbi-blast-2.2.29+/bin
                                                                       ^
SyntaxError: invalid syntax
In [6]:
!ls -ld /media/B0FE4B1FFE4ADD6A/BioinformaticsTools/ncbi-blast-2.2.29+/bin
drwx------ 1 samb samb 4096 Dec 10 12:20 /media/B0FE4B1FFE4ADD6A/BioinformaticsTools/ncbi-blast-2.2.29+/bin
Well, this is discouraging. Tried running blast in just the Terminal. Typing "blastn" simply printed out the PATH to the blast folder. At the end of that output there was a colon; removed that colon from myenvvars.sh file using gedit. Restarting computer.
In [1]:
#check the PATH again
!echo $PATH
/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
In [2]:
#try blast again
!blastn -help
/bin/sh: 1: blastn: Permission denied
Well, I think this is an issue of trying to use the Windows partition (which is the larger of the two partitions; thus why I want to have blast and its databases stored there). Guess I'll have to move blast to the Linux partition.
In [3]:
#moving (mv) blast folder to Linux partition, using the verbose (-v) argument
mv -v /media/B0FE4B1FFE4ADD6A/BioinformaticsTools/ncbi-blast-2.2.29+ /home/samb
  File "<ipython-input-3-2ca7b6c926a7>", line 2
    mv -v /media/B0FE4B1FFE4ADD6A/BioinformaticsTools/ncbi-blast-2.2.29+ /home/samb
                                                                      ^
SyntaxError: invalid syntax
In [6]:
#forgot the stupid "!" needed in IPython
!mv -v /media/B0FE4B1FFE4ADD6A/BioinformaticsTools/ncbi-blast-2.2.29+ /home/samb/BioinformaticsTools
mv: cannot stat ‘/media/B0FE4B1FFE4ADD6A/BioinformaticsTools/ncbi-blast-2.2.29+’: No such file or directory
Whoops! I HAD moved the blast folder to the "/home/samb" directory, but should've moved it to the BioinformaticsTools folder, but forgot. Then, I edited the above line and that's why the error message is spit out. Manually moved the blast folder from "/home/samb" to "/home/samb/BioinformaticsTools"Change the PATH in the myenvvars.sh file using gedit. Need to restart computer for changes to take effect.
In [1]:
#check new PATH
!echo $PATH
/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
Looks good. Let's see if we can get a quick BLAST command to run.
In [2]:
!blastn -h
/bin/sh: 1: blastn: Permission denied
Well, this blows. Going to just try reinstalling BLAST, but in this directory. Maybe problem is that you can't just move the BLAST directory?
In [1]:
#testing "fresh" install of BLAST package on Linux partition
!blastn -h
USAGE
  blastn [-h] [-help] [-import_search_strategy filename]
    [-export_search_strategy filename] [-task task_name] [-db database_name]
    [-dbsize num_letters] [-gilist filename] [-seqidlist filename]
    [-negative_gilist filename] [-entrez_query entrez_query]
    [-db_soft_mask filtering_algorithm] [-db_hard_mask filtering_algorithm]
    [-subject subject_input_file] [-subject_loc range] [-query input_file]
    [-out output_file] [-evalue evalue] [-word_size int_value]
    [-gapopen open_penalty] [-gapextend extend_penalty]
    [-perc_identity float_value] [-xdrop_ungap float_value]
    [-xdrop_gap float_value] [-xdrop_gap_final float_value]
    [-searchsp int_value] [-max_hsps int_value] [-sum_statistics]
    [-penalty penalty] [-reward reward] [-no_greedy]
    [-min_raw_gapped_score int_value] [-template_type type]
    [-template_length int_value] [-dust DUST_options]
    [-filtering_db filtering_database]
    [-window_masker_taxid window_masker_taxid]
    [-window_masker_db window_masker_db] [-soft_masking soft_masking]
    [-ungapped] [-culling_limit int_value] [-best_hit_overhang float_value]
    [-best_hit_score_edge float_value] [-window_size int_value]
    [-off_diagonal_range int_value] [-use_index boolean] [-index_name string]
    [-lcase_masking] [-query_loc range] [-strand strand] [-parse_deflines]
    [-outfmt format] [-show_gis] [-num_descriptions int_value]
    [-num_alignments int_value] [-html] [-max_target_seqs num_sequences]
    [-num_threads int_value] [-remote] [-version]

DESCRIPTION
   Nucleotide-Nucleotide BLAST 2.2.29+

Use '-help' to print detailed descriptions of command line arguments
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.
In [1]:
!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
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::]
In [1]:
#hadn't restarted the computer since I changed the "myenvvars.sh" file to reflect update db location
#let's try again
!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
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::]
Wait, I didn't read the error message correctly. It's searching in the IPython Notebook directory? That's weird. Time for more troubleshooting. 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 computer and try again.
In [1]:
#Another try with the "myenvvars.sh" file fixed
!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
Sweet! That worked; we're all set! Now, want to try using the "time" command with this, just for fun. The "time" command should tell me how long it takes for a task to run.
In [2]:
!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
1863.92user 9.40system 8:00.18elapsed 390%CPU (0avgtext+0avgdata 448928maxresident)k
0inputs+1720outputs (0major+7522623minor)pagefaults 0swaps