Friday, December 20, 2013

Public funding of databases

 I've been meaning to comment on this ever since I read about it. The grants that support TAIR are running out and they are going to switch to a subscription fee system. Some formerly open databases such as KEGG have already partially or completely moved their data behind a paywall, and it seems to be a better option than closing up shop completely. You can't really blame the administrators, they're just doing what they have to do to keep the information available to those who need it most. And I'm not particularly worried about my own access to TAIR because given number of labs working on Arabidopsis at my institution I'm sure they'll get a subscription. What I'm worried about is the fragmentation of data, groups may have trouble justifying paying for access to a database that is outside their core specialty, even if the database may be of great help to one or two particular projects. It also has an impact on reproducibility, researchers are more likely to verify, and then follow up and build on previous studies if the data behind those studies is freely available. Finally, I think paywalls will discourage scientists from using database resources even when they might be part of the best and most efficient way to approach a problem. Science is about exploring, and the easier and cheaper it is to explore different approaches to a problem the better the resulting research will be.

I don't know what the best solution to this problem is. Maybe user fees really are the way to go. It seems like one way or another the grant agencies are going to end up paying for database maintenance, either through direct support or through support of the projects that have to pay subscription fees. Maybe database grants should include some kind of an endowment to keep the information open for many years. Whatever the case, I think it is a reflection of the sad state society that important resources like TAIR, with users across the country and world who are using it as a tool to help improve peoples lives, have to struggle to find find funding, meanwhile the NSA has a black hole budget to fund massive spy databases where the vast majority of the data will never be looked at or used by anyone at all. The American government has some strange priorities, and I don't think representatives spend enough time worrying about opportunity costs.

Thursday, December 19, 2013

Combining the contents of multiple word files with a win32 com Python script

A former member of the lab used to keep his lab notebook as word files. One word file per day. For 8 years. Searching through these files was a real pain, so I decided to try to combine them all into one single massive file that will hopefully be easier to search through and convert to other formats.

anaconda python 3.3 on Windows

I've been using python 2.7, however it seems that now most of the libraries I use are compatible with 64-bit python 3.3 (for some, such as Biopython, there is no official python 3.3 binary, but they are available here). The one package that keeps me from breaking away from python 2.7 for good is Gurobi, which still has no python 3 support.

My main operating systems are Windows 7 and Windows 8, when I need Linux (which is often) I run it through VirtualBox.

After a few years of playing around with different Python distributions, I've found Anaconda python to be the least frustrating option, it also makes it easy to switch between two versions of Python.

Wednesday, September 25, 2013

Learning about DNA topology by playing with string

The only way I was ever able to get any kind of intuitive feel for DNA topology was to play with string, twisting it, wrapping it, untwisting it etc.
I made a video demonstrating some ways model DNA structures with string, so grab some string and follow along!



(also my first foray into youtube, I'm not sure if or when I'll ever post anything else there though, but I think this turned out ok)

Friday, September 6, 2013

python crossplatform handling of wildcard command line arguments

Windows and Linux shells handle wildcard arguments differently. Linux (at least under bash) expands wildcard arguments before passing them to a program. Windows passes them without expanding them. This leads to trouble if you want to write a command line utility that will work correctly in both Linux and Windows (or even one compatible with wildcard arguments at all in Windows).
In Python, the typical way to expand a wildcard is with the glob module.
either: glob.glob to return a list, or glob.iglob to return an iterator (which may be preferable if a large list is expected).

Here's a solution that uses the argparse and glob modules:
import argparse  
from glob import glob  
   
def main(file_names):  
    print file_names  
   
if __name__ == "__main__":  
    parser = argparse.ArgumentParser()  
    parser.add_argument("file_names", nargs='*') 
    #nargs='*' tells it to combine all positional arguments into a single list  
    args = parser.parse_args()  
    file_names = list()  
   
    #go through all of the arguments and replace ones with wildcards with the expansion
    #if a string does not contain a wildcard, glob will return it as is.
    for arg in args.file_names:  
        file_names += glob(arg)  
     
    main(file_names)
One caveat is that I have noticed that python and bash don't sort the expanded lists in the same way, so if for some reason you need deterministic sorting of input, you should sort the resulting list yourself.


see also: http://stackoverflow.com/questions/12501761/passing-multple-files-with-asterisk-to-python-shell-in-windows

Thursday, August 22, 2013

Instantiating generic BioCyc (MetaCyc) reactions

Most databases of metabolic reactions include reactions that are generic. That is, some of the reactants and/or products are not specific molecules, but classes of molecules. This is a wonderfully abstract way of representing a large number of chemical transformations with a simple notation.
An example of a generic reaction is the CARBOXYLESTERASE-RXN in MetaCyc, which has the formula:  a carboxylic ester + water <=> an alcohol + a carboxylate + a proton

As useful and elegant as generic reactions are, they present a problem for people trying to generate mathematical models from a database.  The problem is that most mathematical modeling frameworks do not know how to deal with generic reactions.*  So reactions in mathematical models should generally be balanced and unambiguous.

Latendresse et al. (2012) describe a strategy for generating specific reactions ("instances") from generic reactions from the BioCyc family of databases.  Their strategy is to enumerate all possible combinations of reactants and products for a generic reaction, then check for mass balance. The set of mass balanced instances is further filtered by removing instances that include a reactant or product that appears in more than one balanced instance, as such instances are regarded as ambiguous. They also treat polymerization reactions as a special case and handle them differently from other instantiations.

Thursday, July 25, 2013

Is frivilous spending good for the economy?

Basically it comes down to how you define that vague concept of a 'good economy', if you define it as sheer material/monetary throughput in a particular day or month, then it is hard to argue that indiscriminate consumption isn't good for the "economy". But I tend to define a "good economy" as in terms of the health, happiness, and longevity of the people within that economy. And I think that politicians, advertisers, and economists (perhaps not economists), and the people who pay attention to them and are influenced by them, implicitly hold a definition of a "good economy" that is similar to my definition. When politicians (or whoever) promise to "stimulate" the economy, what they mean (or at least what I think most people take them to mean) is that they will cause people to produce more stuff and exchange more money and therefore quality of life will increase. If they only meant the first part without the second part, that is: "production will increase but quality of life will stay the same or decrease", then there would be no reason to elect them to office, follow their advice, or pay any attention to them because what they would essentially be saying is "I promise you will work harder but not be any happier." And there would be nothing "good" about that kind of an economy. So when people talk about "stimulating" the economy, I'm sure they do mean "causing people to produce more stuff and exchange more money," but there is a widespread assumption (a kind of cultural myth) that more production/consumption/money_exchange (regardless of what exactly is being produced and consumed) leads to a higher quality of life. But on examination, that assumption is revealed to be totally false, in fact it matters a great deal what is being produced/consumed, and how much time is being spent to produce it. In a truly "good" economy, we'd all work very few hours, enough to produce whatever food and technology we need to be happy and healthy, and spend the rest of our time doing whatever we enjoy, which I think for many people would not include making things or handing money around (there is a counter argument that could be made here, contending that excess leisure time would mean wasted potential, i.e. that people could be spending their time improving medical technology etc. instead of just taking it easy, but that argument would still have to agree with the main point I'm making here, which is that producing and consuming "frivolous" consumer goods is bad for everyone). To determine whether a particular product or service is frivolous, you only have to ask yourself one question "would I be any less happy/healthy/long-lived if I had just given that person my money in exchange for nothing rather than in exchange for whatever they had to spend time producing?" In light of the above discussion, it can be seen that the other person would be better off had they not had to waste their time producing stuff for you, so if you would be not be proportionately worse off without the item, then you have just spent frivolously and not helped anyone at all (notably, nearly all government military spending falls into this category, but that's another discussion entirely...), not even the economy.

(as is probably obvious from the style here, this was written for the purpose of arguing with someone on Facebook, not as an essay for a class like the previous four posts)