forked from ninas/umonya_notes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
assignments.html
246 lines (217 loc) · 9.37 KB
/
assignments.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<title>Introductory Programming in Python: Assignments</title>
<link rel='stylesheet' type='text/css' href='style.css' />
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<script src='animation.js' type='text/javascript'>
</script>
</head>
<body onload='animate_loop()'>
<div class='page'>
<h1>Introductory Programming in Python<br />
Assignments</h1>
<div class='centered'>
[<a href='index.html'>Course Outline</a>]<br />
[<a href='solutions'>Solutions</a>]
</div>
<p class='header'><a name='assignment1' id='assignment1'>Assignment 1</a></p>
<ol>
<li class='exercise'>Write an accountants calculator. The user may enter a number, an operator (+, -, *, /), a blank line, or the word 'quit'. The first entry must be a number. Every time a number is entered, it is added to the current total (which
starts at 0), unless the previous line was an operator, in which case, instead of adding, use the operator given to combine the number entered and the total to form a new total. Every time a blank line is entered, print a line of dashes followed by
a line containing the current total. If the entry is the word 'quit' the program ends. Here is an example of output for the input; 4, 9, blank line, *, 2, -, 6, /, 10, blank line, quit
<pre>
4
9
-----
13
*
2
-
6
/
10
-----
2
quit
</pre>
</li>
</ol>
<p class='header'><a name='assignment2'>Assignment 2</a></p>
<ol>
<li class='exercise' value='2'>Write a simple noughts and crosses
game, with a simple artificial intelligence, i.e. the computer
will always place their nought or cross to win the game if
possible, otherwise it will prevent the player forming a line,
or where there are multiple choices, the computer chooses
randomly. The player should be able to decide who is noughts
and who is crosses, with crosses always starting first. To get
the players move, allow them to enter their move in the format
"A2", where the alphabetic character represents the column, and
the number the row. Check that the input is valid, but allow
the alphabetic character to be in any case. If the input isn't
valid (too many characters, out of bounds, etc...), let the
player enter their move again. Entering the word 'quit' allows
the player to forfeit the game early. Output should present a
grid showing the state of the game at each of the players
turns.
<pre>
Noughts (0) or Crosses (X): X
A B C
|-|-|-|
1| | | |
|-|-|-|
2| | | |
|-|-|-|
3| | | |
|-|-|-|
Your move? B2
A B C
|-|-|-|
1| | | |
|-|-|-|
2| |X|O|
|-|-|-|
3| | | |
|-|-|-|
Your move? D3x
Input not valid, too many characters. Try again: D3
Input not valid, out of bounds. Try again: C3
A B C
|-|-|-|
1|O| | |
|-|-|-|
2| |X|O|
|-|-|-|
3| | |X|
|-|-|-|
Your move? B3
A B C
|-|-|-|
1|O|O| |
|-|-|-|
2| |X|O|
|-|-|-|
3| |X|X|
|-|-|-|
Your move? A3
A B C
|-|-|-|
1|O|O| |
|-|-|-|
2| |X|O|
|-|-|-|
3|X|X|X|
|-|-|-|
You win!
</pre>
</li>
</ol>
<p class='header'><a name='assignment3'>Assignment 3</a></p>
<ol>
<li class='exercise' value='3'>A wet lab has given you the task of
writing a program to do some basic statistics on their data. Every
now and then they sequence oligos from different organisms. Their
wet lab machinery provides them with a file for each organism they
sequence containing the date of the sequencing, the name of the
organism sequenced, a short name for it with no spaces or
punctuation, and the list of oligos obtained, and their starting
positions in the genome. There may or may not be 100% coverage of
the entire genome. No oligo is greater than 12 base pairs in
length. They want the following functionality, using command line
parameters.
<ul>
<li>Given a new file, of the format following, they wish to be able to merge it's data into the database if organism hasn't been merged already, i.e. the short name doesn't already exist in the database. (--merge <filename>)</li>
<li>They want to know for a given oligo which organisms it occurred in, and their positions (--belongs <oligo sequence>)</li>
<li>They want to know for a given organism, all of the oligos belonging to it, in order (--genome <organism short name>)</li>
<li>They want to know any shared oligos between two specified organisms, and their positions in each oligo, displayed in a neat table (--shared <organism short name 1> <organism short name 2>)</li>
<li>They want to know the frequency of a given oligo in the entire database (--freq <oligo sequence>)</li>
</ul>
<strong>Notes:</strong><ul>
<li>You will need to use a file to store the database, and you will need to modify its contents. You can either overwrite the entire thing (easiest), or modify it in place (+3 bonus marks above 100%, can offset poor marks from previous assignments). Your decision heavily influences the format of database file.</li>
<li>Remember to use command line parameters for input exclusively, this means no raw_input()...</li>
<li>There is no reason your database can't consist of more than one file</li>
<li>Oligos must match exactly. Do not combine adjacent oligos, nor search for for sub-oligos within the ones in the database</li>
<li>You may <strong>not</strong> use any form of database module, <em>inter alia</em>; any relational database, the shelve or pickle modules, berkdb, ODBC etc... flat standard python files only.</li>
</ul>
Following are 2 example files and the example outputs for the
program using various command line parameters.
<pre>31 Mar 2008: Bugblatter of Traal Neuron
BugBlatNeuron
AACGATCTTACG 0
TGTTGAGACA 16
GCAGATGTCGA 43
CCGAGGCG 86
TGCAGACCATC 111
CACAAACCC 145</pre>
<pre>02 Apr 2008: Babel Fish Brain Matrix Neuron
BabelMatrix
AGCTAGCATGC 3
CATGATGACGAT 45
TACGAGGA 78
CCGAGGCG 109
GTCCCAG 205</pre>
<pre>$ oligodb --merge bugblatter.dat
$ oligodb --merge babel.dat
$ oligodb --genome BabelMatrix
AGCTAGCATGC (3)
CATGATGACGAT (45)
TACGAGGA (78)
CCGAGGCG (109)
GTCCCAG (205)
$ oligodb --freq GTCCCAG
1
$ oligodb --belongs CCGAGGCG
BugBlatNeuron: 86
BabelMatrix: 109
$ oligodb --shared BugBlatNeuron BabelMatrix
BugBlatNeuron BabelMatrix
CCGAGGCG 86 109</pre>
</li>
</ol>
<p class='header'><a name='assignment4'>Assignment 4</a></p>
<ol>
<li class='exercise' value='4'>A local laboratory is doing
experiments in accelerated mutation. Taking starting unicellular
organisms, they bombard them with radiation causing increased
mutation rates, then place the offspring on a medium containing
cellulose. For those organisms that digest the cellulose, the
process is repeated this time with the offspring as the initial
organisms, and the final medium containing a slightly higher
cellulose content. The lab has already identified a site on the
various organisms genomes of interest, 10 base pairs
long. For each surviving organism they have recorded in a file (<a
href='data/assignment4.dat'>assignment.dat</a>):
<ul>
<li>The lab code for the individual organism (unique)</li>
<li>The date the organism was sequenced</li>
<li>The sequence of interest from the organism</li>
<li>The percentage of cellulose digested by the organism in a given time</li>
<li>The ancestry of the organism by its relative indentation</li>
</ul>
While the organisms do exhibit increased cellulose degradation
capabilities, they also exhibit a variety of undesirable
phenotypes. The lab now needs to identify individual SNPs that
cause the greatest average positive changes in cellulose
consumption percentages (CCP), so they can focus on those mutations
to achieve only the cellulose degradation phenotype. Your crack
team of programmers has just been awarded the contract, the deposit
cheque is in your sweaty little palms, the data file is available
for download, get coding.
<ul>
<li>Your program should process files specified on the command line, and merge them into one large dataset for processing</li>
<li>A change in CCP is the difference in a child's CCP and its parent's CCP (child - parent), for a given sequence position</li>
<li>Only if a nucleotide is changed from parent to child in a given position, does that change in CCP contribute to the average change in CCP for that position</li>
<li>Your program should output in descending order of average CCP change, the value of the average CCP change, and the nucleotide position relative to the start of the gene of interest<li>
<li>Create a slide show presentation of <strong>maximum</strong> 5 minutes, explaining your approach to the problem. Be prepared for question from myself, and the class.</li>
<li>The mark for the assignment is out of 10, 5 from the presentation and questions, 5 from the code. You will be expected to demonstrate your code, on screen during your presentation, using the example file.</li>
</ul>
Example output from the given example input file follows...
</ol>
</div>
<div class='pagefooter'>
Copyright © James Dominy 2007-2008; Released under the <a href='http://www.gnu.org/copyleft/fdl.html'>GNU Free Documentation License</a><br />
<a href='intropython.tar.gz'>Download the tarball</a>
</div>
</body>
</html>