Python Crash Course — 4/5ths done!

This week is going to be crowded enough for me that I’m going to cancel this week’s class. On the bright side, the classes have gone better than I thought it would. We will continue on February 9th.

The very first class ended up being too short, with the advanced students feeling that it moved too slowly. The second and third classes ended up being just the right speed– with the exception that the example fill-in-the-blank script from the third class was too difficult.

The difficulty rose when I too quickly introduced dictionaries whose values are lists.

The fourth class held last week was excellent– I completely ditched slides that week and produced five fill-in-the-blank scripts that were just the right tempo for everyone. I had a good mix of BIC (Bioinformatics Club), iGEM and chemistry graduate students– all who attended got something out of the hour which was my objective.

We only had time for four out of the five scripts with the remaining script as a bonus that everyone could take home and try.

Now, it’s back to Structural Bioinformatics homework… It’s quite a daunting assignment to be true (having just formally shaken hands with Singular Value Decomposition), but the parts that are Python (particularly the bonus question) are familiar enough for comfort.

Tags:

Update: General Anesthesia – Risk for Women, Canada.

This is a more balanced article about the issue found in The Hamilton Spectator.

“Disclosure of pelvic exams in question” (Joanna Frketich); found at the following address.

http://www.thespec.com/News/Local/article/714924

Summary, origin of the phenomenon, contrasts with previously posted article:

  • A study was published (found here, “Education” — http://www.sogc.org/jogc/currentissue_e.aspx – accessed Jan 2010)
  • Pelvic exams are integral to some surgeries, part of determining proper treatment
  • A pelvic exam is performed three times, once by each a doctor, a resident, a medical student
  • Contrast to Mr. Picard’s article posted previously indicating a ‘parade’ of students
  • The actual problem is whether or not the single student on the team has been given direct consent
  • Whereas what is thought of as implied is that the team is given consent as a whole (opinions, practices will change)
  • Article goes on to indicate that this consent for each individual should be (will become) the norm

Thoughts, Conclusion:

Med students should be taught to practice — My feeling is that communication is the primary problem: the ratio of women polled that were asked explicit consent for medical students to perform the pelvic exam should have been greater.

The latter article by Frketich revisits the problem but discusses it far more calmly (so as to not break the brains of her readers). It even cites several women healthcare professionals for the inside scoop– something we didn’t get with the former article. We end up with a picture that states what we have always taken for granted in Canada– that when a problem is discovered, it is fixed– in this case, it’s communication between healthcare professionals and patients.

As mentioned in my previous post– it is an object of pride that Canada has excellent healthcare– which is the reason for the dismay, my personal dismay at even the subtle hint let alone a full blown implication of “something this wrong” with the system. If you become a surgery patient at any point, keep informed and ask the right questions: “Who’s going to be operating on me?”, “Who’s going to do the pelvic examination?”. This is the solution that taps the original problem stated: that women just didn’t know what happened for lack of communication.

Notes:

BCC’d to the same individuals contacted yesterday.


[...] Ed’s Blog … other posts by KittyCATBear [...]

Tags: , , , , ,

General Anesthesia – Risk for Women, Canada.

Update: Please see this post written the next day.

Update: Continuing to research issue– see a list of teaching hospitals in Canada: http://www.caho-hospitals.com/member_hospitals.aspx — I need to find out more: Is it true? How widespread is the problem; etc.

Sent from me to many friends via e-mail with BCC earlier today.

Hi All,

This story is deeply disturbing. Women who are under general
anesthetic in hospital recovery rooms can be subject to routine
examination by med students without consent in Canada. This is a
strict violation of everything a scientist would believe with respect
to human health and dignity.

http://www.theglobeandmail.com/life/health/time-to-end-pelvic-exams-done-without-consent/article1447337/

Please have a look and figure out if what action you’d like to take.
Spreading the word, figuring out who knows what and the extent of the
problem are good steps (self-education, personal preventative measures
etc.).

Conversely, if you can verify that this is a myth– that can also be
good (puts minds at ease).

At the very least, bringing up a petition or a stronger public
presence of the problem are both possible.

Thanks,
Eddie Ma

Tags: , , , ,

Generic Functions in C# and Java

The most fun and productive concept in object oriented programming is generics– for me anyway. In C, one could deploy generics hazardously with code that casts the contents of memory addresses with a putative structure. The first field gives away what that chunk of memory is supposed to be at run time. I still do that when it’s called for, but it’s quite delicate and often leads to insidious bugs that don’t crash immediately. At least one would know what code to suspect when crashes do happen.

In C# and Java, two languages that derive from, while leaving C compatibility behind– we find full deployment of generics. Generic classes are interesting, and I’m sure most who have used either of these languages have already played with them and have found them useful. One of the things that don’t receive a healthy dose of spotlight is Generic Functions (I suppose “Generic Methods” if you like). I suspect these aren’t talked about as much because it’s usually a consideration for static methods that “tack on” functionality to the generic classes that already exist– and why tack on, if you design a class completely from the start? No matter– This is useful to me, so it may be useful to you too.

I present below two chunks of code– one in C# and one in Java that do exactly the same thing– demonstrate a trivial function “PrintArrayList” that pumps out the contents of an ArrayList (Java) or a List (C#), both of which would be generic objects. This shows how one single function can operate on multiple types without the need for unsafe casting. The only assumption the code makes is that each object in (Array)?List implements the [tT]oString() method.

Java: C#:
//Main differences:
//Some method names are lowercase, few syntax differences
package main;
import java.util.ArrayList;

public class Main {

  public static void main(String[] args) {
    ArrayList<Integer> cow = new ArrayList<Integer>();
    ArrayList<Double> dog = new ArrayList<Double>();
    ArrayList<String> elephant = new ArrayList<String>();

    for(int i = 0; i < 10; i ++) {
      cow.add(3 * i);
      dog.add(0.25 * i);
      if(i % 2 == 0)
        elephant.add("Even");
      else
        elephant.add("Odd");
      }

      PrintArrayList(cow);
      PrintArrayList(dog);
      PrintArrayList(elephant);
      }

    static <A> void PrintArrayList(ArrayList<A> animalList) {
      for(A a : animalList)
        System.out.print(a.toString() + "\t");
      System.out.println();
    }
}
using System;
using System.Collections.Generic;

namespace CSGenericFnTest {
  class MainClass {

    public static void Main (string[] args) {
      List<int> cow = new List<int>();
      List<double> dog = new List<double>();
      List<string> elephant = new List<string>();

      for(int i = 0; i < 10; i ++) {
        cow.Add(3 * i);
        dog.Add(0.25 * i);
        if(i % 2 == 0)
          elephant.Add("Even");
        else
          elephant.Add("Odd");
      }

      PrintArrayList(cow);
      PrintArrayList(dog);
      PrintArrayList(elephant);
      }

    static void PrintArrayList<A>(List<A> animalList) {
      foreach(A a in animalList)
        Console.Write(a.ToString() + "\t");
      Console.WriteLine();
    }
  }
}

Three generic list objects, cow, dog and elephant are constructed; in a for loop, each gets ten elements. Each list contains objects of a particular type; cow contains integers, dog contains doubles and elephant contains strings.

Output:

0	3	6	9	12	15	18	21	24	27
0.0	0.25	0.5	0.75	1.0	1.25	1.5	1.75	2.0	2.25
Even	Odd	Even	Odd	Even	Odd	Even	Odd	Even	Odd

Tags: , , , ,

First UWiGEM modeling meeting: Wed. Jan. 21 @6pm

Update: The Gleave Library, B1-273 has been booked for this occasion!

Brief: The two software projects that will precede the main body of Waterloo iGEM 2010 will be discussed on Wednesday January 21 from 6pm to 8pm. I will update this post once a room booking has been confirmed.

Related topic here on the Waterloo iGEM Discussion Board.

Tags: , , ,

Fight e-mail address typos with MD5 hashes :P

Silly: One day, Dave messaged me and said that his e-mails weren’t getting through to me. I was puzzled as he was using the g-talk service, meaning he has my valid g-mail handle. As it turns out, the device he was on didn’t have copy and paste available for that field, and he simply couldn’t see the ‘t’ in my address.

Incidentally, that’s one dysfunction of the human visual system I’d like to purge– reading something over and over, only to make exactly the same lexicographical mistake each time. It’s an evil broken heuristic… remember kids, it’s a ‘feature’, not a ‘bug’.

I then messaged him the MD5 hash of my e-mail address along with the one for the incorrect address…

Correct:   2f776881db0ca037c145e74a6c41721c
Incorrect: 35c56bee61e9914929f4a3242d44c339

Don’t worry, there’s no practical value in doing this :P

Note: to get the MD5 of an arbitrary string on a *nix system, just type this in the terminal…

echo "arbitrary string" | MD5

It almost amuses me as much as catting arbitrary binary files…

Tags: , , ,

fsMSA Algorithm Context

What started as a meeting between me and my advisors ended up being a ball of unresolved questions about the cultural context of multiple sequence alignment and phylogenetic trees. While I had a good idea of what the field and its researchers had looked into and developed, I hadn’t a grasp of how far along we were. The result is the presentation I’ve just finished. In it, I discuss what I consider to be a representative sampling of the alignment and phylogenetic tree building algorithms available right now, at this very instant.

(PDF not posted, contact me if interested.)

Tags: , , , , ,

Python Crash Course – Lesson 1

The first lecture of my Python Crash Course went really well! I ran it two evenings ago in the Dean’s Conference Room.

In gearing the very first lecture for absolute beginners, I had very little to cater to BIC (Bioinformatics Club) members. I however took the opportunity to discuss with them about the SOLVER group (more on that later); many of which seemed interested.

Overall there were roughly a dozen people that turned out, including Ariana, my TA partner from last term. There were about four iGEM members and six BIC members.

I also took the opportunity to poll for the kinds of things that students wanted to learn. Here are my findings.

  • Object Orientation is something everyone wants to know– especially the people coming in with a Javascript, PERL, C, C++ and Scheme background; I was surprised that the C++ people didn’t get exposure to thinking in objects earlier.
  • The beginners came in two groups. First, there are the ones who are happy to learn anything as long as it can be applied later.
  • The second group of beginners want to data crunch PDBs, SDFs, FASTAs, Nucleotides etc.

In week two, we’ll take care of object orientation and in week three, we’ll take care of everything anyone ever needs to know about input output in order to do data crunching. I have added a link in the navigation of this blog for the Python Crash Courseware which will eventually include all the PDFs, code modules and examples used in class.

Oh right, I don’t know if I’ll get around to it– but I am missing instructions for setting environment variables in Windows. Perhaps I will add it later when I have time.

(iGEM attendees were John Heil, Danielle Nash, Tiffany and Lina; BIC members included Fiona, James and about four others whose names I have forgotten.)

Edit: Direct link to Python Crash Courseware; Direct link to Week 1: A Mad Mad Introduction, PDF.

Tags: , , ,

Apache Optimized Finally! (Firebug, YSlow)

I didn’t realize I hadn’t added the mod_expires.c and mod_deflate.c items to my httpd.conf file in Apache yet– Andre clued me in!

Andre noticed my blog was taking a while to load, even when the browser cache should have significantly dented the page weight. He used Firebug and Yahoo’s YSlow to make a diagnosis and told me to do the same– this page ended up taking a whopping 17 seconds to load which is … very … sad. After I added these lines to my httpd.conf file, things were looking better (roughly 1.5 seconds — not perfect, but it’s far better).

The mod_expires.c chunk specifies that files displayed on a webpage ought to live in the browser cache. The caching information is sent as part of the file header by Apache to the client browser. Without this, files were apparently expiring instantly meaning that each refresh required downloading every single file again including including the images comprising this theme’s background.

The mod_deflate.c chunk specifies that file data should be gzipped before transmitting– this is again handled by Apache. The trade off between compressing a few text files (even dynamically generated ones) versus sending uncompressed text is more than fair.

<IfModule mod_expires.c>
    FileETag MTime Size
    ExpiresActive On
    ExpiresByType image/gif "access plus 2 months"
    ExpiresByType image/png "access plus 2 months"
    ExpiresByType image/jpeg "access plus 2 months"
    ExpiresByType text/css "access plus 2 months"
    ExpiresByType application/js "access plus 2 months"
    ExpiresByType application/javascript "access plus 2 months"
    ExpiresByType application/x-javascript "access plus 2 months"
</IfModule>

<IfModule mod_deflate.c>
    # these are known to be safe with MSIE 6
    AddOutputFilterByType DEFLATE text/html text/plain text/xml

    # everything else may cause problems with MSIE 6
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE application/x-javascript
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/ecmascript
    AddOutputFilterByType DEFLATE application/rss+xml
</IfModule>

I’ve also removed the custom truetype font files specified in the CSS… they aren’t handled correctly for whatever reason– even after I added ‘font/ttf’ entries to the mod_expires.c chunk above. Finally, I tried completely removing background images from the site and restoring them again– it doesn’t make things any faster after images have been cached (correctly, finally).

I am very happy.

Tags: , , , , ,

Project management software I want to write

Update: if you’re from Waterloo iGEM and want to work on this with me, see here.

I’ve contemplated this for so long, I think it’s time to put the plans into writing– at least as a draft so I have something to build upon.

There are three pieces of software I’ve been wanting to write. The rules are simple. I’ve become so addicted to cloud computing, I wouldn’t even contemplate desktop applications– so this stuff will be browser powered and hosted on Zinc. Each piece of software must intuitively communicate with each other piece — this can only be done where logical as is discussed below. Each application must offer familiar interfaces, seemingly simple operation and few tunable parameters. Finally, this stuff should be released with a cheap as free (as in beer, birds and guilt) license.

Tarocchi – Task Rhythms

The first application is for time and task management, I call it tarocchi as in ‘tarot’ as in the cards– ironically to mean that we are masters of our own future (immediate or distant). As much as I contested the idea of working-sphere based task management, I came to realize that’s what I’d benefit from the most the more I analyzed what I was already doing. Of course, this is not quite as invasive/pervasive as a technology that would stop irrelevant phone calls or e-mails from reaching me– but it is designed to break a workday apart into manageable hour-long units.

Each hour, tarocchi’s heartless silicon clutches will deal the end user with a card that is inscribed with the task for the next hour. For individuals with many projects, this provides a visual cue to switch gears so as to not burn out from the given task. The user must accept the task for the time spent on it to be logged. Note that at any time within the hour-long time period, the user may accept the task however– just as with pausing a task in progress, tarocchi will only log the amount of time that the user has claimed to work but will not track work committed after the hour unit is complete.

At the time of card dealing, the user may comment on the previous card and indicate whether or not it has been completed so that it will be placed into a deck of finished tasks.

Although tarocchi has no soul, it is not meant to force the user to work but is designed to make it psychologically easier to let go of a current task, and to beat the early morning, mid-day and end-of-day mental blahs.

A user may opt to reject a dealt card, whereupon tarocchi will ask if a break is needed, or if another card should be drawn. If the user manages to exhaust the entire remaining deck by rejecting them all, tarocchi will shuffle the cards and present the deck again. Tarocchi doesn’t operate completely at random, a few heuristics and user defined parameters tune how often, how long and in what order tasks may occur. There is also a facility to specifically tune when a particular deck should be played (date, time)– this functionality will make more sense after seeing mastermind and jigsaw.

Tarocchi has a guest mode which allows a logged-off user to browse the deck, each tasks’ progress and time into the current task of a named user, should that user have made the given card, deck or their own profile available for prying eyes. This guest interface doubles as the weekly report generated by tarocchi that allows the user to self-analyze how much time they spent on each task– which tasks were more often rejected, accepted, had breaks put in etc..

Mastermind – Team Brains

The second application fills a niche for iGEM, I call it mastermind. Mastermind is software designed to delegate tasks for a given team of individuals and to keep track of milestones. I will first describe mastermind as a stand alone. The guest-level interface shows the progress of particular projects, and its logical milestones. There is no enforcement on how large these milestones can be, as mastermind does not attempt to comprehend real-world implications, only to represent supervisors’ comprehension of tasks. Milestones should never be deleted, and have a five-valence progress descriptor: preproduction, churning, done, aborted, and paused. Tagged with each task or milestone are descriptions, notes, messages, links to materials they represent and other references. The guest may browse essentially the deliverable history of the team.

The user-level interface allows a user to own a particular task, edit its contents and to change its progress– additionally, users may break a long task into smaller logical tasks while supervisor-level interface additionally allows the creation and delegation of tasks and the administration of users.

Mastermind does not inherently keep track of time spent on milestones, only the materials used and how complete each milestone and task is. Mastermind does optionally keep track of when a particular project should be worked on by a specific user… this functionality will make more sense after you’ve read about jigsaw.

Tarocchi and Mastermind work together as follows. Mastermind would pass a deck of cards to Tarocchi corresponding to each of the teams and tasks that user has committed to. Tarocchi would then ask the user a few questions about priorities and shuffle these cards into its emotionless cultches to be dealt to the user. These cards also inherit the project descriptions provided by mastermind, and similarly these properties can be updated by every user with a copy of this card within tarocchi. Tarocchi would then tell mastermind whether or not the task depicted on the card has been completed, and also pass back the amount of time that was worked by this user. For tasks that mastermind has defined a specific time frame to be spent (date and time), the corresponding cards are not dealt unless the user has entered that frame. Mastermind tasks thus display the time spent on tasks per user through tarocchi.

Jigsaw – Scheduler

Jigsaw plays well with calendaring software such as google calendar. This is basically a revival of the scheduling software I was interested in being involved with. Basically, when shifts are to be assigned, wherein a specific number of people must show up in a given shift– where one must piecewise fit each person’s reported availability– jigsaw would magically puzzle the pieces into place. A supervisor defines the week, month or other time range they want filled, and what shifts exist. Users fill in their availability and guests may see the result. Users get an e-mail about which shifts they’ll take, may subscribe with RSS or export to an offline or online calendar. Little hitches like insufficient availability, users forgetting to report their availability, incorrect reports etc., can be resolved through automated messages to supervisors and users involved.

Jigsaw would likely communicate with Mastermind and Tarocchi as follows (if at all, as this gets complicated). Because there isn’t a clear logical entry point, I’ll have to make both jigsaw and mastermind applications that can begin the crosstalk. I generally avoid this kind of design because it is implicitly redundant– so in lieu of a better method, here we go. If a supervisor uses both jigsaw and mastermind and creates a task, they can specify on either that this task requires the other application. In mastermind, one would check off a box and indicate that this project must be scheduled in particular shifts. In jigsaw, one would indicate where these jigsawed shifts fit into the team’s projects. The functionality is far clearer from here. After all of the piecewise fitting is complete, jigsaw then tells mastermind who has been assigned to the task, and when. Mastermind does not communicate with jigsaw after this. Mastermind however does indicate to tarocchi when a particular project must and can only occur so that cards related to this project are dealt when a user enters a specific shift.

Overall

The interface that a user should see most often is tarocchi– it keeps often times overwhelming details of time management hidden while actual work is being done. Taking the worry away from choosing what to work on amongst self-defined, team-based and team-scheduled projects is a plus for people that have well defined tasks, but ill defined working schedules. No additional bloat such as chatting or person-to-person messaging should be added aside from the notes interface within mastermind– the focus is on simple, effective and time saving means to manage projects.

First Steps

I think I’ll develop a draft and specs for tarocchi while recruiting developers for tarocchi and mastermind.


Proworkflow says...

I’ve tried just about every system you can imagine, including testing and setting up three different project management apps for a virtual software company I used to work for before I started working for myself. I found all of them lacking to be honest.

Tags: , , , , ,