Differences between revisions 23 and 54 (spanning 31 versions)
Revision 23 as of 2013-09-01 12:36:00
Size: 3750
Editor: hassan
Comment:
Revision 54 as of 2014-12-16 12:07:03
Size: 5389
Editor: mark
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
== Practical 1  ==
== Practical 1 ==
Line 4: Line 3:

Before staring with the exercises, have a look at the python tutorial, [[ScrumPy/Doc/Tutorial/PyIntro | here]]. Try to repeat some of the code in your {{{ScrumPy}}} window.
Before staring with the exercises, have a look at the {{{Python}}} tutorial, [[ScrumPy/Doc/Tutorial/PyIntro|here]]. Try to repeat some of the code in your {{{ScrumPy}}} window.
Line 10: Line 8:
>>> num_type_1 = 8
>>> num_type_2 = 9.0
>>> str_type = 'a'
>>> num_1 = 8.0
>>> num_2 = 9
>>> str_1 = 'a'
Line 14: Line 12:
Line 18: Line 15:
num_type_1/2
num_type_1/2.0
num_type_2/3
num_1/2
num_2/2
num_2/2.0
Line 22: Line 19:
str_type*4 str_1*4
Line 24: Line 21:

C
ontrol your answers using Python. Any deviations from expected? Why?
Do the calculations above using {{{Python}}} and compare with your answers. Any deviations from expected? Why?
Line 29: Line 24:
Line 32: Line 28:
Make another list ({{{reversed_list}}}) that is a copy of the first, e.g.:
Line 33: Line 30:
Make another list (''reversed_list'') that is a copy of the first, e.g.:
Line 37: Line 33:
(why will this assignment result in a copy of {{{test_list}}}? Hint: this is a ''slicing'' operation.)
Line 38: Line 35:
(why will this assignment result in a copy of ''test_list''? Hint: this is a ''slicing'' operation.)

Now, reverse the order of the items in ''reversed_list'' by repeating the following assignment with suitable choice of ''n'' and ''m'':
Now, reverse the order of the items in {{{reversed_list}}} by repeating the following assignment with suitable choice of {{{n}}} and {{{m}}}:
Line 45: Line 40:
'''(c)''' Define two empty dictionaries, one called {{{ara}}} the other {{{rad}}}. Both will be used for collection information about plants, {{{ara}}} about ''Arabidopsis thaliana'', and {{{rad}}} about radish.
Line 46: Line 42:
'''(c)''' Define two empty dictionaries, one called ''ara'' the other ''rad''. Both will be used for collection information about plants, ''ara'' about ''Arabidopsis thaliana'', and ''rad'' about radish. For both dictionaries define the keys {{{name}}} with a empty dictionary as value (e.g. {{{ara[name] = {} }}}) and {{{relatedTo}}} with an empty list as value (e.g. {{{ara[relatedTo] = []}}}). For the nested dictionaries ({{{name}}}) define the keys {{{Latin}}} (with another empty dictionary as value) and {{{English}}} with the English name of the plant as value (for ''A. thaliana'' this is ''thale cress''). For the {{{Latin}}} dictionary define the keys {{{genus}}} (with the value being the genus name) and {{{sp.}}} (with the value being the species name). For ''A. thaliana'', {{{genus}}} is ''Arabidopsis'', {{{sp.}}} is ''thaliana''. The Latin name for radish is ''Raphanus sativus''.
Line 48: Line 44:
For both dictionaries define the keys ''name'' with a empty dictionary as value, ''usedFor'' and ''relatedTo'' (both with empty lists as values). For the nested dictionaries (''name'') define the keys ''Latin'' (with another empty dictionary as value) and ''English'' with the English name of the plant as value (for ''A. thaliana'' this is ''thale cress''). For the ''Latin'' dictionary define the keys ''genus'' (with the value being the genus name) and ''sp.'' (with the value being the species name). For ''A. thaliana'', ''genus'' is ''Arabidopsis'', ''sp.'' is ''thaliana''. The Latin name for radish is ''Raphanus sativus''.

For both ''ara'' and ''rad'' define the key ''reletedTo'', with an empty list as value. Since the two plants are in the same family, for each dictionary append the other dictionary to the ''relatedTo'' list.
Since the two plants are in the same family, for each dictionary append the other dictionary to the {{{relatedTo}}} list (e.g. {{{ara[relatedTo].append(rad)}}}, provided {{{ara[relatedTo]}}} is a list and that {{{rad}}} is defined.)
Line 54: Line 48:
Explore what happens if you try to access the nested ''relatedTo'' organism, starting from any of the two organisms (i.e. start from one organism, access the organism it is related to, then continue down one level to the organism the second organism is related to). Explore what happens if you try to access the nested {{{relatedTo}}} organism, starting from any of the two organisms (i.e. start from one organism, access the organism it is related to, then continue down one level to the organism the second organism is related to).
Line 56: Line 50:
'''(d)''' The volume of a sphere can be calculated as 4/3*π*r^3^ given a radius ''r''. Import the {{{math}}} module to obtain an approximation of π as {{{math.pi}}}; and calculate the volume of a sphere with radius of 4. The method {{{pow(...)}}} can be used to calculate ''x^y^''. Note that 201.06 is not the correct answer.
Line 57: Line 52:
'''(d)''' The volume of a sphere can be calculated as 4/3*π*r^3^ given a radius ''r''. Import the ''math'' module to obtain an approximation of π and calculate the volume of a sphere with radius of 4. The method ''pow(...)'' can be used to calculate ''x^y^''. Note that 201.06 is not the correct answer. '''(e)''' Repeat exercise '''(b)''' using a {{{for}}} loop to rewrite {{{reversed_list}}}.

[[AccliPhot/WorkshopOne/prac1/hint_e|Hint]]

'''(f)''' Given the start and end values of a range of floating point numbers, how can you obtain a list of a fixed length with numbers evenly distributed between the start and end? E.g. given {{{start = 0}}}, {{{end=5}}}, and {{{length=10}}}, you should obtain {{{[0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5]}}}.

[[AccliPhot/WorkshopOne/prac1/hint_f_1|Hint 1]]

[[AccliPhot/WorkshopOne/prac1/hint_f_2|Hint 2]]
Line 60: Line 63:
Have a look at [[ScrumPy/Doc/Tutorial/ScrumPyIntro|this tutorial]] before starting. We will look at the last two subsections, ''Elementary modes'' and ''Enzyme subsets'', tomorrow, so don't worry about those yet.
Line 61: Line 65:
Have a look at [[ScrumPy/Doc/Tutorial/ScrumPyIntro | this tutorial]] before starting. '''(a)''' Create and load {{{toy_model.spy}}} as described in the tutorial.
Line 63: Line 67:
'''(a)''' Create and load ''toy_model.spy'' as described in the tutorial. '''(b)''' See what happens if you remove the tilde sign (~) from any of the reactions in the model file. Implement the modification either by selecting ''!ScrumPy'' > ''Compile'' in the model file, or do:
Line 65: Line 69:
'''(b)''' See what happens if you remove the tilde sign (~) from any of the reactions in the model file. Implement the modification either by selecting ''!ScrumPy'' > ''Compile'' in the model file, or do:
Line 69: Line 72:

in the !ScrumPy window (after saving the modification in the model file).
in the {{{ScrumPy}}} window (after saving the modification in the model file).
Line 79: Line 81:
Line 82: Line 83:
=== Part 3 - The Stoichiometry Matrix and Null-space ===
'''(a)''' Familiarise yourself with the stoichiometry matrix of the toy model, e.g. repeat the examples in the section of the [[ScrumPy/Doc/Tutorial/ScrumPyIntro|tutorial]] relating to the stoichiometry matrix.
Line 83: Line 86:
=== Part 3 - The Stoichiometry Matrix and Null-space === '''(b)''' Generate a kernel of the stoichiometry matrix (using the {{{.NullSpace()}}} method).

'''(c)''' Multiply the stoichiometry matrix by the kernel matrix, using the {{{.Mul()}}} method of the stoichiometry matrix.

'''(d)''' Repeat the multiplication above using the external stoichiometry matrix instead.

'''(e)''' Create a kernel of the external stoichiometry matrix - what is different?

'''(f)''' Multiply the internal and external stoichiometry matrices by your new kernel.

'''(g)''' Try adding or removing reactions from the model, and repeat the exercises above, explain the new results.

Practical 1

Part 1 - Exploring Python

Before staring with the exercises, have a look at the Python tutorial, here. Try to repeat some of the code in your ScrumPy window.

(a) Start a ScrumPy session, and make the following assignments:

   1 >>> num_1 = 8.0
   2 >>> num_2 = 9
   3 >>> str_1 = 'a'

What do you think the value and type of the following expressions are?

num_1/2
num_2/2
num_2/2.0
5 + 2*10
str_1*4

Do the calculations above using Python and compare with your answers. Any deviations from expected? Why?

(b) Create a list with six items, e.g.:

   1 >>> test_list= ['a', 'b', 'c', 'd', 'e', 'f']

Make another list (reversed_list) that is a copy of the first, e.g.:

   1 >>> reversed_list=test_list[:]

(why will this assignment result in a copy of test_list? Hint: this is a slicing operation.)

Now, reverse the order of the items in reversed_list by repeating the following assignment with suitable choice of n and m:

   1 >>> reversed_list[n]=test_list[m]

(c) Define two empty dictionaries, one called ara the other rad. Both will be used for collection information about plants, ara about Arabidopsis thaliana, and rad about radish.

For both dictionaries define the keys name with a empty dictionary as value (e.g. ara[name] = {} ) and relatedTo with an empty list as value (e.g. ara[relatedTo] = []). For the nested dictionaries (name) define the keys Latin (with another empty dictionary as value) and English with the English name of the plant as value (for A. thaliana this is thale cress). For the Latin dictionary define the keys genus (with the value being the genus name) and sp. (with the value being the species name). For A. thaliana, genus is Arabidopsis, sp. is thaliana. The Latin name for radish is Raphanus sativus.

Since the two plants are in the same family, for each dictionary append the other dictionary to the relatedTo list (e.g. ara[relatedTo].append(rad), provided ara[relatedTo] is a list and that rad is defined.)

How would you find, using one single command, the English name of an organism that A. thaliana is related to?

Explore what happens if you try to access the nested relatedTo organism, starting from any of the two organisms (i.e. start from one organism, access the organism it is related to, then continue down one level to the organism the second organism is related to).

(d) The volume of a sphere can be calculated as 4/3*π*r3 given a radius r. Import the math module to obtain an approximation of π as math.pi; and calculate the volume of a sphere with radius of 4. The method pow(...) can be used to calculate xy. Note that 201.06 is not the correct answer.

(e) Repeat exercise (b) using a for loop to rewrite reversed_list.

Hint

(f) Given the start and end values of a range of floating point numbers, how can you obtain a list of a fixed length with numbers evenly distributed between the start and end? E.g. given start = 0, end=5, and length=10, you should obtain [0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5].

Hint 1

Hint 2

Part 2 - Creating Models

Have a look at this tutorial before starting. We will look at the last two subsections, Elementary modes and Enzyme subsets, tomorrow, so don't worry about those yet.

(a) Create and load toy_model.spy as described in the tutorial.

(b) See what happens if you remove the tilde sign (~) from any of the reactions in the model file. Implement the modification either by selecting ScrumPy > Compile in the model file, or do:

   1 >>> m.Reload()

in the ScrumPy window (after saving the modification in the model file).

(c) Modify the reaction stoichiometry in any of the reactions in toy_model.spy so that all reactants are identical, e.g.:

   1 A_tx:
   2     A -> A
   3     ~

Reload or compile the model as above. What happens?

Part 3 - The Stoichiometry Matrix and Null-space

(a) Familiarise yourself with the stoichiometry matrix of the toy model, e.g. repeat the examples in the section of the tutorial relating to the stoichiometry matrix.

(b) Generate a kernel of the stoichiometry matrix (using the .NullSpace() method).

(c) Multiply the stoichiometry matrix by the kernel matrix, using the .Mul() method of the stoichiometry matrix.

(d) Repeat the multiplication above using the external stoichiometry matrix instead.

(e) Create a kernel of the external stoichiometry matrix - what is different?

(f) Multiply the internal and external stoichiometry matrices by your new kernel.

(g) Try adding or removing reactions from the model, and repeat the exercises above, explain the new results.

None: AccliPhot/WorkshopOne/prac1 (last edited 2014-12-16 12:30:53 by david)