This project is read-only.

An experimental port to JavaScript

Sep 10, 2013 at 11:53 PM
Recently, and for various project reasons, one of our people has done some rather interesting work exploiting the .NET Bio codebase in JS. The gist of his work is in the following post, and he will doubtless jump into the conversation as it develops:
Over the last few weeks I have been conducting an informal feasibility study into retargeting a subset of the .NET Bio library to JavaScript. The primary aim is to make some of the core functions provided by .NET Bio available for direct use in JavaScript programs to produce bioinformatics tools. These tools might take the form of HTML5/CSS/JavaScript applications running in a web browser or under Windows RT, or run as standalone desktop or server-based JavaScript applications using technology like Node.js.
At present I am focussing on basic functionality which I expect will prove useful in a range of applications – principally, the bits that I want for the software that I am presently working on. That said, the performance of modern JavaScript engines makes some of the more heavy-duty computational functions included in .NET Bio quite tempting avenues for exploration as well.
The three main functional areas that I have ported to JavaScript at present are:
  1. NCBI Web Blast.
  2. Genbank parser (formatters may follow, however at present I have no direct need for this.
  3. Blast Xml Parser.
    I am using Nikhil Kothari’s Script# cross-compiler to generate JavaScript from (a heavily hand-edited version of) the .NET Bio C# source code. Although Script# works generally very well, it only supports a restricted subset of C# and consequently significant editing has been required to adapt the source to the new target. The main kinds of incompatibility that cause difficulty are:
    • Automatic property (Property { get; set; }) notation is not supported, and these have to be converted to either a field or an explicit property with a backing field.
    • Lambda expressions are not supported. Lambdas have to be replaced by anonymous delegates.
    • Generics are only partially supported. User defined generic types need to be replaced with a non-generic equivalent.
    • A number of data types needed to be implemented from scratch. This includes TextReader, TextWriter, StringReader and XmlReader. Others, such as HashSet, have been replaced by less sophisticated data types in the interim pending time and need for improvement.
    • Fundamental differences in the JavaScript type system and standard libraries had to be addressed, such as the fact that JavaScript has a very different set of primitive types: int, byte, long, float and double all map to Number, while char maps to String (a char is a string of length = 1).
    I am still engaged in unit testing the JavaScript port, but at this stage it appears to be sufficiently solid to support the work we are doing around BLAST and RegPrecise. I expect that the library will allow us to develop some really interesting apps in the near future.
The motivation for this exercise has been in large measure to get a good type system and basic functionality for bioinformatics to sit comfortably in the browser, but this is of course a more general possibility. Any thoughts from the community on this work and its possibilities?