---
title: "Installing PECAN on Emu"
output: html_notebook
---

I'm going to try something new. Instead of having the script actively run install commands, I'm just going to add comments that show the commands called. This should save some time as I won't have to be reinstalling things multiple times as errors crop up and I'm not sure how interesting hundreds of lines of install output really are. It should be as simple as uncommenting the code and running on your own machine, if you feel like it.

Feel free to let me know if you like/don't like this approach. If I come across interesting errors, or things that should be noted, I'll do my best to render them in the notebook.

Also, I may have neglected to mention, since I'm doing this in R Notebook, any non-R command (bash call, etc.) is wrapped in system(), which is just an R command that invokes the system command contained inside. If you want to do this in something other than R, just strip the system() from the command, and all will work!

On with the show! Today we're installing PECAN, a mass spec analysis tool from https://bitbucket.org/maccosslab/pecan

First I have to install pip on Emu, as the default installation of Python doesn't have this, also I install cmake for building the percolator program. 

Then I install NumPY, percolator, and pymzml as required by the PECAN package via pip.

```{r}
#setwd(~/home/shared/pecan/)

#system("sudo apt-get install python-pip"")
#system("sudo apt-get install cmake")

#system("sudo pip install numpy")
#system("sudo pip install pymzml")


```
Building perclolator from source failed due to some oddities with the Ubuntu builder, specifically it creates directories and then references them incorrectly. I ended up going with plan b, which is downloading the pre-compiled binaries and installing that way which was sucessful in the end. It required converting the .rpm file to a .deb file, using the Alien package.

Note the file name changes between the alien and dpkg commands. 

```{r}
#system("wget https://sourceforge.net/projects/percolator/files/latest/download -O percolator-noxml-v2-06-linux-x86_64.rpm ")

#system("sudo apt-get install alien dpkg-dev debhelper build-essential")

#system("sudo alien percolator-noxml-v2-06-linux-x86_64.rpm")

#system("sudo dpkg -i percolator-noxml_2.06.0-2_amd64.deb")


```

Hooray, dependencies installed!

Now to install PECAN itself.

```{r}

#system("wget https://bitbucket.org/maccosslab/pecan/get/31750509f5c4.zip")
#system("unzip 31750509f5c4.zip")
#system("cd maccosslab-pecan-31750509f5c4")
#system("sudo python setup.py install")

```

According to the Pecan Tutorial we also need to install the Grid Scheduler.

```{r}
#system("wget https://sourceforge.net/projects/gridscheduler/files/SGE6.2u5p2/SGE6.2u5p2.tar.gz/download -O SGE6.2u5p2.tar.gz")
```

Delving in to the instructions for Grid Scheduler I found we need to install BerkleyDB found at www.sleepycat.com (A redirect to an Oracle website). This required a login/password to download, so the download won't be directly documented here.

Installing BerkleyDB- takes a while, but straight forward. 
```{r}

#system("tar -xzf db-6.2.23.tar.gz")
#system("cd db-6.2.23.tar.gz/build_unix")
#system("sudo ../dist/configure")
#system("sudo make")
#system("sudo make install")

```

Installing GridEngine Scheduler- Much easier, done through apt-get

```{r}
#system("sudo apt-get install gridengine-client gridengine-common gridengine-master gridengine-qmon")
```

A quick test. It gives us an error, but it's an error associated with a missing yeast proteome, so that hopefully indicates a succesful install! Pecan doesn't provide test data which is a bummer.

```{r}
system("pecanpie")
```
