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.

Sunday, December 21, 2014

'Make for India' makes more sense than 'Make in India'

Recently, the current RBI governor Raghuram Rajan (http://www.financialexpress.com/article/economy/official-takes-dig-at-rbi-guv-raghuram-rajan-over-pm-narendra-modis-make-in-india-campaign/21232/), made a somewhat controversial statement saying that 'Make for India' makes better sense than 'Make in India'. Initially, I did not pay a lot of attention to this. But after thinking a bit I think Raghuram Rajan has a point here, particularly when you think in longer terms.

To be at the top of the economy, or as a driving force, I believe, one needs to be a 'innovation driven' economy. To be an innovation driven economy, we need to solve local problems, and then scale them up globally. If you look at all the startups in the US, they all start locally, solve local problems, and then find a global audience. They drive the world, they drive the money. Where as if you look at what happens in China - they are primarily manufacturing hub, which is quite akin to 'Make in India' campaign. The problem with this is that, at the end of the day, you don't have the clout - over platforms and standards - that define next wave of development. You end up being just a 'worker' in the whole scheme of things - not the one who solves problems. This is what make me support 'Make for India' idea, than the other more funded and visible campaign.

A totally different context, but I think there are some parallels in this video:

Sunday, November 16, 2014

Few time lapse trials

I am just learning here. So go easy on judging! The first three are taken using the Hyperlapse app. While the last one is taken using iPod + iPhone camera's time lapse feature and then edited using iMovie.


The Alleppey Bridge, Alleppey Beach


In a flight, near Bengaluru


 A top a rooftop restaurant (Post 91) in Baner, Pune


'The Purple Flower', my garden


Saturday, November 01, 2014

Algorithmic discovery of One Pot reactions

I am always interested in research and technology development that challenges the status quo, and gives an alternative way to do things, preferably using a computer algorithm. The paper by Bartosz Grzybowski and co-workers is one of these (see http://onlinelibrary.wiley.com/doi/10.1002/anie.201202155/abstract). One Pot reactions is currently more of an individual skill rather than a rigorous process that can be implemented in a computer algorithm. The paper published in Angewandte Chemie in 2012, address this exact issue. I am sure that this is a solvable problem, and when it does get mass acceptance, a lot of cost savings may be achieved.
 

Wednesday, September 10, 2014

One more thing...

... Is the Apple Watch. It is easily the best pieces of wrist watches that I have seen recently. It has most of things that I would want of a wearable device (http://tovganesh.blogspot.in/2013/09/it-is-not-calls-text-and-tweet-that.html), with one glaring exception: battery life. Looks like it is not going to be great (http://recode.net/2014/09/10/codered-apple-watch-battery-life-charge-nightly/). 

Sunday, September 07, 2014

Social Bus Spotter (Alpha) : crowd sourced bus running status

Usually public bus timetables in India are quite unpredictable. Most of the times you do no know when to expect a bus. Social Bus Spotter (alpha release), is the first step I am taking to make this information available in a easier way. The idea is to rely on all of you who travel daily via buses. Typically many of you have a smartphone. All you have to do is register a bus when you travel in one of the buses. This information is collected in the back end and then presented to others.

The app, in its alpha version is now published on the Google Play Store (https://play.google.com/store/apps/details?id=com.busspotter). Use it, be responsible, spread the word about the app with hash tag #SocialBusSpotter on Twitter.



(Note 1: As the app is in early stages of development, expect frequent updates).
(Note 2: The app is currently only published in India and Israel Play stores, I will push to other markets as I keep improving the app).


Saturday, September 06, 2014

Saturday, August 30, 2014

Samsung Gear S : Almost everything I need from a smart watch

Samsung just announced Gear S (based on Tizen OS, not the Android Wear - which I consider to be merely a glorified notification center), and the specs are almost what I would want out of a smart watch (see here: http://www.samsungmobilepress.com/unpacked2014ep2/#wearable/spec/GearS). Further it can be used without a phone, which is added benefit. The only issue I see is the battery. Although suggested battery life is 2 days, I am not very sure how practical is that in daily usage.

Next up: What is in store for September 9?

Monday, August 11, 2014

A remote I would like to see

Some time ago I was wondering if there could be a 'simplified universal remote, with a child mode function'. I don't think I have seen such a product in the market. So I went out with my usual powerpoint and came up with the following (putting it under CC license so if you would like to build one I would be happy to see it) ..


Friday, August 08, 2014

Opinion: A reminder on why using closed systems is bad

I use a lot of closed systems. In fact, I rely on many of them. To name a few Skype, Windows and now an iPhone. I also use a lot of opensource (including developing my own opensource projects). With open systems (as in with availability of source code), you are always in control and not at the mercy of the initial company that developed it.

So when I heard of Skype discontinuing support for WP7 devices (https://support.skype.com/en/faq/FA34489/is-skype-for-windows-phone-7-being-discontinued), it was a reminder how bad this could turn up to be. I had been using a Lumia 800 device for quite some time and actually had no plans to switch until Septemeber, when the official support for WP7 ended. But I switched to another closed system, and iPhone because of a number of reasons: primary one being I just wanted the device to work for me without me tinkering a lot. This is the same reason I use Windows on my home machine. I just have no time to do the tweaking required for open systems to work for me always. But this comes with one major issue such as the one exhibited by the dropping of Skype  on WP7. When I bought into WP7 from Nokia (as they never released the N9 in India), I was quite aware that I was going into a totally closed system, but just ignored it. Lumia 800, started its life without Skype, it came a few months after wards, and now even if the device is in great shape, Skype is altogether dropping support for the device.
I presume that about 2 years down the lane it will be the same issue with my current iPhone: Apple will drop support and force me to upgrade to a new device, even if the device may be in good shape.

That brings me to other question: should I switch to more open systems like Jolla? Probably I should, but then I won't be able to do a tonnes of things that I so easily accomplish on my current iPhone. There is probably a fine balance between open and closed systems. One can't probably choose completely over the other. What is probably still in your hands is that you still have complete control over the data that you store in these devices.

Update: The reactions here (http://community.skype.com/t5/Windows-Phone/Unable-to-login-to-Skype-in-WindowsPhone-7-5/td-p/3437429/page/4?cm_mmc=AFCJ%7C1250_B1-_-10576637-6146953), pretty much sum up my feeling towards how MS has handled its mobile OS strategy. They have simply screwed up.

Saturday, July 12, 2014

A quick and dirty algorithm for Maximum Common Substructure

While there is vast amount of literature dedicated to algorithms for Maximum Common Substructure (MCS) search, particularly with respect to molecular graph (see for instance: http://scholar.google.co.in/scholar?hl=en&q=maximum+common+substructure&btnG=), I wanted to quickly write an algorithm without reading any literature on the subject. And thus this algorithm was written, typically over the weekend.

First consider finding an MCS between two molecular graphs:

1. Convert the molecule into a bit representation. This is akin to generating fingerprint of the molecule, but in this case a fingerprint is generated for each Atom in the following way:

  • Each Atom is represented as a bit-set of 64 bits, that will be able to capture a maximum of seven bonds that are connected to the atom under consideration.
  • Each set of 9-bits represents a connection: 7 bits for storing atomic number of connected atom type, 2 bits for bond type (0-single, 1-double, 2-triple, 3-aromatic).  
  • The order in which the bits are stored in the bit-set is always in sorted order: first sorted on atomic number and then on the bond type.
2. Match the corresponding bit atom representations (generated above)  among the two molecular graphs, and build a pair list. This matching is done in two stage: the first stage involves exact bit pattern match, where as the second stage involves partial match. When doing the partial match, the atom pair match that has the maximum bit matches is taken. The pair list thus generated becomes the seed for 'growing' the graph that would hopefully be the maximum common substructure.

3. For each of the pair list generated in step 2, start growing the graph using a breadth first traversal method, at each stage checking if the corresponding expansion in the paired molecule is also possible. The pair stops growing, when no such expansion is possible. And the algorithm stops when there is no growth for any of the pairs in the list. The pair with the maximum number of elements then forms the maximum common substructure. Use this pair to next generate the template molecular sub-graph representing MCS.  

For finding MCS among a set of molecules: 

4. Find the molecule with least number of atoms from the set, and mark it as reference molecule. Follow steps 1 to 3 for the pair of reference molecule and every other molecule in the set. Instead of just picking the pair with maximum elements in step 3, save the complete list (L). Next, pick the pair list that has least number of elements as reference (Lp). For a member in this list (iLp), search the complete list (L), to see if every list has the member iLp, if yes add it to a new list (Lnew). Repeat this procedure for every member of list Lp. Finally, the list with maximum number of elements in Lnew is the MCS for the set of molecules. 

That is it. I have tested the algorithm on different sets of congeneric series of molecules, and it pretty much works for all. For non-congeneric set however, one needs to build a cluster algorithm to find the MCS in sub group of molecules, that is work for some other weekend. 

For now, an implementation of this is available as a scripting function within VLifeMDS (www.vlifesciences.com, visit https://portal.vlifesciences.com/ to buy a license). I will also hopefully make an implementation available with MeTA Studio soon.