## CELL0014: An Introduction to Maths and Python for Modelling

In CELL0014: Dynamic Biological Systems we will be using techniques from maths, computing and engineering to build models of biological systems.

The Introduction to Maths and Python materials below are provided so that you will quickly be able to work with the Python code needed to model systems. It also includes materials revisiting some useful A-Level Maths skills and concepts. Details of the topics covered can be found here.

If you taking the module in Term 2 (2018-19) you should ensure you schedule some time in Term 1 to study these materials. These should take about 30 hours in total depending on your existing experience.

## 1 : Getting Started

In this session we will:

1. Install Anaconda so that you can work with Python on your computer (or check you can find it on the UCL machines)
2. Work through some Getting Started with Python activities.

Tutorials to work through can be found on the following page:

## 2 : (Maths I) Working with Equations and Measurements

The materials for this section can be found here:

Work through the materials in the two documents testing your skills by completing the exercises.

For your convenience the exercises and answers for this session are available as separate PDFs.

## 3 : (Python I) The Fibonnacci Sequence and Seed Patterns

The materials for this session can be found here:

Folder : Session 3 Python I

Work through the material, taking note in particular how to:

work with lists

• work with loops
• create plots

## 4 : (Maths II) Investigating Functions

The materials for this section can be found here:

Please work through the materials in the two documents. Each topic has some exercises (with answers) for you to work though in the separate documents above.

## 5 : (Python II) A program to read and translate DNA sequences

The materials for this session can be found here:

Folder : Session 5 Python II

This works through a series of Python exercises using the example of reading DNA strings. In reality Python has libraries of functions for loading standardised sequence data, but as we are trying to learn the basics of Python we will do things by scratch. The task has been borrowed from some activities targeted at non-biologists so expect the biology to be somewhat basic!

Work through the materials, taking note in particular how to:

• work with strings
• work with the if command and test conditions
• break code into functions
• use dict objects
• use while loops and slice lists

## 6 : Maths (III) Introduction to Calculus

The materials for this section can be found here:

Please work through the materials in the two documents

Each topic has some exercises (with answers) for you to work though in the separate documents above.

## 7 : Python (III) Working with Files

The materials for this session can be found here:

The first activity runs through the basics of how to open a file and use it to retrieve or store information.

The second activity builds on our DNA processing code from the previous Python session, and uses the functions we developed to translate DNA on a real DNA sequence loaded from a file, to search for protein candidates.

The resources for the activites are in the subfolder here:

Work through the materials, taking note in particular how to:

• load data from a text file into a Python variable
• write out data to a file
• use functions to break up programs into smaller reusable parts

## 8 : Python (IV) Working with Objects

The materials for this session can be found here:

The activities work through how to define and work with custom Object types in Python.

Work through the materials, taking note in particular:

• how to define a custom Object class in Python
• how to use objects attributes to store the data associated with an object
• how to define methods that act on an Object including the __str__ method
• how to use str.format() to display data
• how to save and load objects using pickle
• how to export and import object data using csv files
• the difference between mutable and immutable objects in Python
• the difference between object equality and object equivalence
• how to set up functions that take a variable number of arguments / keyword arguments / default arguments