All posts
created: 09 Mar 2010 18:50
tags: chemcomm
Here the list of all the posts:
Scripting at all costs? No thanks
created: 07 Mar 2010 18:17
tags: scripting thoughts
Here some thoughts about scripting Vs manual donkey job. To clarify, is always better to do a script when we have to deal with repetitive tasks, such as file modification?
For instance, I usually have to work with gromacs and modify pdb files, topologies and other files, but I do this with Vi. why? Here my reasons.
Scripting is in general a good thing: allows to do things faster and better. In general. The downside is that to be valid, a script should be a good script, even in is a non-optimize code. And for "good" script I mean a well written bunch of lines of code: indented, commented, and flexible, both regarding the execution and the management of errors. This is an investment of time, which is good if we have always, exactly the same problem to solve, or the same task to do.
You have to calculate a distance between a list of coordinates? go with a script.
You have to do a sequence of bash command? do a script.
You have to read specific data from a well formatted file? go with a script.
You have to do something with data that vary from time to time or work with files that can have slightly different structures? Don't waste time with a script. It is much easier if we are the intelligent script rather than write one. So, we have just to find the right tools to to our job, in a fast and flexible way.
So, my idea is that when a script is starting to get an intricate sequence of if.. else if.. else ..for.. while… try… catch… etc. to try to deal with different type of input or output, better try to do by ourself the real thing, rather than waste weeks programming. For the well known Murphy's law, we will always find a situation in which our nice script of 100000 lines, fails.
So here we are, human scripts. boring, slow and likely to do mistakes. Or not? Likely, not… at least if you use linux and you are not afraid to learn a bit of bash and the supreme Vi. Here a practical example where having a script is totally useless:
Let's suppose I generate a polymer with my script and save it as pdb file. Now, I need to generate the Gromacs topology and I want to use pdb2gmx. Well, the pdb must then be adapted to the data in the Gromacs rtp file: atom names, residue names and residue numbers must be conveniently assigned, according to those in the rtp file. And all this, maintaining the pdb fix format. A script to do this should read the data in the rtp, understand where those data apply to the pdb file and modify the pdb in the proper way, keeping the right format. Rtp and pdb files can vary a lot from case to case and a script that will account for all the possibilities is out of reach. Much better do the things by our own, even if it seems a complicate (and boring) job. Nothing could be more wrong. Open your rtp in a vi terminal, open the pdb file in another and modify it using the substitution commands in vi and vi macros, defined on the fly. With a bit of experience, in 2 minutes a pdb of hundreds thousands of line is properly modified, ready to be used with pdb2gmx. ant 1min30sec will be used by vi… your job was finished after the first 30 sec:)
So, my idea is to do scripts when it is easy or difficult, but cannot be done otherwise in a simpler way. For the remaining cases, let your brain be the intelligent script, and manually use the powerful tools that are out there.
Comments: 0, Rating: 0
Gmail: easily manage more accounts
created: 07 Mar 2010 11:07
tags: gmail
I have recently switched my working mail to gmail. I did this for a numbers of reasons, much more space for storage and much better antispam rules in primis.
The problem was to find a way to easily check my working and personal accounts, both on gmail. I have tried to use the imap protocol and a client like mail (on osx) and thunderbird (on linux), but I was not happy with this solution. The main problem of using gmail with a client is the management of gmail labels, which are seen in the client as different mailbox: to avoid to have the same mail copied in many different mailbox in the client, a tricky configuration of gmail imap (with gmail lab) and the client is required. And the result is not sure.
So, the best is still use gmail with the web interface, but that means a continue login/logout to switch from an account to the other. I have search the web for possible solutions and what I found was even worst than setting an imap client: use to different browsers, install firefox plugins, use chrome in incognito browsing mode on a tab, etc.
By luck, I have found a nice and, I think, neat solution:
- Mac Users You can download for free the web application Gmail Browser (http://willmore.eu/software/gmailbrowser/). This little application allows you to remain signed in in your, let's say, working gmail, while personal mailbox can be checked as usual in your browser. Also, you can run google calendar and docs in gmail browser.
- Linux Users Unfortunately there is not a linux version of Gmail Browser, but there is another way to manage different accounts. Again, the solution is to use a web application for prism, a simple XULRunner based browser that hosts web applications without the normal web browser user interface. There are many web applications for prism: we will install prism-google-mail, but prism-google-docs, prism-google-calendar, prism-google-groups, prism-google-reader etc. are also available. Prism, prism-google-mail and the other wep applications can be easily installed in ubuntu via synaptic. Again, the secondary account can bemanaged normally via web.
Hope this can help you with your google-based world ;)
Comments: 0, Rating: 0