MATLAB Answers


DNA Sequence alignments in MATLAB behaving a bit weirdly

Asked by Sukrit
on 18 Jun 2013


I have a large number of 30 base pair DNA sequences and I'm trying to get all pairwise alignments between them. I'm not interested in the score of the alignment so I made up a simple scoring matrix that allows me to count how many mismatches there are given the best alignment. I tried a couple things as sanity check, and now I'm not sure what's going on anymore. Essentially, I tried to align two sequences that are offset by one base. However, all the alignment functions in MATLAB that I have tried (nwalign, swalign, localalign) fail to see this and report that there are 12 mismatches between the sequences instead of 1. I've included the code for the test case below. What am I screwing up? Much appreciated..

    %if true
mat = [0,1,1,1;

  1 Comment

Ingrid Tigges
on 23 Jun 2013

Did I understand you correctly that you are seeing 12 mismatches when you are using a default scoring matrix? If I use for example this code


I only see one mismatch in the output of y.


No products are associated with this question.

0 Answers

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!