Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Sequence allignment The optimum cost of an alignment of the strings x1 x2 x3 x4

ID: 3856326 • Letter: S

Question

Sequence allignment

The optimum cost of an alignment of the strings

x1 x2 x3 x4 ... x_m and y1 y2 y3 ... y_n

will always be greater than the optimum cost of an alignment of

   x2 x3 x4 ... x_m and y1 y2 y3 ... y_n

because any alignment of the first pair of strings necessarily contains an alignment of the second pair of strings.


This is NOT correct!

It is NOT true that any alignment of the first pair of strings necessarily contains an alignment of the second pair of strings: For example, let x = CT and let y = CG. It is NOT true that any alignment of these start with x1 = C against a gap, followed by an alignment of x2 against y1 y2 (i.e., an alignment of T against CG). Here is such an alignment:

A T
A G

This alignment has cost 1, whereas any alignment that starts with the first A in x against a gap necessarily will have cost at least 2 for that first gap, and optimally has cost 5:

A T -
- A G

Is it possible to have a situation in table "opt" where x_i is the same character as y_j and have

opt[ i ][ j ] = 2 + opt[ i+1][ j ] = 2 + opt[ i ][ j+1]    = 0 + opt[ i + 1][ j + 1]

(In other words, when creating the alignment, we could have come from ANY of the 3 neighboring squares below and to the right?

You need to compute the entire "opt" table, and see if there exists an i and a j such that x_i == y_j and when you are computing the value of opt[i][j], it is a 3-way tie between 2+opt[i + 1][j], 2+opt[i][j + 1], and opt[i+1][j+1].

Explanation / Answer

MATLAB® is optimized for operations involving matrices and vectors. The process of revising loop-based, scalar-oriented code to use MATLAB matrix and vector operations is called vectorization. Vectorizing your code is worthwhile for several reasons:

Appearance: Vectorized mathematical code appears more like the mathematical expressions found in textbooks, making the code easier to understand.

Less Error Prone: Without loops, vectorized code is often shorter. Fewer lines of code mean fewer opportunities to introduce programming errors.

Performance: Vectorized code often runs much faster than the corresponding code containing loops.

Vectorizing Code for General Computing

This code computes the sine of 1,001 values ranging from 0 to 10:

This is a vectorized version of the same code:

The second code sample usually executes faster than the first and is a more efficient use of MATLAB. Test execution speed on your system by creating scripts that contain the code shown, and then use the tic and toc functions to measure their execution time.

Vectorizing Code for Specific Tasks

This code computes the cumulative sum of a vector at every fifth element:

Using vectorization, you can write a much more concise MATLAB process. This code shows one way to accomplish the task:

Array Operations

Array operators perform the same operation for all elements in the data set. These types of operations are useful for repetitive calculations. For example, suppose you collect the volume (V) of various cones by recording their diameter (D) and height (H). If you collect the information for just one cone, you can calculate the volume for that single cone:

Now, collect information on 10,000 cones. The vectors D and H each contain 10,000 elements, and you want to calculate 10,000 volumes. In most programming languages, you need to set up a loop similar to this MATLAB code:

With MATLAB, you can perform the calculation for each element of a vector with similar syntax as the scalar case:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote