Giter Site home page Giter Site logo

cahanlab / web_framework Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 700 KB

Web_Framework (a.k.a Radiator) is a cloud-backed computational framework that addresses common barriers to deploying compute-intensive bioinformatics tools

License: MIT License

PHP 16.70% CSS 76.00% Python 7.30%

web_framework's Introduction

Radiator Web Framework

Radiator is a web framework that allows you to deploy your bioinformatics command line tool through a cloud provider, facilitating flexibility, computationally efficiency, cost-effectiveness, and above all, reproducibility.

The following walkthrough assumes basic knowledge of Linux, virtual servers and machines, and web development concepts. It will demonstrate how to adapt our base framework for a simple example application.

We have written a Python 'down-sampling' script, down.py as an example of a bioinformatics tool one might want to deploy. The script takes a random sample of reads from a FASTQ file; this is useful when fewer reads than may be present in a FASTQ file are sufficient for a downstream analysis tool.

Architecture Overview:

Radiator utilizes a Model-View-Controller (MVC)-like architecture. This is an organizational paradigm that separates the logic of code into the categories of front-end/user-side appearance (views), back-end/server-side software (controllers), and data (models).

In the Radiator framework, directories are organized under the MVC paradigm as such:

  • HTML files are stored under views
  • Server-side scripts are stored under controllers
  • Data are stored under models
  • Supporting CSS and Javascript files specifying additional front-end behaviors are found under assets

These directories are stored in the server's filesystem under /var/www/html.

Launching our base framework (For the Developer):

The base virtual machine is hosted by Amazon Web Services as an EC2 Amazon Machine Image (AMI). Currently it is only available in the US-East-1 region.

  1. Select the Radiator AMI: Cahan-Lab Application Framework Base Image
    • AMI ID: ami-5dd1db27
  2. Specify desired instance type.
  3. Specify security group. Make sure it allows for incoming traffic through ports 20 (SSH for shell access) and port 80 (HTTP for web access)
  4. Launch instance.

The Front Page:

frontpage

  1. Modify the input parameters of the front page by editing front_page.php in /var/www/html/views/. Name your application and provide a brief description here. Add HTML form elements for specifying the user parameters necessary for analysis. Modify application appearance in /var/www/html/assets/css/main.css and upload-file.css.
  2. For the purposes of the down-sampling application, we will add an html form element to specify the number of reads desired.
  3. Add the following HTML tag to the front page:
<input type="text" name="parameter1" placeholder="Input Read Depth [Default 5000000]"/>
  1. Now your front page should look similar to the following:

frontpage

Controllers:

  1. Add your executable (in this case, the down-sampling executable) to its proper location using scp. Your command should look something like this:
    • scp -i keyname.pem downsample_file [email protected]:/var/www/html/controllers/Algorithm
  2. Assign the proper permissions so that Apache can execute it:
    • sudo chown apache downsample_file
    • sudo chmod +x downsample # This will make it appear as an executable to the operating system

The run.php script takes care of the parameters specified in your front page form. It collects them to create a shell command that will feed input into your script. So now we can build the command to execute the script. Change the line

if(isset($_POST['parameter1'])) {
    $parameter1 = (int)$_POST['parameter1'];
    #$command = "/var/www/html/controllers/Algorithm/EXECUTABLE_NAME";
}
else {
    #$command = "/var/www/html/controllers/Algorithm/EXECUTABLE_NAME";
}

to

if (move_uploaded_file($_FILES['data']['tmp_name'], $target_file)) {
## CHECK IF A PARAMETER IS SPECIFIED
    if(isset($_POST['parameter1'])) {
        $parameter1 = (int)$_POST['parameter1'];
        $command = "/var/www/html/controllers/Algorithm/downfile -n $parameter1 $target_file";
    }
    else {
        $command = "/var/www/html/controllers/Algorithm/downfile $target_file";
    }
    exec($command);
}

Setting I/O Paths:

  1. Now make sure that the executable is writing its output to the right place. In your the downsample script, replace this line (LINE 40):

    with open("subset_"+fname, "w") as output:

    with

    with open("/var/www/html/models/output/subset_"+fname, "w") as output:

Make Application Available through Cloud Formation:

  1. Save new AMI based on current instance state.
  2. Make the AMI public.
  3. Map your Stack Template to launch an instance of your AMI.
  4. Make the link to your Stack Template publically available.

Launching the Application (End-user):

This process is similar to launching the CellNet web application, detailed on the CellNet Web Application GitHub Page.

  1. Navigate to Cloud Formation.
  2. Create Stack by pasting link to Stack Template.
  3. Use the output URL to open the web application.
  4. Use web application.
  5. Finish and delete stack.

Storage

Your instance type matters! If your application is going to require more than ~5GB of disk space, then you'll want to specify an instance type with Storage Volumes. They should be automatically mounted upon instantiation.

web_framework's People

Contributors

remyschwab avatar emilyklo avatar pcahan1 avatar

Stargazers

Colin Davenport avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.