Entering edit mode
10.0 years ago
Korsocius
▴
260
Dear all,
can you help me with one thing, I would like to convert ASCII quality to decimal Quality for each read and for each base in the read and write it into one row. Input bam file. Output rows, where will be phred Quality score (I am using Torrent technology, then -33).
I create one code, but it is only for all bam file to get Quality score, could you help me with this?
#! /usr/bin/perl
open (IN,"samtools view bezdup.bam |") ;
$vysledek=0;
$celkovy_pocet=0;
while (<IN>) {
my @ascii = split '\t', $_;
$jeden= $ascii[10];
my @jedenacty= split //,$jeden;
foreach $vypocet (@jedenacty) {
$pomocna = ord($vypocet)-33;
if ($pomocna >= 20) {
$vysledek++;
#print "$pomocna\n";
}
$celkovy_pocet++;
}
}
close (IN);
$quality= ($vysledek / $celkovy_pocet)*100;
print "$vysledek\n";
print "$celkovy_pocet\n";
print "$quality";
Do you want to write the decimal values as rows in a file or as rows of what? You appear to be computing them correctly in
pomocna
, so it's just a matter of processing it in an appropriate way for your goals.Anyway, I assume you want a line printed for each read, so just iterate over
pomocna
before hitting the end of thewhile
loop.For eaxmple. If your read bam file there is in $11 ASCII code.
INPUT : bam file $11 column
OUTPUT: Decimal values for each base
input : <<<===98 output: 60 60 60 61 61 61 57 56
and same results for all rows in bam file (for all reads)
Right, so just iterate over
pomocna
before hitting the end of thewhile
loop.Thank you, I will try it, because perl is really new language for me...