Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with this question for Perl language . this is the question. Modify the program so that it asks the user for a

I need help with this question for Perl language .

this is the question.

Modify the program so that it asks the user for a match value V, a mismatch cost Cm, and an indel cost Im. It should read the inputs from the keyboard and assigns them to variables.

Modify the program so that it finds the maximum value of any possible alignments of the two input strings, where the objective function is

 maximize{V * (#matches) - Cm * (#mismatches) - Im * (#indels)} 

Run your program for the two strings in Exercise 1. If you use the same weights, do you find the same results?

This is the code that need to be modified:

Use needleman.pl

#This is the Needleman-Wunsch global alignment algorithm without gaps

#in the model and

#with match value = 1, and mismatch and indel value = -1.

#dg

open (OUT, '> outer'); #Open a file called 'outer' for outputing.

print "Input string 1 ";

$line = <>;

chomp $line;

@string1 = split(//, $line); #split up the line into individual characters

#and place the characters into a list, whose

#first index is 0 (here Perl has inherited

#one of the worst features of C) See Johnson

# 4.3 for an introduction to lists. Look up

# split in the index and read it.

print "Input string 2 ";

$line = <>;

chomp $line;

@string2 = split(//, $line);

$n = @string1; #assigning a list to a scalar just assigns the

#number of elements in the list to the scalar.

$m = @string2;

print "The lengths of the two strings are $n, $m "; # Just to make sure this works.

$V[0][0] = 0; # Assign the 0,0 entry of the V matrix

for ($i = 1; $i <= $n; $i++) { # Assign the column 0 values and print

# String 1 See section 5.2 of Johnson

# for loops

$V[$i][0] = -$i;

print OUT "$string1[$i-1]"; # Note the -1 here because array indexes start at 0 (ug!)

}

print OUT " ";

for ($j = 1; $j <= $m; $j++) { # Assign the row 0 values and print String 2

$V[0][$j] = -$j;

print OUT "$string2[$j-1]";

}

for ($i = 1; $i <= $n; $i++) { # follow the recurrences to fill in the V matrix.

for ($j = 1; $j <= $m; $j++) {

# print OUT "$string1[$i-1], $string2[$j-1] "; # This is here for debugging purposes.

if ($string1[$i-1] eq $string2[$j-1]) {

$t = 1; }

else {

$t = -1;

}

$max = $V[$i-1][$j-1] + $t;

# print OUT "For $i, $j, t is $t "; # Another debugging line.

if ($max < $V[$i][$j-1] -1) {

$max = $V[$i][$j-1] -1;

}

if ($V[$i-1][$j] -1 > $max) {

$max = $V[$i-1][$j] -1;

}

$V[$i][$j] = $max;

print OUT "V[$i][$j] has value $V[$i][$j] ";

}

}

print OUT " The similarity value of the two strings is $V[$n][$m] ";

close(OUT);

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional SQL Server 2000 Database Design

Authors: Louis Davidson

1st Edition

1861004761, 978-1861004765

More Books

Students also viewed these Databases questions

Question

=3/What does it mean when a source of financing is cheap?

Answered: 1 week ago