convert code into matlab code
조회 수: 3 (최근 30일)
이전 댓글 표시
hi, i badly need this code, but it is not matlab code. this is code foe sequence local alignment(smith-waterman), I did not find it as matlab code .I converted most of this code but the last part, I did not know the commands of this programming language can anybody help to convert the following code into matlab?
- trace-back
my $align1 = "";
my $align2 = "";
my $j = $max_j;
my $i = $max_i;
while (1) {
last if $matrix[$i][$j]{pointer} eq "none";
if ($matrix[$i][$j]{pointer} eq "diagonal") {
$align1 .= substr($seq1, $j-1, 1);
$align2 .= substr($seq2, $i-1, 1);
$i--; $j--;
}
elsif ($matrix[$i][$j]{pointer} eq "left") {
$align1 .= substr($seq1, $j-1, 1);
$align2 .= "-";
$j--;
}
elsif ($matrix[$i][$j]{pointer} eq "up") {
$align1 .= "-";
$align2 .= substr($seq2, $i-1, 1);
$i--;
}
}
$align1 = reverse $align1;
$align2 = reverse $align2;
print "$align1\n";
print "$align2\n";
thanks in advance
댓글 수: 0
채택된 답변
Walter Roberson
2011년 12월 27일
Looks like perl.
last if condition
translates to
if condition; break; end
and
A .= B
translates to
A = [A B]
and
$matrix[$i][$j]{pointer}
translates to
matrix(i,j).pointer
and
reverse $align1
translates to
fliplr(align1)
댓글 수: 5
Walter Roberson
2011년 12월 29일
"next" in perl is the equivalent of "continue" -- that is, skip any further instructions in the body of the loop and start the next iteration of the loop.
This contrasts with perl's "last", which is the equivalent of "break" -- that is, skip any further instructions in the body of the loop and exit the loop itself, continuing on after the end of the loop.
추가 답변 (1개)
Diego
2011년 12월 30일
If you have the bioinfo toolbox, then you probably have the swalign file that implements the smith-waterman algorithm. On the other hand, I just discovered that Matlab runs perl scripts smoothly! In my case, I have a perl script that uses the bioperl module and Matlab ran it!. I said this because I was facing a similar problem, and these tips may help you to accomplish your work. Regards, Diego
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!