Welcome to Software Carpentry Etherpad!

This pad is synchronized as you type, so that everyone viewing this page sees the same text. This allows you to collaborate seamlessly on documents.

Use of this service is restricted to members of the Software Carpentry and Data Carpentry community; this is not for general purpose use (for that, try etherpad.wikimedia.org).

Users are expected to follow our code of conduct: http://software-carpentry.org/conduct.html

All content is publicly available under the Creative Commons Attribution License: https://creativecommons.org/licenses/by/4.0/

Software Carpentry Workshop - April 27th-28th 2017



Attendance (please add your name):
    Byron Smith (Instructor, <bsmith89@gmail.com>)
    Chris Gates (Instructor): cgates@umich.edu
    Abby Wicks WSU Biological Sciences
James Block Cancer Biology/ MD/PhD
    Chase Hellmer
    Kendall Muzzarelli
    Anna Boegehold
    John Butts
    Kiran Koya - wsu med school - surgery
    Corey Krabbenhoft - WSU Biological Sciences
    Nikita Deshpande - Dept of BIological Sciences
    Jonathan Greenberg- WSU SOM MIB PhD
    Stephen Barr
    Ben Kuiper
    Elisabeth Steel
    Cynthia Kalita
    Allison Mitchell -WSU SOM Cancer Biology Program
    Larry Grossman 
    Justyna Resztak (Center for Molecular Medicine and Genetics)
    Ashley Anderson - WSU Schol of Medicine Department of Microbiology, Immunology, and Biochemistry
    Bob Akins  SOM BMB
    Matt Fountain
    Patrick McLaughlin  (Department of Biological Sciences)
    Rayanne Burl - School of Medicine, Center for Molecular Medicine and Genetics
    Stephanie Gladyck
    Aya Attia - WSU med School - Center of medical genetics and genomics CMGG 
    Michael Salsaa
    Cristiano Petrini
    Rupali Gadkari
Andrew Winters
    Will Close
    Vanesa Ramseyer
    prasanna
    Neeraja Purandare


Day 1 (04.27.17) UNIX SHELL
See https://swcarpentry.github.io/shell-novice/ for lessons covered and additional resources


Instructions to setup data for Intro to Shell
-------------------------------------------------
Move the file to your Desktop and unzip it (usually you can just double click on the file and it will unzip)

Bash (good for more simple tasks)
$ is the prompt-after completing commmand, prompt returns 
cd means change directory essentially just clicking on folder
pwd means print working directory shows me where file is located
dashes after words or change in color indicate the word is a folder; no dash after word or no change in color means the word is a file
spacing is important they matter
can do multiple flags at once within one command
man means manual tells you what a command means and how to utilize it
use cd to move up within directory as well eg type cd followed by root path (path with slashes)
cd followed by .. means go to the directory before me so don't have to do so much typing 
~ represents /Users/ashleyanderson/ (the home folder) to get to it cd ~
if you start typing something and press tab, terminal will fill in the rest of command
hitting the up arrow reveals the last command entered continue to hit arrow will continure to get previous commands
. before words indicates special file (essentially a hidden file that has been revealed)
ls -l the l means long gives you more info about about files
clear after prompt clears all previous commands and responses
mkdir means make directory allows you to create a new folder/directory or file if you put .txt or something like that behind it
^ means hit control key
rm -r removes a directory and everything in that directory very dangerous tool
rm -r -i so that computer will check with you before it deletes stuff
mv allows you to change name of file/directory and move files into another directory
to open txt files from terminal type nano and name of txt file
cp means copy
to get out nano hit control X and hit enter
cd / also allows you to go up a level in directory like cd..
wc means word count if you want to just focus on line count do wc -l
* means everything in the folder (actually is a wild card-substitutes for anything computer attempts to give results by pattern matching
can * to find files with letters in common
control c is an undo stops everything stops what it's doing and returns your command prompt to you
cat is short for catenate and is a way printing contents of file
sort allows you to sort files in folder 
> is a way to move things eg sort -n -r length.txt > length.sorted.txt means you want to take the results of the sort and place them in a new file which comes after the synbol
to access pipe command hit shift and the straight down line with dash key
if you create a nano (text) file and write commands into it you can then in terminal type bash followed by the name of the file and you have just created a new command that you can use
history in command line gives all your previous commands history | tail gives you your last 10 commands

Python by way of jupyter (for complicated analysis or where you want to use code someone else has written)
in terminal typing python lets computer 
have to be in data folder you want to analyze and then type jupyter notebook on command line and jupyter web browser 
shift Enter and control Enter lead to completion of task 
can make python scripts like you would nano scripts by typing python then scriptname.py
when reading python start from top and move to bottom
type (word) identifies to you what type of object/number it is
python/jupyter uses 0 index meaning first item in list numbered 0
use square brackets to direct position in something, if you're trying to perform a function requires parentheses
to import functions/data packages from somewhere else type import followed by name of package
dir followed by name of package will tell you all functions in that function
once you have imported a package to utilize any of it's functions have to write package name.followed by the function name
to identify what line something is on in an input, hit escape followed by l
when renaming something have to remember to write new name in quotation marks eg ""
del is a way to delete objects froml lists; also splicing your list around the object you want to remove is another way to get rid of something
on kernel menu hit restart to completely clear definitions from variables that were assigned

Using python to analyze tabular data 
import pandas
csv stands for comma separated variables
. after a name of object indicates the name that comes after that period belongs to that object
.to_name allows you to save a file somewhere else
.ix means index and is a way to retrieve data from the table from whatever row/column the .ix follows; you follow this [row, colum] with rows and columns being numbers or words depending on what's in the table
== means equivalent to/equals
can pick and choose specific rows/columns data (data.continent == 'Africa', data.gdpPercap_1952 > 3000

Python Day 2
to recall/bring in data into particular package use command .read_(file type)
./ means within this directory I want follwed by file you want to open
index in python can be used as a noun to tell the computer how you want to organize your data; it can also be used a verb telling the computer you want to recall certain data by indexing by a certain column/row
%matplotlib inline results in a feature turning on that allows your plots to show up in your jupyter/python web browser
import matplotlib.pyplot as plt is way for you to import data and rename it at the same time
for blank in blank is way to create loops; indents are a way to create loops to break loop unindent; using range( ) before a loop tells the computer how many things you want
def means defining a function; parentheses surround  arguments; return tells computer that we want the answer of the function that follows it otherwise no value will be returned as an output for you to view
a single = means assignment; == means equivalent to you
!= means not equal to
can do if, if else, and else statements

Gitmo 
version control software (helpful for grad documents when keep creating multiple versions of document)
Git commands: git followed by
init means to initialize respository for where you want new document stored,
status shows the status of document/folder you're tracking changes for
add alllows files to be added to git for version control
commit allows you to write a note summarizing what you wrote and changes that have been made at this point in time
config --global followed by some aspect of under git control eg git config --global user.name "Ash And"
log allows you to view all revisions that have been made to document
reset allows you to change the current state of the repository to a previous state without changing the origninal file that began the repository
checkout allows you to change the current state of the repostiory to a different state and changes the original file that began the repository; checkout HEAD gives you the most recent saved file in your repository
can add/commit multiple files at same time
short hand form of commit: commit -m "commit message here" and press enter; another shorthand for committing: commit -m "commit message here" file.txt
latex is a text editor for writing papers and being able to access them with nano






re-launching terminal will bring it back to default
remove everything before the "$" type: PS1="$ "
ls = list to show what is in your current directory
ls –F = shows what is a directory and what is a file
Captialization matters (case sensitive); spacing is important as well
ls -G color codes directories 
for help on windows type: ls --help
cd .. allows you to move up one level in the directory
cd ~ sends you back to the home directory
to set home directory in windows, in cmd type: setx HOME "%USERPROFILE%"

@bioesteel (DOS) Day 1 notes (warning, I am verbose...):
    Intro to Shell:
        Shell is a program that allows you to interact with other programs
        -Bash Shell is a common shell, there are all sorts of different ones, and once you understand Bash, you can translate that to others
        
       The way Shell operates: input a command, Shell reads evaluates and then prints (my interpretation) 
        READ
        EVALUATE
        PRINT
        
        

Pair Exercise 1:
  1.     Execute the commands shown and figure out what each does from the data-shell directory
    1. command ls -1 : made the file listing into a vertical listing, rather than a 2 column horizontal listing
    2. command ls -F puts slashes after directories to indicate that those are folders
    3. command is -G flags the folders with a color (default perhaps is blue?)
    4. command ls -a we now have to pay attention to anything in the directory that starts with a dot. by convention, files that start with a dot are "special files" (traditionally the "hidden files"). If you can't see a file you are expecting using ls, it's probably hidden
    5. command ls -l is a long listing "Long format" display that describes some of the file properties including last date modified







you can use either -l -h or can stack them simply with -lh --> both give you same response
mkdir name = makes new directory in current folder
for Windows users, you can use Notepad++ to create .txt documents (execute using $notepad draft.txt)
rm filename = deletes files
rm -i filename = deletes file after confirming with you
rm -r directory = deletes directory
rm -r -i = deletes directory after confirming with you
rmdir directory = deltes directory but notifies you about contents first

cd molecules/
ls -l
ls -l -h 
wc cubane.pdb #tells you stuff about the file. first number is the line counts, second is the word count, and last is the character count.
wc -l cubane.pdb #tells you about the line count of the files
wc -l cubane.pdb ethane.pdb methane.pdb octane.pdb #tells you the line count for all the files listed
wc -l * #give me the line count for everything in this directory. asterisk is a wildcard, that give you zero or more characters to match. 
wc -l *.pdb #give me the line count for all the files that end in .pdb
wc -l p*.pdb #give me the line count for all the files that start with p and end in .pdb
wc -l *ethane.pdb #give me the line count for all the files that have *ethane.pdb
wc -l *t* #give me all the files with a t in it. 
wc -l *t* *o* #give me anything with a t or an o. lists the files so it will list them twice if they have both of the wild card characters.
wc -l * > length.txt #run the command and put the output into a file named length.txt
cat length.txt #cat prints the content of a text file.
control C #will exit you from the command you are running.
##when making file/directory names, keep them simple, avoid spaces, and avoid special characters. Use underscores, dashes, dots.
sort length.txt #will order the rows in the file
sort -n -r length.txt #switched the order
sort -n -r length.txt > length.sorted.txt #made a new file with the sorted stuff
head length.sorted.txt #shows you the top 10 lines. very useful for large files to get a look at them. however, this file only has a couple of lines.
head -n 2 length.sorted.txt #I want the head (top) of the file and I only want the first two lines. 
head -n 2 length.sorted.txt > length.sorted.head.txt
tail -n 1 length.sorted.head.txt #shows you the bottom
##PIPING. Connects commands so you don't make any intermediate files. 
wc -l *.pdb | sort -n -r | head -n 2 | tail -n 1 #by piping with the |, it takes the output from one command and uses it in the subsequent command. 
nano biggest_file.sh #put wc -l *.pdb | sort -n -r | head -n 2 | tail -n 1 in the nano thing. Save. Exit. Now you have a made a bash command!
bash biggest_file.sh #this gives you the same output as above! so you just made a file to do that command. 


recap @ 1130: wc *.pdb > length.txt
sort -n -r length.txt (r for reverse numeric sort)
redirected: sort -n -r length.txt > length.sorted.txt
found the first 2 lines of the header: head -n 2 length.sorted.txt > length.sorted.head.txt
also found last line of file using "tail" prompt: tail -n 1 length.sorted.head.txt
Doing all of this finally gave us the answer we were looking for - what file has the most lines? A: Octane.pdb w/ 30 lines
Pipe command [ | ] connects commands - no intermediate files
$ wc -l *pdb | sort -n -r | head -n 2 | tail -n 1 
does same thing as we did but more simply

PS1="$ "  #clears stuff infront of dollor shell
ls -F # flags which ones are directories
ls -G # colors directories
cd../.. # go two driectories back or up
clear #clear history
.  # means current directory
.. # parent directory
.file # means its a hidden file. 
nano file.txt #creates a new text file. 
rm -r # remove directory and recursuviley remove everything in the directory. 
rm -r -i # removes files interactively. 
mv # you can move a file to another directory
   # can also rename the file. 
   # you can accidentally overwrite files by this command. 
wc filename #gives how many lines and characters are in a file
wc -l filename # gives lines in the file
wc -l filename1, 2, 3 # gives lines for all of the files
wc -l * # wildcard makes lines of all files
cat #print a file contents without opening. 
sort -n #sort by numeric order
sort -n -r #sort by reverse order or high to low
head # show top 10 lines
tail #show bottom 10 lines
head/tail -n number # specify how many number you want to see. 

########Piping############
 | is  pipe command meaning take the output from previous command and use it as input for next command. 
  wc -l *.pdb | sort -n -r | head -n 2 | tail -n 1  # will take out put from one command and use it as input of next command and give you final output
  Save the whole line in file.sh
 and type bash file.sh



Python - Day 1


Instructor: Byron Smith <bsmith89@gmail.com>

Instructions to test your Python installation:
    -----------
Download https://bsmith89.github.io/2017-04-27-wsu/setup/swc-installation-test-1.py
and https://bsmith89.github.io/2017-04-27-wsu/setup/swc-installation-test-2.py
and move to your Desktop
On the command line move to your Desktop (cd ~/Desktop),
and then run the following command:
python swc-installation-test-1.py
if you do not have any errors, next run:
python swc-installation-test-2.py
and put a red sticky up if you have any errors.


Download and unzip example data:
http://swcarpentry.github.io/python-novice-gapminder/files/python-novice-gapminder-data.zip

@bioesteel Workshop Python notes:
    



Python Day 1 - Anna's Notes imported from a word doc so sorry about formatting and stuff that might make sense to me but not to other people! (thank you!)
 
·     Jupyter notebook – enter “jupyternotebook” in terminal and it will open up a web browswer – do not try to dothis in Python! need JN to run python
·     in jupyter notebook – to printtext, use quotes “hello world” but if want to print variables, use parenthesis 
o   print: “Hello World”
o   print(variable)
·     run cells w/ shift or cntrl enter
·     Different variables are differenttypes:
o   numeric, string, type
·     type() tells you the type of avariable
o   integers vs float
·     syntax for lists is squarebrackets []
·     python starts w/ 0 when listing,so first thing in list is the 0th item, not the 1st 
o   called “0 indexed”
o   len( ) = length of list
·     use parenthesis to call afunction
·     square brackets = list to indexto 
·     Work from inside out with scripts
·     Remember tab completion in Pythonas well!
·     dir for directory, helpfor…additional info
·     can import libraries w/ “import”
·     to get line numbers – hit“escape” and then “l”
·     If you want to call somethingthat’s defined in the library – need to call it specificall from lib
o   ex math.cos(math.pi) 
§ Can’t just call “pi” if undefined
·     Strings are like lists of letters– can call stuff out and index like a list
o   all characters count – spaces, tabs, etc  
·     our_first_list[0] = 'Charles' 
o   can change the value of something in your list by using the abovecode
o   can replace w/ another string! our_first_list[0] = a_string
·     REMEMBER THAT WHEN YOU BRACKET,IT’S UP TO BUT NOT INCLUDING THE RIGHT HAND NUMBER
o   0-2 = 0,1 
·     pandas package to work with .csvfiles
·     index_col = to bring up columnsby name instead of column number
·     Double equal sign ==  when pulling up specific colums
o   data[data.continent == 'Africa'] 
§ pulls up only data for Africa
·     Can also do great than or lessthan qualifiers: 
o   data[data.gdpPercap_1952 > 1000] 
·     Can combine: 
o   data[(data.gdpPercap_1952 > 3000) & (data.continent =='Africa')] 
 

Python - Day 2

Attendance:
  Elisabeth Steel (first! lol)
  Anna Boegehold - WSU Biological Sciences
 Kiran Koya - med school -Surgery dept 
John Butts - WSU Biological Sciences
Ashley Anderson - WSU Schol of Medicine Department of Microbiology, Immunology, and Biochemistry
James Aretakis - WSU Biological Science Grad
Corey Krabbenhoft - WSU Biological Sciences
Allison Mitchell
Chase Hellmer
Ben Kuiper - School of Medicine - MIB
Matt Fountain WSUSOM - MIB
Ashley Anderson
Corey Kra
Vanesa Ramseyer WSUSOM CMMG
bob akins
Cynthia Kalita - WSUSOM CMMG
Stephanie Gladyck - WSUSOM CMMG
Justyna Resztak
cdNikita Deshpande
Larry Grossman (SOM)
Aya Attia
Stephen Barr-Schol of Medicine:BMB
Kendall Muzzarelli - WSU School of Medicine -MIB
Rayanne Burl - School of Medicine, Center for Molecular Medicine and Genetics
prasanna-School Of Medicine- MIB
Cristiano Petrini
Neeraja Purandare-School of Medicine CGG (CMMG)
Abby Wicks-WSU Biological sciences
Will Close (Microbiology, Immunology, Biochemistry)

Remember to set the correct working drive before opening Jupyter Notebook!
Can take notes directly in your code in jupyter notebook by using the pound sign (#) before the text you don't want the program to run as code

can hit shift+tab to pull up a help version in anew window while cursor is in the parenthesis,  for example like in "matplotlib.pyplot.plot()" using shift+tabl will bring up help on arguments for creating a plot in this library

If you're getting an error in your syntax- maybe you're using ( ) instead of [ ] or vice versa! I may be speaking from experience.

Python magic to get plots to show in-line in jupyter notebook: %matplotlib inline 
Remember to work from the inside out when nesting things in parenthesis and brackets
Read error messages! Very helpful in Python because will pinppoint exactly what is wrong!

simple boolean expressions from this link https://www.eskimo.com/~scs/cclass/notes/sx3c.html    
        <=        less than or equal
        >        greater than
        >=        greater than or equal
        ==        equal
        !=        not equal
        
#elif adds an additional condition onto the code 
#if statement formats: if only, if else, if, elif gets tested, then if that's not true then else gets tested
#elif can only be here if it's directly in line with an "if" before 
#can do any number of elif statements after an if, and the first one it matches will end the fucntion

Tab fill description for object-oriented programming:
it's like predictable text, if you don't know the name of an option to define, start typing and try hitting tab, and then you get a list of 
options that are available if you are on the right track with what the name of the option name starts as
Jupyter Environment hotkeys: 
Commenting code in Python: 
    # symbol ahead of your description
Loops in Python:
    
    Example:


Pro tips from Byron:

Functions

Logical statements


     
     Example3:
         # logical statements nested in for loop
         # if elif else code block (could also have multiple elif statements between if else to have multiple checks)
            some_numbers = [1,2,3,4,5] # range(1,6)

Git - Day 2

LaTeX (but is pretty heavy - maybe not for begginers) and Markdown (maybe preferred) were the suggested languages for working in Git

guide for Markdown for Github: https://guides.github.com/features/mastering-markdown/ 

Open 

@bioesteel Git notes:
configuration sequence




$git checkout HEAD #most recent commit (i think, this may not be accurate)
$git HEAD~1 #most recent -1 commit (one before most recent, again, please check for accuracy)

more notes from Byron: allowing branching in your git collaborations is useful for developing in case you want to try to two different approaches to a coding strategy; multiple branching within a git collaboration 
Googledocs/Dropbox is great for collaborating, but if you are coding, git may be useful in order to track for version control and git also is preferable for branching

GitHub.com
using github:
    create a repository in your github account, and copy and paste the HTTPS address
    
   .........I have fallen off the boat, my notes are lost to the deep sea of the etherwebsgit 





AGB Git Notes imported from Word so mind formatting changes: 
    Git
 
·     can help you keep track ofdifferences in updating versions of the same document
·   $ git config--global user.name "Anna Boegehold"
·   $ git config--global user.email "annaboegehold@gmail.com"
·   $ git config--global color.ui "auto" 
·   $ git config--global core.editor "nano -w"
·   $ git init 
·   Initializedempty Git repository in /Users/annaboegehold/Desktop/guacamole/.git/
·   $ ls
·   $ ls -a
·   .   ..  .git
·   $ git status
o  current status of my repository 
·   To commitsomething to registry, can start by making a txt doc in nano
o  nano file name.txt
o  create and save file
o  remember to look at file contents use “cat”
·   $ git addinstructions.txt
·   $ git status
·   On branchmaster
·    
·   Initial commit
·    
·   Changes to becommitted:
·     (use "git rm --cached<file>..." to unstage)
·    
·    new file:   instructions.txt
·   2 stages tosaving in git: 
o  1 – add
o  2 – commit using “git commit” 
§  this will openup nano
§  here you canadd message to yourself or others on what you did w/ the changes
·   Save and commit file and you will get a prompt telling you what was changed (files,lines added, subtracted, etc.)
Double check using "git status" to make sure you have nothing to add