# 6.00 Problem Set 7 # Problem 1 # Name: Jane Lee # Collaborators: John Doe # Time: # import pylab # The *_age lists hold the evolutionary distance in millions of years. # The *_sub lists hold the number of substitution per 100 amino acids # in the protein sequences. # Adopted from Dickerson, J Mol Evol 1: 26-45 (1971). # cytochrome c cyt_age = [90.0,90.0,240.0,300.0,300.0,400.0,600.0,1200.0] cyt_sub = [10.2,5.0,13.6,10.0,15.3,19.8,29.6,60.1] # globins glob_age = [90.0,400.0,500.0,780.0,890.0,900.0,940.0,970.0,1000.0] glob_sub = [16.3,68.9,87.0,138.6,151.4,156.5,161.9,163.5,174.2] # fibrinopeptides fib_age = [33.0,45.0,50.0,60.0,90.0] fib_sub = [37.1,40.5,47.1,58.0,80.3] def linreg_and_plot(xdata,ydata,data_marker,line_marker): """ Fit y data against the x data using first order linear regression. Plot y data against x data with the specified data marker. Plot the fitted line with the specified line marker for x ranging from 0 to the maximum value of the x data. Return the coefficients of the fitted line. xdata,ydata: lists of numerical values, with the same number of elements data_marker: marker for the data points, as accepted by pylab.plot line_marker: marker for the fitted line, as accepted by pylab.plot returns: the coefficients of the fitted line """ print 'linreg_and_plot not yet implemented.' # delete this line when you're done def test_linreg_and_plot(): # data for testing the regression and plotting helper funcion x_test = [1,2,3,4,5] y_test = [2,4,6,8,10] data_marker_test = 'xr' line_marker_test = '-r' pylab.figure() linreg_and_plot(x_test,y_test,data_marker_test,line_marker_test) pylab.title('test_linreg_and_plot') def mol_clock(): pylab.figure() print 'mol_clock not yet implemented.' # delete this line when you're done print 'PROBLEM 1 data loaded' print 'Cytochrome c:',len(cyt_age),'time points',len(cyt_sub),'substitution values.' print 'Globins:',len(glob_age),'time points,',len(glob_sub),'substitution values.' print 'Fibrinopeptides:',len(fib_age),'time points,',len(fib_sub),'substitution values.' test_linreg_and_plot() mol_clock() pylab.show()