Harvard:Biophysics 101/2007/02/06: Difference between revisions

From OpenWetWare
Jump to navigationJump to search
 
(4 intermediate revisions by the same user not shown)
Line 3: Line 3:


==Q&A==
==Q&A==
*Q1: "When I'm editing a page, is there any way to do it in a box that is bigger than the single-line tiny editing box that comes up at first?"
*Q1: "When I'm editing a page on the wiki, is there any way to do it in a box that is bigger than the single-line tiny editing box that comes up at first?"
*A1: Visit the [[Special:Preferences|my preferences]] link in the upper right-hand corner of the page.  Under the "Editing" tab, set Rows: 25, Columns: 80.
*A1: Visit the [[Special:Preferences|my preferences]] link in the upper right-hand corner of the page.  Under the "Editing" tab, set Rows: 25, Columns: 80.
*Q2: "How do I install BioPython on OS X?"
*Q2: "How do I install BioPython on OS X?"
*A2: The [[Harvard:Biophysics_101/2007:Python|Python]] page has been updated with more detailed instructions.
*A2: The [[Harvard:Biophysics_101/2007:Python|Python]] page has been updated with more detailed instructions.
*Q3: "I've installed Python and can see programs like  "Build Applet", "IDLE", and "Launcher".  How do I actually run a Python script?
*A3: The simplest route is probably to use IDLE, or the Python ""Integrated DeveLopment Environment".  A nice intro for complete beginners can be found [http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/index.html here].  Full documentation is [http://www.python.org/idle/doc/ here].
*Q4: "Can I edit Python scripts in <nowiki>[some editor]</nowiki>?"
*A4: IDLE comes with a built-in editor.  However, you can use pretty much any editor you want.  Just make sure you are saving your files as plain text (as opposed to rtf or doc).  Here is a list of [http://wiki.python.org/moin/PythonEditors editors] that are known to be compatible with Python.  I use an OS X editor called [http://macromates.com/ TextMate] which costs money but has amazing features and shortcuts (see screencasts [http://macromates.com/screencast/python_part_1.mov 1] and [http://www.rubyonrails.org/screencasts 2]).


==Tasks to complete by Feb 8==
==Tasks to complete by Feb 8==
Line 13: Line 20:
*Post your code to your personal calendar entry for Feb 8, along with the output when it is run.
*Post your code to your personal calendar entry for Feb 8, along with the output when it is run.
*Hints
*Hints
**The assignment calls for processing 10,000 strings. For easier debugging, you can initially write your code to process a smaller number.
**You may find it useful to read about the [http://docs.python.org/lib/module-random.html random] module, specifically "choice()"
**You may find it useful to read about the [http://docs.python.org/lib/module-random.html random] module, specifically "choice()"
**You can reuse a modified version of substring the matching "Method 2" from the first assignment
**You can reuse a modified version of substring the matching "Method 2" from the first assignment
Line 19: Line 27:
*General
*General
**If you are feeling really lost,check out the [http://wiki.python.org/moin/BeginnersGuide Beginner's Guide] to Python for more gentle introductions than we've provided so far.  It includes tutorials especially for non-programmers, like [http://www.hetland.org/python/instant-hacking.php this one].
**If you are feeling really lost,check out the [http://wiki.python.org/moin/BeginnersGuide Beginner's Guide] to Python for more gentle introductions than we've provided so far.  It includes tutorials especially for non-programmers, like [http://www.hetland.org/python/instant-hacking.php this one].
**Try to read the [http://docs.python.org/tut/tut.html Python tutorial].  Specifically, chapters [http://docs.python.org/tut/node5.html 3] and [http://docs.python.org/tut/node6.html 4].
**Try to read the [http://docs.python.org/tut/tut.html Python tutorial].  Specifically, chapters [http://docs.python.org/tut/node5.html 3] and [http://docs.python.org/tut/node6.html 4].
**Practice trying out different things that you do not understand.   
**Practice trying out different things that you do not understand.   

Latest revision as of 10:31, 8 February 2007

Biophysics 101: Genomics, Computing, and Economics

Home        People        Schedule        Project        Python        Help       

Q&A

  • Q1: "When I'm editing a page on the wiki, is there any way to do it in a box that is bigger than the single-line tiny editing box that comes up at first?"
  • A1: Visit the my preferences link in the upper right-hand corner of the page. Under the "Editing" tab, set Rows: 25, Columns: 80.
  • Q2: "How do I install BioPython on OS X?"
  • A2: The Python page has been updated with more detailed instructions.
  • Q3: "I've installed Python and can see programs like "Build Applet", "IDLE", and "Launcher". How do I actually run a Python script?
  • A3: The simplest route is probably to use IDLE, or the Python ""Integrated DeveLopment Environment". A nice intro for complete beginners can be found here. Full documentation is here.
  • Q4: "Can I edit Python scripts in [some editor]?"
  • A4: IDLE comes with a built-in editor. However, you can use pretty much any editor you want. Just make sure you are saving your files as plain text (as opposed to rtf or doc). Here is a list of editors that are known to be compatible with Python. I use an OS X editor called TextMate which costs money but has amazing features and shortcuts (see screencasts 1 and 2).

Tasks to complete by Feb 8

  • Complete Feb 1 tasks
  • Write a python script that generates 10,000 strings of 10 random coinflips (H or T) and outputs the tally of continguous (overlapping) stretches of 2, 3, 4, 5, 6, 7, 8, 9, and 10 H's or T's in that set of 10,000 10-mers.
  • Post your code to your personal calendar entry for Feb 8, along with the output when it is run.
  • Hints
    • The assignment calls for processing 10,000 strings. For easier debugging, you can initially write your code to process a smaller number.
    • You may find it useful to read about the random module, specifically "choice()"
    • You can reuse a modified version of substring the matching "Method 2" from the first assignment
    • If you have programming experience, try to do the exercise on your own
    • If you have no idea where to start, you can look at this template.
  • General
    • If you are feeling really lost,check out the Beginner's Guide to Python for more gentle introductions than we've provided so far. It includes tutorials especially for non-programmers, like this one.
    • Try to read the Python tutorial. Specifically, chapters 3 and 4.
    • Practice trying out different things that you do not understand.
    • Modify code and see if it does what you expect.
    • Use lots of print statements.
    • The range() Function is covered in chapter 4
    • List comprehensions and loops are covered in chapter 5
    • Spice up your I/O code by reading chapter 7