Unfaithful Web APIs
Haploview is a Java application developed by Broad Institute and is used to visualise and analyse haplotype datasets. One of its key features includes a direct data link with HapMap. It is very useful for anyone studying genotypic links in disease studies, and from what I hear, co-workers at my research institute use this actively in their research.
Recently, many of them started facing difficulties in using Haploview to download datasets from HapMap. Not surprisingly, Haploview technicians suggest that we first attempt to remedy the situation by using the correct proxy settings. However, to our knowledge, no explicit proxy server settings are used at UBC. These days, most large enterprise IT systems depend on transparent proxy servers for accessing the Internet. So there wasn't really much we could do about that.
Next, I plouged through the source codes looking for connection details. What server was it trying to connect to? What port did it require? What are the parameters supplied to the web API? I found the information I needed in a rather deeply embedded class. It was connecting to a PERL-script - http://www.hapmap.org/cgi-perl/phased, which I figured was responsible for providing phased data based on the parameters supplied, e.g. target chromosome, start, stop and population.
I checked the link and found that I was able to retrieve phased data in plain-text format. But the application was expecting the data to be returned compressed as a GZIP stream. I'm guessing that in older versions of the phased CGI-script, a header that specifies "Accept-Encoding" = "gzip" would have signalled the script to return the data in gzip format rather than plain-text. This is a classic example of what happens when a contract is not well-defined between APIs and client applications.
The error reported is also confusing. There are two lines of codes that give the same message, "Could not connect to HapMap database." You'll find this on line 1096 and 1261. These are within catch clauses for IOExceptions. On line 1096, this would be correct, but not necessarily so for line 1261. The IOException caught here is due to unexpected formats and not because of connectivity issues.
If you are not able to wait for an official resolution to this problem, you may do the following:
- Download the HaploView source codes.
- Edit the class edu.mit.wi.pedfile.PedFile using your favourite IDE.
- Comment out lines 1098 and 1099 that should contain the following lines of codes:
GZIPInputStream g = new GZIPInputStream(hmpCon.getInputStream());
BufferedReader hmpBuffReader = new BufferedReader(new InputStreamReader(g));
- Replace the codes in (3) with the following line of code:
BufferedReader hmpBuffReader = new BufferedReader(
new InputStreamReader(hmpCon.getInputStream()));
- Execute "ant haploview" to compile and package the application.
- Execute "java -jar haploview.jar".
If you have any difficulties performing these steps, feel free to contact me and I will send you a pre-compiled version with this issue fixed.

![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=9be1e814-974e-4109-ae0d-5238139bf822)
Comments
Its been a year now and I
Its been a year now and I persume the "Could not connect to HapMap database." has been resolved. I wish you would have mentioned which Haploview version you talking about. I am referring to 4.2.
I wanted to point that today there is another issue with connecting to server. Its "error Connecting to GeneCruiser" its posted on the sourceforge homepage for haploview so I persume the technicians know about it. I wonder if you can give some insight into this issue?
Version
My bad... yes, I should have specified the version I was referring to. I believe it might have been 4.1, so I'm guessing the development team would have fixed it by now. I will see if I can spare some time to look at it again, but I'd strongly suggest writing to their mailing list to let them know about this issue. Btw, I'm not a Haploview user myself, I was helping my co-workers fix this issue. :)
Compiled Haploview
Hi,
Could I also get from you the newest compiled version of Haploview. I just came upon this error as well.
Best,
Darin
haploview
Could you please send me the newly compiled version of Haploview that has the connect to hapmap problem resolved.
thanks
rakesh
Contact
Hi Rakesh,
Sure I can. Please drop me a message here and I will send you the link.
http://fuzziebrain.com/content/contact
Post new comment