Home

You might wonder why I would write about compiling NCBI’s legacy blast. It’s discontinued, right? Well, yes. But:

  1. Some people still want to use it
  2. Other programs use it (well, psi-cd-hit requires it, I don’t know if anything else does)
  3. The precompiled one at NCBI is compiled at 32 bits (I want 64 damn it!)
  4. I am obsessive about compiling at -O3 optimization (at least)

So here’s how you accomplish this task:

(I’m assuming that you have Xcode and the command-line tools installed.)

The first thing is to download the software from NCBI (ncbi.tar.gz).

Done? OK. Now “untar it!”

The next steps require a bit of information. You will modify two files:

  1. ncbi/platform/darwin.ncbi.mk
  2. ncbi/make/makedis.csh

What we want to accomplish is avoid the compilation of GUI-based applications (like Entrez). reason being that those depend on things that Macs no longer support (Carbon), which is the same reason that legacy blast is available pre-compiled only at 32 bits. But we want command-line, and we want 64 bits. I also want -O3 optimization, but that one is up to you.

There’s many ways you can accomplish this, and here I will use one that doesn’t require you to use an editor. Just perl command-line runs.

So, to accomplish -O3 optimization, we can run:

% perl -i.bak -pe 's{-O2}{-O3}g; s{/home/coremake}{/usr/local}' ncbi/platform/darwin.ncbi.mk

The second substitution is just fixing the pathway expected for NCBI to the place where I put the ncbi thing after compiling. Seems useless (the programs run whether I change this or not). But, as I said, I’m somewhat obsessive, and this is a minor correction that makes me happy.

To accomplish the avoidance of GUI-based applications, we substitute every appearance of “HAVE_MAC=1” for “HAVE_MAC=0”.

% perl -i.bak -pe 's{HAVE_MAC=1}{HAVE_MAC=0}g; s{/Developer/Tools/}{}' ncbi/make/makedis.csh

The second substitution is just to avoid some warning by the end of the compilation, but it’s also inconsequential.

Finally you run:

% ./ncbi/make/makedis.csh

By the end, it will tell you that the whole compiled thing is at ncbi/build, but it’s also at ncbi/bin (and this one has just the compiled applications, while the stuff under “ncbi/build” has all kinds of intermediary and source files). You can move these applications wherever you want them to be.

Here’s a session as I would do it (The “diff” commands are here just to show what’s changed in the files by the perl command, and the “|& tail -[number]” to avoid showing all the output produced by the tar and the compilation commands. I also show that the files were compiled at 64 bits, and the list of programs compiled. Remember that my commands follow the “%” prompt. Anything else is output):

% wget ftp://ftp.ncbi.nlm.nih.gov/blast/executables/release/2.2.26/ncbi.tar.gz
--2015-06-30 08:55:13--  ftp://ftp.ncbi.nlm.nih.gov/blast/executables/release/2.2.26/ncbi.tar.gz
           => ‘ncbi.tar.gz’
Resolving ftp.ncbi.nlm.nih.gov... 130.14.250.10, 2607:f220:41e:250::10
Connecting to ftp.ncbi.nlm.nih.gov|130.14.250.10|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD (1) /blast/executables/release/2.2.26 ... done.
==> SIZE ncbi.tar.gz ... 68691452
==> PASV ... done.    ==> RETR ncbi.tar.gz ... done.
Length: 68691452 (66M) (unauthoritative)

ncbi.tar.gz         100%[=====================>]  65.51M  2.74MB/s   in 28s    

2015-06-30 08:55:43 (2.38 MB/s) - ‘ncbi.tar.gz’ saved [68691452]

% tar zxvf ncbi.tar.gz |& tail -5
x ncbi/asnstat/asnmacro.h
x ncbi/lib/
x ncbi/include/
x ncbi/build/
x ncbi/bin/
% ls ncbi/bin/
% perl -i.bak -pe 's{-O2}{-O3}g; s{/home/coremake}{/usr/local}' ncbi/platform/darwin.ncbi.mk
% diff ncbi/platform/darwin.ncbi.mk ncbi/platform/darwin.ncbi.mk.bak 
15,21c15,21
< NCBI_LDFLAGS1 = -framework CoreServices -O3
< NCBI_OPTFLAG = -O3
< NCBI_BIN_MASTER = /usr/local/ncbi/bin
< NCBI_BIN_COPY = /usr/local/ncbi/bin
< NCBI_INCDIR = /usr/local/ncbi/include
< NCBI_LIBDIR = /usr/local/ncbi/lib
< NCBI_ALTLIB = /usr/local/ncbi/altlib
---
> NCBI_LDFLAGS1 = -framework CoreServices -O2
> NCBI_OPTFLAG = -O2
> NCBI_BIN_MASTER = /home/coremake/ncbi/bin
> NCBI_BIN_COPY = /home/coremake/ncbi/bin
> NCBI_INCDIR = /home/coremake/ncbi/include
> NCBI_LIBDIR = /home/coremake/ncbi/lib
> NCBI_ALTLIB = /home/coremake/ncbi/altlib
% perl -i.bak -pe 's{HAVE_MAC=1}{HAVE_MAC=0}g; s{/Developer/Tools/}{}' ncbi/make/makedis.csh
% diff ncbi/make/makedis.csh ncbi/make/makedis.csh.bak 
243c243
< 	set HAVE_MAC=0
---
> 	set HAVE_MAC=1
531c531
< 			Rez Carbon.r -o $i
---
> 			/Developer/Tools/Rez Carbon.r -o $i
% ./ncbi/make/makedis.csh |& tail -10
                   ~ ^~~~~
wblast2.c:3121:9: warning: implicit declaration of function 'BlastProgram2Number' is invalid in C99 [-Wimplicit-function-declaration]
        BlastProgram2Number(progname, &program_number);
        ^
26 warnings generated.
cc -pipe -o bl2bag.cgi -framework CoreServices -O3 -I../include  -L../lib  bl2bag.c -lncbi -lc
Put the date stamp to the file ../VERSION
*********************************************************
*The new binaries are located in ./ncbi/build/ directory*
*********************************************************
% file ncbi/bin/blastall 
ncbi/bin/blastall: Mach-O 64-bit executable x86_64
% file ncbi/bin/blastpgp 
ncbi/bin/blastpgp: Mach-O 64-bit executable x86_64
% ls ncbi/bin/
asn2ff           checksub         gene2xml         seedtop
asn2gb           copymat          getmesh          seqtest
asn2idx          debruijn         getpub           taxblast
asn2xml          demo_regexp      gil2bin          tbl2asn
asndhuff         demo_regexp_grep idfetch          test_regexp
asntool          dosimple         impala           testcore
bl2bag.cgi       entrcmd          indexpub         testobj
bl2seq           errhdr           makemat          testval
blastall         fa2htgs          makeset          vecscreen
blastcl3         fastacmd         megablast        wblast2.REAL
blastclust       findspl          ncbisort         wblast2_cs.REAL
blastpgp         formatdb         nph-viewgif.cgi
cdscan           formatrpsdb      rpsblast
% rm -rf ncbi/build
% sudo mv ncbi /usr/local/

The last command (sudo mv ncbi /usr/local/) moves the ncbi directory to the place I like it to be. It assumes that you don’t have an ncbi directory or file there already. If you do have such a thing, you should delete it before moving the newly compiled one there.

There you have it. Legacy BLAST compiled at 64 bits under Yosemite.

Enjoy!
-Gabo

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s