Setting up Windows and Linux

To take advantage of certain sections of the book, Windows users will need to install some programs that are not included by default.

This page is a brief introduction to the prerequisites. It supersedes the Cygwin info in the Appendix I of the book.

The problem:
Most of the principles and practices can be applied in a Windows environment as well, but the specifics of how you carry out those actions (setting up your computer to run programs from within a data directory) will differ. We can only explain so many mouse-clicks in the text...

A few chapters on using a unix shell will be unavailable to you without installing some additional software. These skills are not just important for the direct processing that you can do, but because they allow you to operate when connected remotely to a server, as is sometimes required by research.

There are two options for setting up a Unix system. One option is to install a UNIX system that can run within Windows called MSYS2. A single installer program provides the environment, and then you can the pacman installer to add other programs from within that environment.

A second option is to do a Linux installation in a Virtual Machine on your computer. This is a bit more involved, requires more disk space and processor power, and it is also a bit more difficult to access your normal Windows files from within the virtual environment. However you will be able to run a full-fledged Linux installation and any associated Linux graphical programs, all within a sub-window of your normal Windows environment.

The specifics:
A. TEXT EDITORS

1. Instead of TextWrangler, you can use Notepad++ or Sublime Text, among others.
2. If you have a favorite text editor already, make sure it supports:
a. Regular Expressions (in the Find/Replace dialog)
b. Syntax highlighting (color-coding special words within scripts)

B. THE SHELL ENVIRONMENT

There are a few options for setting up a command-line environment on your Windows machine for use in the course.

# download MSYS2 (Arch Linux)
https://msys2.github.io/
# Choose the version that says x86_64, not i686
 
# Update system
pacman --needed -Sy bash pacman pacman-mirrors msys2-runtime
 
# Restart MSYS 
# (Close all windows and reopen from start menu)
# All Programs > MSYS2 64-bit > MSYS Shell
 
pacman -Su
 
# You might get some errors. If so, just run the command again and it should pick up the slack.
 
#install python and other utilities
# REQUIRED
pacman --noconfirm -S  gcc python2 man nano sqlite vim git bc tar 
 
# This can take a while to download
 
# Note: To search for other package locations, use
 
    pacman -Ss <package_name>
 
Then to install, copy the name (before the version number) after a pacman -Sy command...
 
 
# issues: sudo and screen not there in default pacman...
 
# NEXT you should do these commands:
cd /usr/bin
ln -sf python2 python
cd
 
# Then install pip using these steps:
 
mkdir ~/scripts
cd ~/scripts
curl -O 'https://bootstrap.pypa.io/get-pip.py'
./get-pip.py
 
# If that succeeds (which pip should now find something)
then..
 
  rm get-pip.py
 
# Now to use the installer for grabbing python packages like numpy, Biopython, and beautifulSoup:
 
   pip install numpy
 
##########################
Working in MSYS2
 
Your home directory, as we refer to it in the book, will be /home/lucy in the terminal window, but it lives in the c:\msys32 (or msys64) folder. You could make a shortcut from the folder here with our username to the Windows desktop for easy cross-platform access.
 
# MSYS2 starts with an annoying multi-line prompt, so edit your .bash_profile using this command
 
    nano ~/.bash_profile
 
# Note that <ctrl>C will not work for copying in the terminal, because it has another function.
# Right click to copy/paste from the pop-up menu
 
# Add the following four lines to your .bash_profile
 
PS1='\[\e[1;32m\]\u:\[\e[1;36m\]\w \$ \e[0m'
export PATH=$PATH:$HOME/scripts
export EDITOR=/usr/bin/nano
set -o noclobber
 
################################
 
Next, in Windows, install the GUI
Install <a href="http://www.sublimetext.com/3">Sublime Text 3</a>
 
After installation, Change color scheme to iPlastic
 
To get the command-line option (so you can edit files from the terminal by typing 'subl' google the page about changing your System Path to work with Sublime Text 3.
##############################

2. For a full unix environment running alongside windows, install a Virtual Box and then install Ubuntu Linux into that environment. Further instructions on this process are on the ubuntu site and in Appendix I.

When using this option, you will already have python installed as part of Ubuntu, and will just have to choose a text editor. You can try jEdit or Sublime Text. jEdit can be added from within the Applications menu of the Linux environment and Sublime Text from the web.

If you use gEdit, you will want to also install the developer plug-ins.

If you use Ubuntu, you will need to install the program curl separately.
Open a terminal window (the black rectangle in the upper menu bar) and type:
sudo apt-get install curl
It will ask for your password.

Setting the PATH
For Ubuntu, instead of editing ~/.bash_profile, as directed in the book,
you should edit ~/.bashrc and add your startup commands and aliases there.

Shared Folders
The hardest part of this process is getting shared folders between your Windows
system and the Ubuntu part of the operation.

a. Install Guest Additions with the instructions here
b. Restart the VirtualBox
c. Create or identify a data folder on the windows side that you want to share
(named with no dashes or spaces). Let's call it PCFBShared.
d. Open a terminal window, and if you don't have one already create a folder on
the ubuntu side. We'll call it shared:
mkdir ~/shared
e. Set the Windows folder as a permanent shared folder inside the VirtualBox app
using the Devices... Shared folder menu.
f. You should be able to restart the Virtual Box at this point and have your
shared folder show up.
g. To make this change permanent, you can have the system "type" it each time you log in.
Edit your start-up settings file in the terminal window by typing:
sudo nano /etc/rc.local
h. Add the bold command below to the end of that file, above exit.
mount -o uid=1000,gid=1000 -t vboxsf PCFBShared /home/lucy/shared
(where /home/lucy/shared is the path you get if you type 'pwd' from the ubuntu shared folder).
i. The official VirtualBox manual is bundled with the installer and
is also available here.

C. PYTHON PROGRAMMING LANGUAGE

This will be installed if you use the VirtualBox/Ubuntu option or cygwin
options above. You will interact with python mainly from within the command
line (terminal/unix) environment. If you want to try Python programming
within Windows directly, you can download the installer here, but you may have difficulties accessing your data files in the same ways that are
discussed in the book.