Skip to main content

Exon Chaining source code in Perl (Dynamic programming)

Exon Chaining Problem:
Can't tell lucky or not the same problem is can be found in Uva online judge for programming.When our team attend a contest in a university in bangladesh this modified version of this problem is given.(11908 Skyscraper).
In Bio-informatics it is a set of exon is given now create the amino acid from which the needed protein can be found.
Input >> here cuttings from start to end with score is given.
Output >> Give the maximum Allginment Score and selected chunk.

Code is given bellow (perl):
*************************************************************************************
INPUT >>
2 3 3
1 5 5
4 8 6
6 12 10
9 10 1
7 17 12
11 15 7
13 14 0
16 18 4
OUTPUT>>
21

use strict;
use warnings;

main(@ARGV);

sub main
{
  my $line;
  my $co = 0;
  my ($i,$ans);
  open(MYDATA,"in1.txt");
  my @G = [(1...10),(1...4)];
  while($line = <MYDATA>)
  {
    chomp($line);
    my @p = split' ',$line;
    for($i=0;$i<3;$i++)
    {
      $G[$co][$i] = $p[$i];
    }
    ++$co;
  }
  close(MYDATA);
  #print $G[1][1];
 
  $ans = exon(\@G,$co);
  print $ans,"\n";

}


sub exon

   my($g,$n) = @_;
   my @G = @{$g};
   my ($i,@s);
 
   for($i=0;$i<=$n*2;$i++)
   {
     $s[$i] = 0;
   }
  
   for($i=1;$i<=2*$n;$i++)
   {
      my($fl,$ro,$cos) = root(\@G,$i,$n);
  
      if($fl == 1)
      {
        if($s[$ro] + $cos > $s[$i-1])
        {
          $s[$i] = $s[$ro] + $cos;
        }
        else
        {
            $s[$i] = $s[$i-1] ;
        }
     
      }
      else
      {
        $s[$i] = $s[$i-1];
      }
  
   }
  
   return $s[$n*2];

}

sub root
{

  my($g,$m,$lim) = @_;
  my @G = @{$g};
  my $i;

  for($i=0;$i<$lim;$i++)
  {
    if($G[$i][1] == $m)
    {
      return (1,$G[$i][0],$G[$i][2]);
    }
  } 
  return (0,-1,-1);
}

Comments

Popular posts from this blog

UDP server client in c

Server #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <stdio.h> #include <unistd.h> #include <errno.h> #include <string.h> #include <stdlib.h> int main() {         int sock;         int addr_len, bytes_read;         char recv_data[1024],send_data[1024];         struct sockaddr_in server_addr , client_addr;         if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {             perror("Socket");             exit(1);         }         server_addr.sin_family = AF_INET;         server_addr.sin...

Video Conferencing Project in Java Source Code

My video conferencing project was completed as 300 project for 3rd year.It is not totally completed. There is some bug in here.To solve these bugs and to help other students this project is open.It is first try to make a project open source in this way so it can be modified.Any kind of question against this project will be answered. As this project was created in 3rd year 1st semester and now i nearly completed my BSc. so there will be little description about this.I will try to describe every class and function later when i get the chance.   For more details and how to build and run go to this link   in github.com . Latest code and binary release : VideoConference-v1.1 Older code and binary release : VideoConference-v1.0 Fix: 1. When in Video chat the Text chat option hanged for good. ################################################################################# FEATURE #############################################################################...

[ASTERIK] configure: error: *** uuid support not found (this typically means the uuid development package is missing)

ISSUE: Build error on Asterik , when you want test webrtc feature :) checking for uuid_generate_random in -luuid... no checking for uuid_generate_random in -le2fs-uuid... no checking for uuid_generate_random... no configure: error: *** uuid support not found (this typically means the uuid development package is missing) Fix: This issue arises due to missing of UUID generator specified by rfc4122 . +Linux sudo apt-get install uuid-dev  @Unix yum -y install libuuid-devel Asterik comes with lots of helpful script available on - asterisk/contrib/scripts/ folder of your ASTERIK source. So just use the following command on UNIX console to run the asterik pre-requisite script. contrib/scripts/install_prereq install And you are done! configuring. Now -- Make Asterik.