Day 2

What We are Doing for 2 Weeks: Gene Finder (Mini-Project 1)

Today, we provide some background information related to mini-project 1 and have a full introduction to the material in the next class session. (slides)

Resources on Protein synthesis

Who we are and How/Where we’re doing MP1

We will inform you of which studio to attend for the duration of MP1 using Canvas (Announcements and/or other mechanisms).

Getting Comfortable Coding and Completing Assignments in Python

There are many ways to run the Python code that you write:

Method 1: Interactive Python interpreter

$ python3
Python 3.7.1 (default, Dec 14 2018, 19:28:38)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print("Hello, SoftDes!")
Hello, SoftDes!

There is also an advanced implementation of the interpreter called ipython that adds some nice extra features.

Method 2: Jupyter notebooks

This is what you will use for the Reading Journal assignments. Each code cell in the notebook is essentially a mini interpreter session.

Method 3: Within an IDE/editor

Several integrated development environments(IDE)/text editors allow you to run Python code as you write it. The mechanism for doing so varies by editor. In order to run Python code from Atom, you should install the “script” package (detailed instructions on installing packages), and then use ctrl-shift-b (on a Linux or Windows PC) to execute your code. There is a way to tell Atom that you want to execute Python in the lower portion of the interface.

A few things to watch out for: when you run code using this method it usually can’t take standard input, so this means you can’t use e.g. the raw_input function. Also, if you run an infinite loop (begin counting something and never tell the program when to stop) it may freeze your editor!

Method 4: Saved script

Finally, you can save your program as a text file (with a .py extension by convention) and run it at the command line:

$ python3 my_script.py
"Hello, SoftDes!"

This is the preferred method for running all but the very simplest of programs, and is how you will complete and submit all the mini-projects / assignments in this class other than reading journals.

Reading Journal Procedures

In a terminal, run jupyter -h to check whether Jupyter is installed. You should see a message like this:

usage: jupyter [-h] [--version] [--config-dir] [--data-dir] [--runtime-dir] [--paths] [--json] [subcommand]

Jupyter: Interactive Computing

positional arguments:
  subcommand     the subcommand to launch

optional arguments:
  -h, --help     show this help message and exit
  --version      show the jupyter command's version and exit
  --config-dir   show Jupyter config dir
  --data-dir     show Jupyter data dir
  --runtime-dir  show Jupyter runtime dir
  --paths        show all Jupyter paths. Add --json for machine-readable format.
  --json         output paths as machine-readable json

Available subcommands: bundlerextension console kernel kernelspec lab labextension labhub migrate nbconvert nbextension notebook run serverextension troubleshoot trust

When you set up your machine according to instructions provided in the first class session, you set up git and a Github account, which we will be using in a number of ways for this class. Some examples are:

We have assigned a reading journal for you to work on before the next (third) class session. (Note that we did not say “complete” as it is not mandatory to finish all exercises in a given reading journal, but we expect that you try as much as you can without spending over 3 hours on it). During this second class session, we will help you start the steps to setup your own personal ReadingJournal repository. We’ll

  1. Click on the invitation link https://classroom.github.com/a/WX2oD6lX
  2. Click the green button “Accept this assignment”.
  3. Follow the remaining instructions until you get to your repository page. It will looks something like https://github.com/sd2020spring/reading-journal-myname, except with your GitHub user id instead of myname.
  4. Clone the repository to your computer by typing the following into your Terminal program. Replace myname with your GitHub user id.
$ git clone https://github.com/sd2020spring/reading-journal-myname.git ReadingJournal

Now you have a copy of the ReadingJournal folder (directory) on your drive. Use the terminal or Ubuntu File Manager to verify that it is present.

Next, you can fire up Jupyter notebook and load the reading journal for day X.

$ cd ReadingJournal
$ jupyter notebook reading-journal-01.ipynb

If all goes well, this should bring up a web-browser with the reading questions.

The Class Session Following a Reading Journal

We typically plan class sessions (beyond the first second day) with a Reading Journal follow-up activity. We have gone through this first reading journal as an in-class exercise, but had we made reading-jounrnal-1 due before class, you might expect to see prompts such as the following:

Example Post-Reading-Journal Pair up

With two people sitting around you, go over your reading journal. Identify any questions / difficulties and try to work through them. We will do a quick report out for lingering confusions along with observations you’d like to share with the rest of the class.

Example Modular Design Exercise

In groups of 3, review the solutions from a previous iteration of this class to Chapter 3, Exercise 5, Part A.

Discuss Which aspects of these different designs:

In groups, redo Chapter 3 Exercise 5 based on the design that your group decides is most readable and most flexible.

In a surprise move, your manager has asked you to implement two new features for your program.

  1. Write a function that draws the following grid

    + - - - - + - - - - + - - - - + - - - - + - - - - +
    |         |         |         |         |         |
    |         |         |         |         |         |
    |         |         |         |         |         |
    |         |         |         |         |         |
    + - - - - + - - - - + - - - - + - - - - + - - - - +
    |         |         |         |         |         |
    |         |         |         |         |         |
    |         |         |         |         |         |
    |         |         |         |         |         |
    + - - - - + - - - - + - - - - + - - - - + - - - - +
    |         |         |         |         |         |
    |         |         |         |         |         |
    |         |         |         |         |         |
    |         |         |         |         |         |
    + - - - - + - - - - + - - - - + - - - - + - - - - +
    
  2. Modify your function to take in two additional inputs that specify the dimensions of width and height (in characters) of each of the boxes that compose the grid. For instance,

    grid(6, 3) produces

    + - - + - - + - - + - - + - - +
    |     |     |     |     |     |
    |     |     |     |     |     |
    + - - + - - + - - + - - + - - +
    |     |     |     |     |     |
    |     |     |     |     |     |
    + - - + - - + - - + - - + - - +
    |     |     |     |     |     |
    |     |     |     |     |     |
    + - - + - - + - - + - - + - - +