Friday, 22 April 2016

Using package manager Homebrew (Mac OSX) for science / computational biology


I am using Mac OSX on a daily use for many reasons.

One reasons is that you can use the classical tools from the Windows world (Microsoft Office, Endnote) that don't exist on Linux. It is important to me as many of my external collaborators are using Windows, so it can be problematic when sharing documents. I don't exclude that I would shift one day to Linux.

The second reason, and I think it was one of the best strategy from Apple, was the transition to Unix in 2001. This greatly improved the compatibility and access to tons of scientific softwares. The installation of unix tools from source is usually done by the classical "./configure; make; sudo make install".

Hopefully, package managers exist to avoid this task, and to keep the system tidy, especially with library dependencies. At the very beginning, when I started my PhD in 2005, I was using Fink. I then switched to MacPort. Last year, I encountered some problems with MacPort and some versions of GCC. Everything was messy and I decided, as I switched to El Capitan from 10.8, to move to Homebrew. So I remove my MacPort installation and installed HomeBrew. And Homebrew is really great!

(Shaun Jackman told me on Twitter that he is maintaining the linux fork of Homebrew, available here: http://linuxbrew.sh/ )



Some reasons I like it:
  • Very easy to use.
  • No need to use super-user, as it installs in the user directory.
  • It tries to use already libraries if possible.
  • There is one way for unix-style software and one way for .dmg package (cask).

To install it, you need:
  • MacOSX 10.9 ou +
  •  Xcode (the most recent). [NB: Xcode is not needed anymore. Save a lot of space!]
  • Command Line Tools (Install with command: xcode-select --install)

You can install Homebrew from there:  http://brew.sh/

You just need this command, and homebrew will auto-install itself:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"


Then it is very easy to use in the Terminal. For example, if your are interested to install "Gimp":

brew search gimp => search for packages that contains the word "gimp".

brew info gimp => describe gimp package, and which dependencies are needed.

brew install gimp => install gimp.

brew list => show everything installed on your computer.


There are other sections in homebrew. For exemple, a category specific to games, or a category specific to science. To include those directly on your homebrew, you can tap them:

brew tap homebrew/games
brew tap homebrew/science

Now, you can install CodeML / PAML:
brew install paml


For example, here is what I have installed from the science category:

brew leaves | grep "science"

homebrew/science/bowtie
homebrew/science/bowtie2
homebrew/science/cd-hit
homebrew/science/clustal-omega
homebrew/science/cytoscape
homebrew/science/dssp
homebrew/science/emboss
homebrew/science/express
homebrew/science/fastml
homebrew/science/fasttree
homebrew/science/gromacs
homebrew/science/hyphy
homebrew/science/mcl
homebrew/science/mrbayes
homebrew/science/muscle
homebrew/science/newick-utils
homebrew/science/paml
homebrew/science/phylip
homebrew/science/phyml
homebrew/science/prank
homebrew/science/pymol
homebrew/science/raxml
homebrew/science/repeatmasker
homebrew/science/rstudio-server
homebrew/science/samtools
homebrew/science/sratoolkit
homebrew/science/trimal
homebrew/science/velvet
homebrew/science/weblogo
homebrew/science/xmgredit

You will recognise many useful tools. Nice, isn't it?



However, there are still some tools that cannot be installed with Homebrew:


brew search biopython => No formula found for "biopython".
brew search jalview => No formula found for "jalview".
brew search pagan => No formula found for "pagan".
brew search njplot => No formula found for "njplot".
brew search netphorest => No formula found for "netphorest".
brew search vmd => not the one I search for. :/

(I will update this list once I installed them)




There is also the CASKROOM, which contains other packages, such as .dmg packages.

https://caskroom.github.io/

Same, you can merge with homebrew:
brew tap caskroom/cask

For example, to install Firefox:

brew cask install --force figtree
=> it will install Firefox in your and create a shortcut in /Users/yourname/Applications

If you want to install in /Applications:
brew cask install --appdir="/Applications" --force figtree

=> it will force the creation of the shortcut to /Applications. But I prefer to install in my own Applications folder, it is cleaner.


Here is my short list:

brew cask list | sort
android-file-transfer
arduino
audacity
avogadro
cathode
dosbox
dropbox
emacs
figtree
filezilla
firefox
gimp
google-earth
grandperspective
handbrake
hex-fiend
java
kid3
kompozer
libreoffice
mplayer-osx-extended
rstudio
scribus
silverlight
skim
skype
slack
teamviewer
thunderbird
unetbootin
unrarx
vlc
vox




Maintenance:

It is easy to maintain and update all your package (except the ones from CASK, I don't know why)

brew doctor => check that everything is ok. It can display lot of warnings, especially if you previously installed programs by hand.

brew update => update your package list definition.

brew upgrade =>  upgrade all your outdated packages

brew upgrade $FORMULA => upgrade only the specific formula (i.e. mrbayes).

brew cleanup
brew cask cleanup

You can run the maintenance in one line:
brew update; brew upgrade; brew cleanup; brew cask cleanup




For the packages from CASK, here is how I update them (with the --force option):

brew cask install --force --srgb --with-cocoa emacs

brew cask install --force java
brew cask install --force arduino
brew cask install --force avogadro
brew cask install --force bittorrent
brew cask install --force cathode
brew cask install --force figtree
brew cask install --force filezilla
brew cask install --force gimp
brew cask install --force grandperspective
brew cask install --force google-earth
brew cask install --force handbrake
brew cask install --force kompozer
brew cask install --force kid3
brew cask install --force mplayer-osx-extended
brew cask install --force rstudio
brew cask install --force scribus
brew cask install --force silverlight
brew cask install --force slack
brew cask install --force teamviewer
brew cask install --force thunderbird
brew cask install --force unetbootin
brew cask install --force unrarx
brew cask install --force vlc
brew cask install --force vox

brew cask install --force --appdir="/Applications" firefox
brew cask install --force --appdir="/Applications" libreoffice
brew cask install --force --appdir="/Applications" skype


You can also do it in one line like this:
brew cask list | xargs brew cask install --force


That's it!

I strongly recommend to use Homebrew, especially if you start from a fresh system. Homebrew community is very active and new packages are put every weeks.


Romain


PS: other interesting blog posts:

No comments:

Post a Comment