Time to get past shell scripting.
Getting Easier Now
#In a terminal window launch the ipython notebook (opens a new tab in default web browser)
#Transpose a matrix and create a pivot table on another matrix
#See build a Mac for install of python3
Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 5 2014, 20:42:22)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> ###THIS IS THE PYTHON PROMPT###
#Lets get things loaded to do some work
#Import os so you can do same basic things like navigation and list files in the directory
>>> import os
#Navigate to the Desktop (one directory above
#Import the SciPy Tools
>>> import pandas as pd
>>> import numpy as np
>>> import matplotlib.pyplot as plt
#Read in a tab-deliminated table (test1.txt)
>>> table = pd.read_csv("test1.txt", sep="\t", index_col=0)
P1 P2 P3
MYC 1 0 0
TRAF3 2 1 2
CYLD 0 2 1
#Transpose the table (This is too easy!)
Gene MYC TRAF3 CYLD
P1 1 2 0
P2 0 1 2
P3 0 2 1
#Make the transposed table a new object
>>> trans = table.T
#Write the new transposed object to a new tab-deliminated file
>>> trans.to_csv("transposed.txt", sep="\t")
## PIVOT TABLES SO WE NEVER NEED TO USE EXCEL AGAIN!!
Some early basics.
1) To build a python script
#!/bin/python #This must be the header line
2) Query the user
name = raw_input("What is your name?")
print "Hello %s" % (name)
from datetime import datetime
now = datetime.now()
print '%s/%s/%s' % (now.month, now.day, now.year)
print '%s:%s:%s' % (now.hour, now.minute, now.second)
print '%s/%s/%s %s:%s:%s' % (now.month, now.day, now.year, now.hour, now.minute, now.second)
4) IF, ELSE-IF, ELSE Decision Trees
!= Does not equal
> Greater Than
< Less Than
>= Greater Than or Equal To
<= Less Than or Equal To
and - checks if both values are true
or - checks if at least one is true
not - gives the opposite of the statement
print "You've just entered the lab!"
print "Is your lab on the left or the right?"
answer = raw_input("Type left or right and hit 'Enter'.").lower()
if answer == "left" or answer == "l":
print "Wrong Direction, the Carpten Lab is to the Left!"
elif answer == "right" or answer == "r":
print "Good job, now find your bench and get to work!"
print "Hey Neuroguys, you need to pick Left or Right, try again."
# Transpose a Matrix File
python -c "import sys; print('\n'.join(' '.join(c) for c in zip(*(l.split() for l in sys.stdin.readlines() if l.strip()))))" < INPUT.txt > OUTPUT.txt
$ jupyter notebook