Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MATLAB BIOINFORMATICS HOMEWORK HELP NEED HELP WITH PART 2 MAINLY. start code with this: % A trial sequence with all amino acids: % ARNDCQEGHILKMFPSTWYV %

MATLAB BIOINFORMATICS HOMEWORK HELP

NEED HELP WITH PART 2 MAINLY.

start code with this:

% A trial sequence with all amino acids:

% ARNDCQEGHILKMFPSTWYV

% The trial sequences in the HW description:

% ARNDCQE

% ARNCDE

% Ask the user for protein sequence 1.

prompt = 'Enter the first amino acid sequence of length 1 to 25: ';

seq1 = input(prompt, 's');

len1 = length(seq1);

fprintf(1, 'Seq 1 %s has %d residues ', seq1, len1);

% Ask the user for protein sequence 2.

prompt = 'Enter the second amino acid sequence of length 1 to 25: ';

seq2 = input(prompt, 's');

len2 = length(seq2);

fprintf(1, 'Seq 2 %s has %d residues ', seq2, len2);

% Initialize a 25x25 matrix of zeros.

A = zeros(25,25);

% The supplied initMatrix must be modified!

A = initMatrix(A, seq1, seq2);

% Print the matrix A.

printMatrix(A, seq1, seq2);

end

% Print out a matrix

function mat = initMatrix(mat, seq1, seq2)

numRows = length(seq1) + 1;

numCols = length(seq2) + 1;

mat(1,1) = 0; % Init the value at (1,1) to 0.

% Initialize the first column.

for i=2:numRows

% Do something here!

end

% Initialize the first row.

for c=2:numCols

% Do something here!

end

% Init the rest of the matrix.

for r=2:numRows

for c=2:numCols

% Do something here!

end

end

end

% Print out a matrix

function printMatrix(mat, seq1, seq2)

len1 = length(seq1);

len2 = length(seq2);

% Print the first row of sequence letters

fprintf(1,'\t\t');

for r=1:len2

fprintf(1,'%2c\t', seq2(r));

end

fprintf(1,' ');

% Print the first row of scores.

fprintf(1,'\t');

for c=1:len2+1

fprintf('%2d\t', mat(1,c));

end

fprintf(1,' ');

% Print the rest of the scores.

for r=2:len1+1

% Print the first letter of vertical sequence

fprintf(1, '%c\t', seq1(r-1));

for c=1:len2+1

fprintf(1,'%2d\t',mat(r,c));

end

fprintf(1,' ');

end

end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3 -3 -4 -4 -2 -2 -3 -2 -2 -3 -2 -3 -1 1 -4 -3 -2 11 2 -3;

- 2 -2 -2 -3 -2 -1 -2 -3 2 -1 -1 -2 -1 3 -3 -2 -2 2 7 -1;

0 -3 -3 -3 -1 -2 -2 -3 -3 3 1 -2 1 -1 -2 -2 0 -3 -1 4];

value = A(i1, i2);

end

function value = aaToInt(aa)

switch aa

case 'A',

value = 1;

case 'R',

value = 2;

case 'N',

value = 3;

case 'D',

value = 4;

case 'C',

value = 5;

case 'Q',

value = 6;

case 'E',

value = 7;

case 'G',

value = 8;

case 'H',

value = 9;

case 'I',

value = 10;

case 'L',

value = 11;

case 'K',

value = 12;

case 'M',

value = 13;

case 'F',

value = 14;

case 'P',

value = 15;

case 'S',

value = 16;

case 'T',

value = 17;

case 'W',

value = 18;

case 'Y',

value = 19;

case 'V',

value = 20;

otherwise,

value = 1;

end

end

image text in transcribedimage text in transcribed

Implement the global alignment Needleman-Wunsch algorithm for protein sequences in an iterative fashion (i.e. do not use recursion, which simplifies the implementation for those that do not have experience with recursion.) For an iterative solution, we will use 3 matrices: The "A" matrix will store the final alignment scores The "B" matrix is simply an initialized "A" matrix with Blosum62 scores for each pair of residues The "D" matrix will store our directions (HW #10, Part 1) . Please see the sample code on Icon, which provides you with functions to 1) Initialize A and/or B matrices Print matrices and 2) 3) Use the BLOSUM62 substitution matrix for scoring For Part 1, simply initialize the "B" matrix, and print out the matrix. The algorithm is described in the lecture notes. You may assume the sequences are less than 25 in length (meaning you can limit your 2 dimentional matrices to 25x25). Note that if sequence 1 is of length m, and sequence 2 is of length n, then the matrices are (m+1) X (n+1). In other words, your matrix needs to be one dimension longer then the lengths of your two sequences For Scoring Gap: -1 Match/Mismatch: Blosum62 Example output follows Enter the first amino acid sequence of length 1 to 25: ARNDCQE Enter the second amino acid sequence of length 1 to 25: ARNCDE B matrix 2 2 2 2 Implement the global alignment Needleman-Wunsch algorithm for protein sequences in an iterative fashion (i.e. do not use recursion, which simplifies the implementation for those that do not have experience with recursion.) For an iterative solution, we will use 3 matrices: The "A" matrix will store the final alignment scores The "B" matrix is simply an initialized "A" matrix with Blosum62 scores for each pair of residues The "D" matrix will store our directions (HW #10, Part 1) . Please see the sample code on Icon, which provides you with functions to 1) Initialize A and/or B matrices Print matrices and 2) 3) Use the BLOSUM62 substitution matrix for scoring For Part 1, simply initialize the "B" matrix, and print out the matrix. The algorithm is described in the lecture notes. You may assume the sequences are less than 25 in length (meaning you can limit your 2 dimentional matrices to 25x25). Note that if sequence 1 is of length m, and sequence 2 is of length n, then the matrices are (m+1) X (n+1). In other words, your matrix needs to be one dimension longer then the lengths of your two sequences For Scoring Gap: -1 Match/Mismatch: Blosum62 Example output follows Enter the first amino acid sequence of length 1 to 25: ARNDCQE Enter the second amino acid sequence of length 1 to 25: ARNCDE B matrix 2 2 2 2

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

Students also viewed these Databases questions