Sat, 29 Apr 2006
For example, during writing some code I realized I was getting protein IDs with their version numbers, e.g. NP_10023.1, while I just wanted to get the IDs. These are the kind of minor roadblocks that you always have when dealing with bioinformatics databases. Now, here the version number is preceded by a dot, ".". So, in English, the logic goes like this: "if the word has a '.' in it, then find the position of '.' in the string and take the part before the position". Here's the Python code:
if '.' in word:
That's it. Now, the point is not to show that this really short example couldn't be done in some other language in an equally short way, if not shorter. The point is: what I think is essentially what I have to write. I don't need to remember what the language's equivalent of strchr() would be. The most obvious thing ('.' in word) works. That makes coding much more natural.