Hi,
I am trying to calculate percentage identity for command line BALT output and I am posting the script below. But it is not working right now and the % is always 100%.
Please let me know the problem. or any other way to caluculate %. This is being followed from BLAT FAQ documentation at http://genome.ucsc.edu/FAQ/FAQblat#blat4
The changes I have donw ith respect to the FAQ code are
It would be great if there are any other way of calculating % identity. Thanks in advance.
I am trying to calculate percentage identity for command line BALT output and I am posting the script below. But it is not working right now and the % is always 100%.
Please let me know the problem. or any other way to caluculate %. This is being followed from BLAT FAQ documentation at http://genome.ucsc.edu/FAQ/FAQblat#blat4
Code:
while(<>) {
chomp $_;
my @v = split(/\t/,$_);
get_pid($_);
}
sub get_pid {
my @line = @_;
my $pid = (100.0 - (&pslCalcMilliBad(@line) * 0.1));
print "The percentage: $pid\n";
#return $pid;
}
sub pslCalcMilliBad {
my @cols = @_;
# sizeNul depens of dna/Prot
my $sizeMul = 1;
#if ($option{p}) {
# $sizeMul = 3;
#} else {
# $sizeMul = 1;
#}
# cols[0] matches
# cols[1] misMatches
# cols[2] repMaches
# cols[4] qNumInsert
# cols[6] tNumInsert
# cols[11] qStart
# cols[12] qEnd
# cols[15] tStart
# cols[16] tEnd
my $qAliSize = $sizeMul * ($cols[12] - $cols[11]);
my $tAliSize = $cols[16] - $cols[15];
# I want the minimum of qAliSize and tAliSize
my $aliSize;
$qAliSize < $tAliSize ? $aliSize = $qAliSize : $aliSize =
$tAliSize;
# return 0 is AliSize == 0
return 0 if ($aliSize <= 0);
# size diff
my $sizeDiff = $qAliSize - $tAliSize;
if ($sizeDiff < 0) {
$sizeDiff = 0;
#if ($option{m}) {
#$sizeDiff = 0;
#} else {
#$sizeDiff = -($sizeDiff);
#}
}
# insert Factor
my $insertFactor = $cols[4];
$insertFactor += $cols[6] unless ($option{m});
my $milliBad = (1000 * ($cols[1]*$sizeMul + $insertFactor +
&round(3*log( 1 + $sizeDiff)))) / ($sizeMul * ($cols[0] + $cols[2]
+ $cols[1]));
return $milliBad;
}
sub round {
my $number = shift;
return int($number + .5);
}
Code:
1
my $sizeMul = 1; and commented:
#if ($option{p}) {
# $sizeMul = 3;
#} else {
# $sizeMul = 1;
#}
2
if ($sizeDiff < 0) {
$sizeDiff = 0;
#if ($option{m}) {
#$sizeDiff = 0;
#} else {
#$sizeDiff = -($sizeDiff);
#}
}
Comment