From: Mongkut Piantanakulchai on
Dear all,

I wonder if somebody has develop Matlab code Needleman–Wunsch algorithm for global alignment. My application involve comparing sequences (not protein) and need our customized scoring matrix (not PAM or BLOSUM). Therefore I cannot apply function in the bioinformatics toolbox in MATLAB directly?.

I might take some time for me to write the code myself. Therefore I want to know if there exists developed code already? or any workaround?

Thanks in advance,

Mongkut P.
From: us on
"Mongkut Piantanakulchai" <mongkutp.remove.this(a)gmail.com> wrote in message <hs0gut$c8$1(a)fred.mathworks.com>...
> Dear all,
>
> I wonder if somebody has develop Matlab code Needleman&#8211;Wunsch algorithm for global alignment. My application involve comparing sequences (not protein) and need our customized scoring matrix (not PAM or BLOSUM). Therefore I cannot apply function in the bioinformatics toolbox in MATLAB directly?.
>
> I might take some time for me to write the code myself. Therefore I want to know if there exists developed code already? or any workaround?
>
> Thanks in advance,
>
> Mongkut P.

just a thought:
did you try to implement your scoring mat in a copy of NWALIGN(?)...

us
From: Mongkut Piantanakulchai on
Thanks for pointing me out.
After reading the help carefully I found that NWALIGN() allow me to put my own scoring matrix.
However, it only limits me with 24x24 scoring matrix (so my customized scoring matrix should be 24x24)
It just come to my mind that I can map my sequence characters into 24 types + specifying my own scoring matrix?

Any other idea?

Thanks !

Mongkut
From: Lucio Cetto on
This is not officially documented but I think should be easy to do. Create a function that calls affinegapmex (or simplegapmex) in the same way nwalign calls them. These private functions require sequences of integers (which are not limited to 24 symbols). Place a stop point in the debuger to learn how these private functions are called from within nwalign.

Here there is a try:
function alignment = alignsentences(sent1,sent2)

M = eye(256).*2 - 1;
[~, path(:,2), path(:,1)] = affinegapmex(uint8(sent1), uint8(sent2), -2, -1, M, 1);
path = path(sum(path,2)>0,:);
path = flipud(path);
alignment = repmat(('--')',1,size(path,1));
alignment(1,path(:,1)>0) = sent2;
alignment(2,path(:,2)>0) = sent1;

Then:
>> alignsentences('This is a nice test','This is a very nice test')

ans =

This is a very nice test
This is a -----nice test

HTH
Lucio

"Mongkut Piantanakulchai" <mongkutp.remove.this(a)gmail.com> wrote in message <hs0kbk$b47$1(a)fred.mathworks.com>...
> Thanks for pointing me out.
> After reading the help carefully I found that NWALIGN() allow me to put my own scoring matrix.
> However, it only limits me with 24x24 scoring matrix (so my customized scoring matrix should be 24x24)
> It just come to my mind that I can map my sequence characters into 24 types + specifying my own scoring matrix?
>
> Any other idea?
>
> Thanks !
>
> Mongkut
From: Mongkut Piantanakulchai on
Dear Lucio,

Thank you very much for your kind advice !!!

Mongkut P.


"Lucio Cetto" <lcetto(a)nospam.mathworks.com> wrote in message <hs13bk$rvi$1(a)fred.mathworks.com>...
> This is not officially documented but I think should be easy to do. Create a function that calls affinegapmex (or simplegapmex) in the same way nwalign calls them. These private functions require sequences of integers (which are not limited to 24 symbols). Place a stop point in the debuger to learn how these private functions are called from within nwalign.
>
> Here there is a try:
> function alignment = alignsentences(sent1,sent2)
>
> M = eye(256).*2 - 1;
> [~, path(:,2), path(:,1)] = affinegapmex(uint8(sent1), uint8(sent2), -2, -1, M, 1);
> path = path(sum(path,2)>0,:);
> path = flipud(path);
> alignment = repmat(('--')',1,size(path,1));
> alignment(1,path(:,1)>0) = sent2;
> alignment(2,path(:,2)>0) = sent1;
>
> Then:
> >> alignsentences('This is a nice test','This is a very nice test')
>
> ans =
>
> This is a very nice test
> This is a -----nice test
>
> HTH
> Lucio
>
> "Mongkut Piantanakulchai" <mongkutp.remove.this(a)gmail.com> wrote in message <hs0kbk$b47$1(a)fred.mathworks.com>...
> > Thanks for pointing me out.
> > After reading the help carefully I found that NWALIGN() allow me to put my own scoring matrix.
> > However, it only limits me with 24x24 scoring matrix (so my customized scoring matrix should be 24x24)
> > It just come to my mind that I can map my sequence characters into 24 types + specifying my own scoring matrix?
> >
> > Any other idea?
> >
> > Thanks !
> >
> > Mongkut