%pwd
!wget 'http://histo.ucsf.edu/BMS270/BMS270_2018/data/example1'
!wget 'http://histo.ucsf.edu/BMS270/BMS270_2018/data/example2'
%ls
fp = open("example1")
fp.read(10)
fp.read(10)
fp.seek(0)
%cd /home/mvoorhie/
%magic
fp.readline()
fp.readline()
fp.readline()
fp.readline()
fp.seek(0)
name = fp.readline()
seq = fp.readline()
name2 = fp.readline()
qual = fp.readline()
name,name2
len(seq),len(qual)
seq[0]
ord(seq[0])
chr(67)
ord('J')
fp.seek(0)
lines = []
for line in fp:
lines.append(line)
len(lines)
line[0]
lines[0]
lines[-1]
lines[:8]
fp.close()
fp = open("example2")
fp.read(10)
!wget 'http://histo.ucsf.edu/BMS270/BMS270_2018/data/supp2data.cdt'
fp = open("supp2data.cdt")
fp.readline()
fp.readline()
fp.readline()
rows = []
for line in open("supp2data.cdt"):
rows.append(line.rstrip("\r\n").split("\t"))
rows[0]
rows[0][0]
rows[0][-1]
rows[-1][:10]
print(rows[-1][:10])
data = []
fp = open("supp2data.cdt")
header = fp.readline()
for row in fp:
d = []
for field in row.rstrip("\r\n").split("\t")[2:]:
try:
d.append(float(field))
except ValueError:
print("{"+field+"}")
print("["+row+"]")
raise
data.append(d)
data = []
fp = open("supp2data.cdt")
header = fp.readline()
for row in fp:
d = []
for field in row.rstrip("\r\n").split("\t")[2:]:
try:
d.append(float(field))
except ValueError:
assert(field == "")
d.append(None)
data.append(d)
easy_data = []
fp = open("supp2data.cdt")
header = fp.readline()
for row in fp:
d = []
for field in row.rstrip("\r\n").split("\t")[2:]:
try:
d.append(float(field))
except ValueError:
assert(field == "")
d.append(0.)
easy_data.append(d)
len(easy_data)
len(data)
len(set(len(i) for i in data))
set(len(i) for i in data)
%matplotlib nbagg
import math
help(math.erf)
math.sqrt(5)
from math import sqrt,pi
sqrt(pi)
import matplotlib.pyplot as plt
plt.figure()
plt.plot(easy_data[0],easy_data[1],"bo")
!wget 'http://histo.ucsf.edu/BMS270/BMS270_2018/code/stats.py'
import stats
stats.__file__
stats.pearson(easy_data[0],easy_data[1])
fig = plt.figure()
h = plt.hist(easy_data[0])
plt.figure()
plt.plot(sorted(easy_data[0]))