Monday, November 23, 2015

Live Molecule search: a quick hack using JSME, Cactus, AngularJS and BootStrap

For an internal project, I needed a web control that will display the structure of the molecule as I type in the name (or SMILES, CAS number, IUPAC name or a host of other ways you can textually describe a molecule in one line). Now this is not really easy, but thanks to the some open APIs provided by the CADD group at NIH/NCI (http://cactus.nci.nih.gov), it was really easy to get this done.

Here is a quick overview of the hack I wrote. The code for the same is available on GitHub (https://github.com/tovganesh/mol-auto-view.js)

The final control. You give a molecule description, the molecule appears in draw area, click "Save to list" and it gets saved to a list that is depicted on the right hand side.


The Cactus (http://cactus.nci.nih.gov/chemical/structure)

The molecule description can be given in various ways, and it usually a very tiresome task to think through and write interpreters. One can of course use tools like Open Babel or CDK, but a more cleaner interface is a web service offered by NCI, called the Cactus. A simple API call as follows,
gives you a mol file that can be viewed:

http://cactus.nci.nih.gov/chemical/structure/[Molecule Description]/pdf


JSME (http://peter-ertl.com/jsme/)

Next to view this structure, I use the simple but powerful 2D molecule drawing tool by Peter Ertl and Bruno Bienfait (http://peter-ertl.com/jsme/)

I, particularly use the following API:

jsmeApplet.reset();
jsmeApplet.readMolFile(dataFromCactusAPICall);


The above call is the clear the drawing area, and read in the new molecule file obtained from call to the Cactus API.

Next, I need to get the molecule file data from JSME and well as a graphics representation to show in a list. This is does using the following API call:

molFile: jsmeApplet.molFile(),
molImage: btoa(jsmeApplet.getMolecularAreaGraphicsString())


The first call is for getting the molecule data, as a mol file. The second call is to get the graphics of the molecule as a SVG data, that is then encoded to base64.

Putting it all together: Angular JS and Bootstrap

Putting it all together required using Angular JS and some basic Bootstrap. The following is used for the text field that takes the molecule description:



The above code is used to fetch the mol data from giving a call to the cactus API, as you type the molecule text. The model change even is delayed by 750ms, so that the API call is only fired, when the user pauses for some time. 

Thats it! I hope you find it useful. To see the full code see Github: https://github.com/tovganesh/mol-auto-view.js



Monday, November 02, 2015

Change in MeTA Studio licensing

Starting today, the MeTA Studio code base will be re-licensed under a more permissive MIT license (https://opensource.org/licenses/MIT).

On a side note, if you are not already aware, the new active home for MeTA Studio is GitHub (https://github.com/tovganesh/metastudio/)

Wednesday, October 21, 2015

ViTAL Lite : An app for computational genotoxicity alerts

Computational toxicity assessment is a mandatory regulatory requirement for pharma industry. A number of companies provide these services to pharma companies. ViTAL (http://www.vlifesciences.com/products/ViTAL/Product_ViTAL.php) is one of the industries most comprehensive, regulatory compliant reporting service offered by VLife Sciences (a division of Novalead Pharma Pvt. Ltd.).

If however, you are looking for a quick way to check computational toxicity alerts for molecules, VLife Sciences has introduced an Android app for the same. Check out the app at: https://play.google.com/store/apps/details?id=com.vlife.vitalite

PS: The ViTAL service, provides a more comprehensive regulatory compliant report (literature survey, multiple updated toxicity models etc.), where as the ViTAL Lite app provides a simple alert indicating probability of the molecule being genotoxic and/or carcinogenic.

PPS: I work for VLife Science.

Sunday, October 18, 2015

Running mobihf on the iPhone

mobihf (https://sites.google.com/site/tovganesh/s60) is a code that I wrote almost a decade ago on my first phone: the Nokia 6600. mobihf was meant to be an educational tool on how to write a basic Hartree-Fock Quantum Chemistry code from scratch, and to me it was a way to experiment on how much can I push the mobile device to do scientific number crunching. At that time the processing power of my mobile was just about 100MHz with just about 10MB of RAM! And now I have this two year old iPhone 5s that has a 1.3GHz 64 bit processor, with about 1GB of RAM.

To test out how things have panned out for my purely Python mobihf (not the C++ integral code that I wrote later), I tried a number of Python interpreters available on the Apple App store.  While Python for iOS (https://itunes.apple.com/us/app/python-2.7-for-ios/id485729872?mt=8) seemed like a good choice, its editor was never able to even load the mobihf script to do anything meaningful. A mail to the developer did not get me any response (as of this writing).

Next up was pythoni (https://itunes.apple.com/in/app/pythoni-run-code-autocomplete/id493505744?mt=8). This is surprisingly well written app with custom keyboard shortcuts and well made editor for editing Python scripts. It is worth buying the pro features in this app if you do a lot of Python programming on the move. So, finally I was able to run the pure Python mobihf code (available from GitHub: https://github.com/tovganesh/myrepo/blob/master/mobihf.py). This code is heavy on numeric computations (evaluations of exponential functions, matrix and vector algebra etc.). Without going into the details of what the code does, I typically run two test cases to see how things are going. These are for two very simple molecules: H2 (hydrogen molecule) and H2O (water molecule) at a basis level called STO-3G. All very basic to the one who knows Quantum Chemistry, and pretty much a jargon to the rest ;-) Since I am using iOS9, I decided to run the job in two modes: once with battery saver on and another without.


As can be observed above, even with battery saver on, there is 50 to 65 times improvements in the timings over the same pure Python. And, to top it the timings also handsomely beat the C++ compiled code on the old phone.



With the battery saver turned off, the performance improves as expected. What is surprising however is that in comparison to when the battery saver is on, the performance improvement is about 60%. That is quite a hit to keep the phone going for longer. I wish we have some radical improvements in the battery technology so that we can keep enjoying our devices at full speed.

The next app was Sketch Python (https://itunes.apple.com/in/app/sketch-python/id984990674?mt=8). There are a number of different Python implementations and each can give you a different performance numbers. So far I have found Sketch Python to be the fastest.

With the battery saver on, Sketch Python performs almost as fast as pythoni with battery saver off. That says a lot about the performance of Sketch Python interpreter, especially in handling Python code with heavy numeric computation.


The performance of Sketch Python to run mobihf increases substantially when battery saver is off, and is probably the best timing that I can get on the A7 processor of iPhone 5s. If you do the math, this is 140-166 times faster than the pure Python code that ran on my Nokia 6600 a decade ago. In comparison to the C++ (native code) running on Nokia 6600, the gains are an order of magnitude times less, but still impressive. I am sure if I port this code over to native, we can do pretty complicated Quantum chemical calculations on the phone. The newer A9 processor in iPhone 6s or the Qualcomm processors (8-core 810 or higher), would be interesting processors to see the current state. But I can say that these mobile processors have reached the performance levels of the most desktop processors for all practical purposes. And this is exactly that I had in mind when I took a look at the ability to run scientific codes on mobile processors (https://sites.google.com/site/tovganesh/s60).

On a different note, the ARM architecture also makes an interesting case for computational codes because of the low power requirement, a topic I briefly touched, but now studied much deeper by Kristopher et.al. (http://pubs.acs.org/doi/abs/10.1021/acs.jctc.5b00713). Alistair Rendell, my postdoc guide, is a co-author in this paper, so it must be real good :)

Note: The experiments above were run 5 times, and the lowest time was taken.
PS: This post has been since mentioned on MacInChem.org (http://www.macinchem.org/blog/files/0c7f90a37910d2ed90402dcddb6cf4e2-1814.php)



Wednesday, August 19, 2015

ambado.js - releasing an experimental, lighweight and fast web app framework

I am a releasing a new open source project called ambado.js, which aims to build a lightweight and fast web app framework. It is experimental, so I will try a lot of ideas I have in mind, and is not really useful for production releases at the moment.

I have been building a number of webapps for our company (www.vlifesciences.com) for consolidating various platforms and services that we offer (drug discovery, toxicity etc.). One of the issues I have been observed during these developments was that of the load time for these apps, which are a lot dependent on loading of the initial scripts, html, css and images. There is no particular emphasis on caching in most frameworks, that would have improved quite a bit of load time and ultimately user experience. Recently though, I found basket.js (http://addyosmani.github.io/basket.js/), which is a wonderful library that does caching. Although, basket.js does a good job, I wanted to extend the idea to a framework that uses the concept of caching itself from ground up, rather than attaching the piece of code externally.

So two days ago, I started putting some basic code together, and now I feel it is kind of usable for the world to see and progress further. The code is hosted on GitHub, and is called ambado.js (https://github.com/tovganesh/ambado.js). ambado.js uses lazy but aggressive loading of resources, currently using the basket.js library. Additionally, it provides a simple framework to build very simplistic UI.

P.S:
Ambado, by the way, is Konkani for Indian Hog Plum (https://www.flickr.com/photos/dinesh_valke/3393914087). We also use it to make pickles, which I love taking with plain rice :-) Although, I only recently tasted it after almost a decade!

PPS:
ambado.js is at a very early stage, things are going to break!

Sunday, July 19, 2015

And so I bought a flat ...

With the kind of crazy prices for property going around in the city I stay (Pune), I never thought I would buy a House. But I did end up buying a small flat. And it was an experience.

My mother always wanted me to buy a flat. I never liked the idea. For all my life, I have lived in a row house, and our house back home in Kerala is a small garden plot with a house. Moving to vertical arrangement, with no garden, no greenery, probably no birds to wake me up in the morning (I almost never use an alarm, it doesn't work for me) made me dislike the whole idea of buying a flat. I always used to argue with my mother, when she used to keep suggesting me places to look for. Two years ago, that stopped. She left us forever suddenly. I was completely lost and had no idea where my life was heading (I am still trying to figure out and learning every moment).

Somehow, last December, I had this thought of buying a small flat. A 1BHK one. So I started off the usual way I start finding anything: online. I registered on magicbricks.com. It was a disaster. I was literately spammed with emails and phone calls. I somehow managed to close my account with them. But in-between my e-mail apparently got leaked to other two sites and they apparently started spamming me. Thankfully, the GMail spam filters saved me from further point less e-mails. I must say that I didn't know about Housing.com at that point, probably my experience would have been better.

In the mean time I also registered on the DSK website saying I was looking for a 1BHK flat in or near Baner (as this is near to the place I currently work). I had known DSK as a builder largely because of the wonderful 'DSK Gappa' program they run on the Pune local Radio, where the main guy DS Kulkarni carries out a conversational program. The beauty of the program is that they never advertise that they are a great builder and they are building a new site, go look and buy. DS Kulkarni instead talks on varied subjects, and buying a house is one of the main subjects. In any case, with the kind of spamming I received from all the online sites, I was not really expecting anything from DSK. But suddenly out of blue, one Saturday I got a call from DSK office saying they have few flats for ready possession at DSK Gandhkosh project, which is walking distance from my Office. I indicated to them that I would like to visit the site. And did so the coming Monday. I was not expecting that I would like a flat at 10th floor, when for all my life I have lived on ground zero, with a garden besides. But as soon as I entered the flat, it reminded me of the small apartment that I had rented when I lived in Canberra, only a lot better, with a nice airy terrace. At the very moment I had decided that I would be buying this very unit and not the others he was going to show me. It was B1001. Perfect binary ;-)

Well I was not quite sure of price to what I was getting, so I negotiated a bit and they gave me some discount. Then I came back two days later with few of my office mates to just understand their perspective, on if I am doing the right thing buying this flat. They too liked the flat, and suggested that I buy it even if I may not like to stay always here! Well, maybe, I thought.

Next, did my father like it? So the next weekend we visited the site together. To my surprise, my father too liked the place. And so we decided to book the flat just few days before my 35th birthday. I have a habit of giving gifts to myself, since no one gifts me ;-)

Interactions I had with the builder (DSK), were one of the most pleasant one. Once I had decided to buy the flat, the obvious next question was finances. The DSK guys wanted me to give them an advance of 5L INR for booking. Which obviously was not immediately available in my bank account. So I gave a part payment and my Father said he will give me some from his savings, which would make up the amount. The next thing was the getting a loan. I had never taken a loan before and had absolutely no idea if anyone would ever give me a loan! DSK guys indicated to me that they have some special scheme running with HDFC that would get me a loan at 9.9% interest (at that time the market rate was 10.10%). Since I didn't do much survey, I agreed to meet the sales people from HDFC loan department.

From here, the interaction with HDFC has been quite whirlwind. At first the interaction was quite straightforward and appeared simple. But they kept demanding documents after documents. At one stage it was made to believe that it was compulsory to take a insurance for the loan, and was given only one option. Since the premium was too high, I was in two minds if I should at all go ahead with the purchase of the flat. Although my close friend, father and colleagues from office suggested me to look at alternatives. At each point I felt that there was a lot of communication issue with the people interacting with me at HDFC. In any case the loan got approved.

In the meantime, I signed the agreement with DSK and the deed was registered at the registrar office. The builder arranged for appropriate transport to the office and needed appointments with officials there. It went reasonably smooth.

After this, the agreement papers were collected by the HDFC people, and the loan got cleared for disbursement. Around this time I got a call from some other sales guy from HDFC Life informing me about an alternative insurance plan for loan, I quizzed him on why was this not indicated to me previously, and he excused it indicating earlier conversation as an oversight by the previous guy who contacted me. It was indicated to me that this plan would cover life, disability, fire, theft, natural disaster and a host of other things, moreover it would link directly with my loan, so I would not need additional documentation. I though this was a decent plan, so I asked the relevant person to go ahead. So, imagine my shock when on the loan disbursement day, the HDFC guy tells me that the insurance I opted for only covers life and not any other things! This is where I felt totally bad about the way various people at HDFC were communicating with me. I literally fumed at the guy who was handling my papers. But I realised that there was no point bashing this guy, probably I should have been careful, should have enquired more, or should have chosen a different loan provider all together.

In any case, the loan got disbursed, and I gave some pre-EMI cheque (I later came to realise that I had not signed the cheque!) and here came a bummer: I was now told by the HDFC guy that I have to do property registration with the registrar office for the loan mortgage.  What? I have to again go to the registrar office? Fortunately, DSK people helped here to do this thing for me for a little fee. Sigh!

After all this I gave the disbursement cheque to DSK, and on the same day they handed me the keys to my flat. Along with that they gave me a host of starter kits, a set of books and to top all this they gave me a cheque of about 2800 INR. What was that cheque for? Apparently the DSK guys had deposited my advance amount and the own contribution that I did towards the flat in fixed deposits and the cheque was the interest (- TDS) that DSK was giving me back! This was sweet, considering all the pain I had got through. I felt so good about DSK, in complete contradiction to my feeling towards HDFC.

So apparently I now have a flat, albeit small. After this, I and my Father moved in to this flat. There were a lot of small maintenance issues at the flat, which have been or are being handled by DSK. This month, DSK handed over the operations to a provisional society committee, so technically now DSK is not responsible for any further work, but indicated that they are ready to help in any case.

After the first week of stay, my Father didn't much like the surroundings as the place is quite separated out and is still under development. So now, I shuffle between two homes. Workdays at the new flat, and on weekends to my old sweet home.

There are a few things I like about this new place. Its airy and very quite at the same time. At times it can be windy but it is still pleasant. The second one is the solar water heating system, which I very much wanted in my old house, but never managed to get it done. There are a few things I miss: no personal garden, the common garden however is nice. No malls or even shops near by. I have to walk about 1.5 km to get stuff.

Some photos

(NOTE: The photos below are not high res, they are reduced quality images, if you want to see some of them in full res, visit my Flickr photo stream)

A panoramic view of my flat @ DSK Gandhkosh. Fairly well constructed. 
If you come out in the morning, you will find plenty of interesting birds around DSK Gandhkosh.
Night view of Baner from my bed room window. You can keep staring for long.

The first morning I woke up, nature had a pleasant surprise for me. It was a double rainbow :)

The first morning I woke up, nature had a pleasant surprise for me. It was a double rainbow :)
Another night time view of Baner from my terrace.
A view of the small flower garden at the entrance of Gandhkosh.

Few flowers!

A view from outside of DSK Gandhkosh.


Startup or buy house?

Before I bought this flat, I was in a dilemma, of whether I should put all the money I have in my savings for a startup or buying a house. Eventually something prompted me to buy a flat. Don't know what, but it just happened. I was already working with a very good friend of mine towards forming a small entity to try out things we have been discussing over few months. And almost immediately after I signed my agreement for purchase of flat another friend of mine came up with an idea which I couldn't resist to join in. This friend later told me that even if now I am kind of cash strapped, it was a good decision to buy the flat. I hope so, that is the case :) In the meantime I keep working on my ideas, and hopefully I am of some use for this society and a wonderful nation that has given me so much.


Reflection on my mother 

I always used to jokingly tell my mother, that I would be retiring at the age of 35. Sometimes, I felt that I was quite serious about it. Unfortunately, my mother didn't stay to see me turn 35. If not so long ago, people bought a house when they retired, I can consider my self retired ;) Its kind of a funny feeling however, since you still have to payback a good amount of loan! So I keep working :)





Sunday, April 05, 2015

MeTA Studio is moving to GitHub

I have moved the MeTA Studio project (https://code.google.com/p/metastudio/) source repository, Wiki and issue tracking to GitHub (https://github.com/tovganesh/metastudio/). All changes to the source, bug fixes and feature additions will now be made on the GitHub.

This change has happened as Google code will be shutting down. The archival page of MeTA Studio on Google code will continue to exist. I had a great time using Google code to host MeTA Studio, it was far superior and easy to use than source forge when I wanted to open up the source before the publication of my paper (http://onlinelibrary.wiley.com/doi/10.1002/jcc.21088/abstract). Thank you Google.


Switching to Ubuntu from Windows

Long ago, I wrote a post (http://tovganesh.blogspot.in/2008/07/switching-form-ubuntu-to-windows-vista.html) when I switched from Ubuntu to Windows on my mini laptop. I got a few passionate comments on that post, but that is OK, such is expected. From that day, I have always used Windows on my home desktop, although at work it was mostly Linux and Mac. This was primary because my parents were comfortable with using Windows, and it served the purpose then. But since the passing away of my mother, the desktop machine is hardly used. My dad is now more comfortable using his Windows phone and an Android tablet.

So the week before I decided to switch to Ubuntu by nuking the Windows 8 installation all together on my home desktop machine. Since then, I have had not much for a chance to evaluate the change though, as most of my work now gets done either on my phone or when I am at work (where I have the Mac, and connect to a remote Linux box over ssh). But here is my initial impression on a few days of use:

1) Now that this is Ubuntu, I can do a hell lot of things. Literally. A lot of software stack that I wanted to try but was just not too great on Windows can now easily be done with Linux. Theno (http://deeplearning.net/software/theano/), being one of them.

2) Still needs proprietary software to work. MP3/ Flash is still around, so are a huge number of codecs - have they got more since 2008? The biggest gripe is however the graphics drivers. I have a Nividia card on my machine. And that is where the problem is. The default nouveau drivers are usable. But usable is a big word to use for those drivers. There are simply too many crashes. What is more, the Firefox is a pain to use the moment I open > 5 tabs or open the wonderful Flipboard web app. That made me to switch to Chrome. Chrome was great, but the scroll experience was anything but choppy. Finally, I switched to the Nvidia binary driver. It solved some problems and created others: the boot and the shutdown screen are now non-pretty. The issues that I had in 2008 seem to still around in 2015.

(The story however, seems better with new Intel hardware. The driver support on Linux on the latest Intel CPU / GPU combination is probably a lot better than what is on my 2007 Intel Core 2 machine with Nvidia graphics)

3) It boots a lot slower than Windows 8. That is quite surprising to me. I would have expected Ubuntu to boot a lot faster than Windows. But looks like Windows 8 (and now Windows 10) has done a lot of work to improve boot speeds, which makes it comfortably faster than Ubuntu on my desktop PC.

For now, I continue to use new installation without major issues. I will keep updating this post as I more regularly use the desktop for stuff that I do.



Saturday, January 31, 2015

Social Bus Spotter update

The Social Bus Spotter app (for Android), has got an update. The new features include:

- Real time position update of commuter (you!)
- Auto update bus position for next 5 - 30 minutes, once recorded.

With this, the commuter position is updated when using the app automatically in real time. Further, you can auto check in the bus position you are travelling in for a scheduled time span (up to a maximum of 30 minutes). The auto check in (update) to the bus position you are travelling in is useful to give a live feed of the bus. You can download the latest version from Google Play Store (https://play.google.com/store/apps/details?id=com.busspotter).

Social Bus Spotter app is now also a Web App accessible via. http://bus.savarinow.in
With this you can now access the Web App from any modern mobile browser - iOS / Windows Phone / Firefox OS / Android, are tested and works -. The Web App is simple and has limited functionality compared to the Android app. However, the basic functionality of viewing and making bus checkins are available.