Autarchy of the Private Cave

Tiny bits of bioinformatics, [web-]programming etc

    • Archives

    • Recent comments

    Archive for June, 2009

    WolframAlpha: sophisticated online calculations resource

    29th June 2009

    If you ever need to glimpse at the properties of the Poisson distribution with lambda=0.16, or find the factorial of 6163338 (as a gamma function), then Wolfram|Alpha is a perfect tool for you (unless you have some math package at hand).

    The motto of Wolfram|Alpha is Making the world’s knowledge computable. Basically, it is like Mathematica plus a growing corpus of factual numeric data, plus a system to interpret user’s input. This is a nice online reference and computation platform.

    Share

    Posted in Links, Software, Web | No Comments »

    10 simple rules for getting published

    26th June 2009

    Recently, I have come across an excellent piece of advice called Ten simple rules for getting published. The only thing I have to add is that final rule #10 should be kept in mind while checking through all the previous rules – e.g. when editing someone’s submission, make sure that you are in position to be the editor for that article, and make sure your decision will influence chief editor’s decision – otherwise there’s no use reviewing.

    PLoS Computational Biology, where the “simple rules” were published, has a Ten simple rules collection, which includes a handful of other useful advice articles, like 10 simple rules for selecting a postdoctoral position.

    Share

    Posted in Links, Misc, Science | No Comments »

    My readers are natural-born workaholics

    12th June 2009

    Here’s the ultimate proof :) :

    visitors

    One can clearly see that on weekends the number of unique visitors of my blog drops drastically to about 40-50% of the working week average.

    And yes, that is an almost perfect 5+2 pattern, which I’m observing for many months, like a week-long circadian rhythm. “Almost perfect” must be due to the differences in time zones.

    I wonder if the same pattern is characteristic for most web-sites… That is, if people mostly do the browsing at work, and not at home.

    Anybody wants to share the secret cycles of one’s blog audience?

    Share

    Posted in Misc, Web | 2 Comments »

    C: how to specify comparison operators floating precision

    11th June 2009

    There is no way I’m aware of to do what the title says. However…

    I’m sure that you are aware of the fact that floats representation in any programming language is limited by the precision of the internal binary representations. In other words, you can never have an exact float representation – there will always be some precision associated with the float you are working with. The simplest example is the difference in precision between the float and double types in C.

    Suppose I have the following code fragment:
    [C] if ( result.score >= input->raw_cut_off ) [/C]

    Both result.score and input->raw_cut_off are of type float, and can have positive and negative values. When compared with the greater than or equal ( >= ) operator, it is not always that condition is true – for the precision reasons shortly mentioned above.

    As I already said, there is no precision specification for equality operators in C. But it is quite simple to “invent” precision specification; e.g. if I wanted to test for equality only, I could write
    [C] if ( fabsf( result.score – input->raw_cut_off ) < 0.000001 )[/C] In this example, I'm effectively asking for 6-digit precision for the equality comparison of floating-point values. Note, that if you replace that 0.000001 with the actual precision limit of the floating type you are using, you will be "exactly" comparing floating-point numbers - up to that type's precision, of course :) .

    The first-most example with the >= operator can be rewritten as
    [C] if ( result.score > ( input->raw_cut_off – precision) ) [/C]
    where precision is exactly what it is named, e.g. precision = 0.000001.

    Sources used:

    Share

    Posted in how-to, Programming | No Comments »

    Best method to recursively chmod/process files or directories

    8th June 2009

    Found here.

    Recursively set directories only to drwx-rx-rx (755):

    find . -type d -exec chmod 755 {} \;

    Recursively set files only to rwx-r-r (644):

    find . -type f -exec chmod 644 {} \;

    Recursively remove carriage returns (^M) from the end of all *.php files:

    find . -type f -name “*.php” -exec /home/user/dos2unix.sh {} \;

    In all these cases, {} is replaced with the filename/directory find has found matching your parameters; \; at the end just stops exec processing.

    Share

    Posted in *nix, how-to, Links, Notepad | No Comments »

    Debugging PHP: Eclipse PDT + XDebug + XDebug helper

    8th June 2009

    Stimulated by a bug in a complex and unfamiliar web PHP application with heaps of custom tweaks by other programmers, I decided to try a more professional approach to PHP programming and debugging than the standard var_dump() and family.

    As a result, I’m now using Eclipse PDT with Xdebug and Xdebug Helper (Firefox extension). Now I don’t understand how I used to debug my PHP programs before!

    After proper configuration (I’m using local Apache, but it is also possible to debug remotely), my work flow is rather simple:

    • use my web-app as usual, e.g. tweaking and testing here and there
    • if something server-side goes wrong: click the XDebug helper icon in Firefox, and perform some server-request action (e.g. load a page)
    • debugging is started in Eclipse PDT, where I can step through the code, set breakpoints, and examine all variables
    • as soon as the problem is fixed – click the XDebug helper icon again to continue using the site normally (w/o invoking the debugger)

    It takes some time to get used to, but then it’s a breeze.

    Some advice:

    • don’t use apt-get/aptitude to install Eclipse; it will be much easier both in the short and long run to use some all-in-one package from the Eclipse PDT site; all you need to do – download, extract, run!
    • before actually starting to do anything, tweak the eclipse.ini file by increasing heap size from 40 MiB (default) to some larger value (I used 128MiB). If you don’t do this, then at some point your debugging will become painfully sloooow, and then you’ll start getting tons of “out of heap memory” errors, each one suggesting that you quit Eclipse immediately
    • install XDebug with apt-get/aptitude – worked perfectly, and there’s /etc/php5/conf.d/xdebug.ini not to mess with php.ini
    • do read XDebug guide for PDT 2.x (I’m assuming you got the 2.x version); it should be the only document you will really need to configure everything

    I only wish Eclipse was faster – that is, written not in Java but e.g. C or C++.

    Share

    Posted in Links, PHP, Programming, Software | 3 Comments »

    GNU make for bioinformatics presentation

    5th June 2009

    Giovanni Dall’olio has recently posted a presentation on using make.

    Although it has “bioinformatics” on the title page, this is a good and very easy to understand make intro.

    Original post is here.

    Share

    Posted in Bioinformatics, Links, Programming | 1 Comment »