ASCII conversion from bam file
0
0
Entering edit mode
9.4 years ago
Korsocius ▴ 250

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";
ASCII Quality • 2.7k views
ADD COMMENT
0
Entering edit mode

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 the while loop.

ADD REPLY
0
Entering edit mode

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)

ADD REPLY
0
Entering edit mode

Right, so just iterate over pomocna before hitting the end of the while loop.

ADD REPLY
0
Entering edit mode

Thank you, I will try it, because perl is really new language for me...

ADD REPLY

Login before adding your answer.

Traffic: 1655 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6