Installing AMOS for Next Generation Sequence Assembly in Ubuntu Linux step by step

AMOS is A Modular, Open-Source whole genome assembler which In this post, I'll describe about its usage and installation.

Installation

AMOS package is written using C++ and Perl and is platform independent. There is no binary file in AMOS sourceforge page and it should be built according to platform using source codes.

In this section, we explain installation of AMOS 3.1.0 on Ubuntu 14.04, the most favorite Linux distribution.  AMOS also may need some of prerequisites for installation that are the following:

1. Qt 4 development version; install it using this command:

sudo apt-get install libqt4-dev


2. Some Perl modules needed:

sudo cpan XML::Parser Config::IniFiles
sudo cpan Statistics::Descriptive DBI

 

3. Install boost C++ library:

sudo apt-get install libboost-all-dev



4. Download Blat's source code

5. Add  HG_WARN_ERR = -DJK_WARN -Wall  after line #4 of blatSrc/inc/common.mk file.

6. Change directory to unzipped content using cd command.

7. Change make's default installation directory:

mkdir -p /usr/local/bin/



8. Compile and install Blat, using:

make 'MACHTYPE = x86_64'



9. Install MUMmer:

sudo apt-get install mummer



After downloading AMOS source code, before starting installation, you should also fix an error after extractions of compressed file in amos-3.1.0/src/Align/find-tandem.cc add #include <getopt.h>, after line #9. Now all things seem ready for installation; follow these steps to compile and install AMOS:

1. Change directory to  amos-3.1.0 folder

2. Configure installer to adapt your system, using this:

  ./configure –prefix=/usr/local



3. Finally, to install AMOS, use this:

make install

 

Execution

We first use Minimus with some simulated sequences introduced by AMOS website; to do this, we use /minimus/bacterium/c_ruddii.seq file (FASTA format) that located in Tutorial file at AMOS sourceforge page.  The process of using Minimus is as following:

1. Change directory to desired file using this command:

cd tutorial/minimus/bacterium/


2. Convert file to AMOS formatted input file using toAmos utility as following:

toAmos -s c_ruddii.seq -o c_ruddii.afg


3. Run Minimus with default parameters:

minimus c_ruddii


now we use ls  command to see files that produced by running Minimus; the list of newly produced files are the following:

c_ruddii.afg c_ruddii.contig  c_ruddii.runAmos.log  c_ruddii.bnk    c_ruddii.fasta 

Now we describe content of these elements:

*.afg: AMOS formatted input file (created by toAmos)

*.contig: Minimus assembly result file in TIGR format

*.runAmos.log:  log file of Minimus running that contains data like alignment error rate, running duration and etc.

*bnk: this is folder that contains bank data.

*.fasta: Minimus assembly result file in FASTA format

 

Evaluation

In this section we try to use getN50 function of AMOS package to evaluate result of assembly. We use sample data presented in AMOS tutorial file placed at /tutorial/minimus/bacteriophage. The process of evaluationis as following:

Change directory to desired bank file:

cd /tutorial/minimus/bacteriophage


Calculate N50 statistic on FASTA formatted file using AMOS built in getN50 function:

getN50 KVP40.fa


The output is as this:

 

NUM 89032

AVG 220.008232994878

N50 224

 

The NUM value is number of contigs and AVG is average of contigs length. A larger N50 score is usually better but sometimes on impact of incorrect joints in assembled contigs, it may increase that is not because of more quality of assembly.

 

Visualization

We'll use hawkeye visualization tool to graphic representation of Minimus assembly result. Since data used in Execution section was simulated, its visualization is not so realistic; so we use a ready bank from sample data which provided by AMOS website, is used. To run hawkeye, use this command after extraction of bank file:

hawkeye staph_aureus.ctg2533.bnk



Now hawkeye's window will be opened. Scaffolds and contigs views are shown in figure 4 and 5.

 

Installing Mannasim with NS2 on Ubuntu step by step

The Mannasim Framework is a module for WSN simulation, based on the Network Simulator (NS-2). Mannasim extends NS-2 introducing new modules for design, development and analysis of different WSN applications.

I'll describe installing Mannasim with NS2 in some steps!

Note: You can use Ctrl+I shortcut to go to a specific line in gedit.

1. Download NS2-2.29 all in one

2. Download Mannasim patch

3. Extract each of above files

4. Copy extracted patch file (mannasim-patch.diff) to ns-2.29-allinone folder (extracted)

5. In that folder enter this command:

patch -p1 < mannasim-patch.diff

6. Install some of dependencies using this command:

sudo apt-get install build-essential libxmu-dev autoconf automake

After above steps you need to do some changes on NS2 and Mannasim source code to prevent errors on installing:

 

Instruction based on color:
file that need modification
existing code
new code
 

7.  In otcl-1.11/configure file, in line 5503, change SHLIB_LD="ld -shared"  to SHLIB_LD="gcc -shared"

8.  In tclcl-1.17/Tcl.cc file, in line 566, change char *p = strchr(localName, '('); to char *p =const_cast<char*>( strchr(localName, '('));

9.  In ns-2.29/queue/red.cc file, in line 874, change

if (((p = strstr(v->name(), "ave")) == NULL) &&
((p = strstr(v->name(), "prob")) == NULL) &&
((p = strstr(v->name(), "curq")) == NULL) &&
((p = strstr(v->name(), "cur_max_p"))==NULL) ) {

to

if (((p = const_cast<char*>(strstr(v->name(), "ave"))) == NULL) &&
((p = const_cast<char*>(strstr(v->name(), "prob"))) == NULL) &&
((p = const_cast<char*>(strstr(v->name(), "curq"))) == NULL) &&
((p = const_cast<char*>(strstr(v->name(), "cur_max_p")))==NULL) ) {

10.  In ns-2.29/queue/rio.cc file, in line 565, change

if (((p = strstr(v->name(), "ave")) == NULL) &&
((p = strstr(v->name(), "in_ave")) == NULL) &&
((p = strstr(v->name(), "out_ave")) == NULL) &&
((p = strstr(v->name(), "prob")) == NULL) &&
((p = strstr(v->name(), "in_prob")) == NULL) &&
((p = strstr(v->name(), "out_prob")) == NULL) &&
((p = strstr(v->name(), "curq")) == NULL)) {

to

if (((p = const_cast<char*>(strstr(v->name(), "ave"))) == NULL) &&
((p = const_cast<char*>(strstr(v->name(), "in_ave"))) == NULL) &&
((p = const_cast<char*>(strstr(v->name(), "out_ave"))) == NULL) &&
((p = const_cast<char*>(strstr(v->name(), "prob"))) == NULL) &&
((p = const_cast<char*>(strstr(v->name(), "in_prob"))) == NULL) &&
((p = const_cast<char*>(strstr(v->name(), "out_prob"))) == NULL) &&
((p = const_cast<char*>(strstr(v->name(), "curq"))) == NULL)) {

11.  In ns-2.29/queue/pi.cc file, in line 5503, change

if (((p = strstr(v->name(), "prob")) == NULL) &&
((p = strstr(v->name(), "curq")) == NULL)) {

to

if (((p = const_cast<char*>(strstr(v->name(), "prob"))) == NULL) &&
((p = const_cast<char*>(strstr(v->name(), "curq"))) == NULL)) {

12.  In ns-2.29/queue/vq.cc file, in line 333, change

if ((p = strstr(v->name(), "curq")) == NULL) {

to

if ((p = const_cast<char*>(strstr(v->name(), "curq"))) == NULL) {

13.  In ns-2.29/queue/rem.cc file, in line 335, change 

if (((p = strstr(v->name(), "ave")) == NULL) &&
((p = strstr(v->name(), "prob")) == NULL) &&
((p = strstr(v->name(), "curq")) == NULL)) {

to

if (((p =const_cast<char*>(strstr(v->name(), "ave"))) == NULL) &&
((p = const_cast<char*>(strstr(v->name(), "prob"))) == NULL) &&
((p = const_cast<char*>(strstr(v->name(), "curq"))) == NULL)) {

14.  In ns-2.29/queue/gk.cc file, in line 207, change 

 if ((p = strstr(v->name(), "curq")) == NULL) {

to

if ((p = const_cast<char*>(strstr(v->name(), "curq"))) == NULL) {

15.  In ns-2.29/mannasim/dataGenerator.h file, in line 28, change #include <list.h> to #include <list>

16.  In ns-2.29/mannasim/sensedData.h file, in line 40, change #include <list.h> to #include <list>  and in line 41, change #include <vector.h> to #include <vector>

17.  In ns-2.29/mannasim/sensorNode.h file, in line 36, change #include <list.h> to #include <list>

18.  In ns-2.29/mannasim/difussion/commonNodeDiffApp.h file, in line 6, change #include <list.h> to #include <list>

19.  In ns-2.29/mannasim/leach/app/leachApp.h file, in line 7, change #include <list.h> to #include <list>

20.  In ns-2.29/mannasim/leach/rca/rca-ll.cc file, in line 13, change #include "list.h" to #include "list"

21.  In ns-2.29/mannasim/difussion/commonNodeDiffApp.h file, in line 6, change #include <list.h> to #include <list>

22.  In ns-2.29/linkstate/ls.h file, in line 137, change

void eraseAll() { erase(baseMap::begin(), baseMap::end()); }

to

void eraseAll() { this->erase(baseMap::begin(), baseMap::end()); }

23.  In ns-2.29/mannasim/onDemandData.cc file, in line 44, change OnDemandData::OnDemandData(REAL); to OnDemandData(REAL);

Now, go back to ns-allinone-2.29 and install NS2 using ./install command

24. To install nam, use this command:

sudo apt-get install nam

References:





jQueryUI virtual keyboard with randomized keys

I found this virtual keyboard very interesting and flexible:

To adding it to your page; add this files to your HTML code head from downloaded zip file (also you need jQuery and jQueryUI):

<script src="../script/jquery-2.0.1.min.js" type="text/javascript"></script>
<script src="../script/jquery.keyboard.min.js" type="text/javascript"></script>
<script src="../script/jquery-ui.custom.min.js" type="text/javascript"></script>
<script src="script/jquery.keyboard.extension-typing.js" type="text/javascript"></script>
<link href="style/jquery-ui.min.css" rel="stylesheet" type="text/css" />
<link href="style/keyboard.css" rel="stylesheet" type="text/css" />
then to use keyboard for some inputs (here,with "password" id),use script, something like this:
$(function () {
    jQuery("#password").keyboard({ openOn: null, stayOpen: true }).addTyping();<br>    $("#password").focus(function () { $('#pass').getkeyboard().reveal(); });<br>
 });
after download ,to randomize keys, add:
.split("").sort(function(){return 0.5-Math.random()}).join(" ")
to each group of characters(keys) that you want for randomizing:
'qwerty' : {
            'default': [
                '` 1 2 3 4 5 6 7 8 9 0 - = {bksp}',
                '{tab} q w e r t y u i o p [ ] \\',
                'a s d f g h j k l ; \' {enter}',
                '{shift} z x c v b n m , . / {shift}',
                '{accept} {space} {cancel}'
            ],
            'shift': [
                '~ ! @ # $ % ^ & * ( ) _ + {bksp}',
                '{tab} Q W E R T Y U I O P { } |',
                'A S D F G H J K L : " {enter}',
                '{shift} Z X C V B N M < > ? {shift}',
                '{accept} {space} {cancel}'
            ]
        },
for example,add it like this:
'` 1 2 3 4 5 6 7 8 9 0'.split("").sort(function(){return 0.5-Math.random()}).join(" ")+' - = {bksp}',<br><br>
See working example, here

Broadcasting real-time data to all clients using SignalR

You should see on many websites with real time contents update feature; using this feature gives good experience to visitors and avoid using awful polling method to check for new events.

if you are interested to add real time feature to your ASP.NET application, consider using SignalR library!

Installing

if you are using .NET framework 4.5 you can easily download and install latest version of SignalR from Nuget packages manager. 

but if you are using .NET framework 4, you can install SignalR 1.1.3 from Package Manager Console using this command:

 

Install-Package Microsoft.AspNet.SignalR -Version 1.1.3
 

by installing SignalR, Scripts folder will be created in your project root directory.

Usage

now you should add Global.asax file as this image shown:

Now put this snippet in Application_Start method:

RouteTable.Routes.MapHubs();
 

(Don't forget to add related usings)

Then you should create a class which inherit from Hub class, like this:

using Microsoft.AspNet.SignalR;
 
namespace MyProj
{
    public class EventHub:Hub
    {
    }
}
Now add some scripts to your view page:
<script src="/Scripts/jquery-1.6.4.min.js" ></script>
<script src="/Scripts/jquery.signalR-1.1.4.js"></script>
<script src="/signalr/hubs"></script>
And then, you should add this script to connect to SignalR:
<script>
$(function () {
 
    var context = $.connection.eventHub;
    context.client.refresh = function (someData) {
        yourFunction(someData);
    };
    $.connection.hub.start();
});
</script>
Finally you can use bellow C# code to send some data to above Javascript method:
var now = DateTime.Now.ToLongTimeString();
var context = GlobalHost.ConnectionManager.GetHubContext<EventHub>();
context.Clients.All.refresh(now);
In above code, current time will be broadcast to all of clients that are online to this page.

Export excel document from DataTable using EPPlus in web application on the fly

To export xlsx document from DataTable in C# I recommend to use powerful library named EPPlus (for .net 3.5 or higher).

For starting; first download EPPlus from epplus.codeplex.com and extract it (it is free).

Next, in Visual Studio in PROJECT menu click Add Reference to open dialog like this:

 

now click Browse and open EPPlus.dll .

after that in your Webform code behind (.aspx.cs) or your generic handler (.ashx.cs) add this codes:

using OfficeOpenXml;
using OfficeOpenXml.Table;//adding library
DataTable dt=GetDT();//get your DataTable from some method or... 
 
using (ExcelPackage pck = new ExcelPackage())
{     
     if (dt.Columns.Count > 0)
     {
           ExcelWorksheet ws = pck.Workbook.Worksheets.Add("addYourSubjectHere");
           ws.Cells["A1"].LoadFromDataTable(dt, true, TableStyles.Medium6);//<-(input DataTable,show header,table style)
           ws.Cells.AutoFitColumns();
           using (ExcelRange rng = ws.Cells)
           {
                rng.Style.Font.SetFromFont(new Font("Tahoma", 10));
           }
           pck.Workbook.Properties.Title = "yourTitle";
           Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
           Response.AddHeader("content-disposition", "attachment;  filename=Invoice.xlsx");
           Response.BinaryWrite(pck.GetAsByteArray());
           Response.End();
     }
}


if you are using generic handler, you may remove Response.End(); from the code.