First, I don't know how I could write my output in order to still have a fastq format, written in a file and not on the screen. Then, I'm not so conveinced about my output... printed sequences have the same lenght. Maybe there is a problem in the sliding window operation but I don't know where it is. I know if I start with + = good and - = bad, my result should be: +++--++ input +++ output and not +++--++ input +++++ output I don't know how I could stop at the first "bad" window... Could you help me? Thanks a lot Artu5#!/usr/bin/perl # quality trimming of fastq file print "Write the window length\n"; $kmer=<STDIN>; chomp ($kmer); print "Write the minimum quality score cut-off\n"; $cut_off=<STDIN>; chomp ($cut_off); $file = "lib-pool-fosmid.fastq"; if (open(FASTQ,$file)) { while($header1=<FASTQ>) { $dna=<FASTQ>; $header2=<FASTQ>; $qual=<FASTQ>; @dna=split ('', $dna); @qual=split ('', $qual); @num_value=(); @scores=(); foreach $qscore (@qual) { $num_value=ord($qscore)-33; push(@num_value, $num_value); } foreach $value (@num_value) { if ($value<$cut_off) { pop(@num_value); + }else{ last; } } $sub1=substr($dna,-@num_value); @qscopy=reverse @num_value; foreach $value (@qscopy) { if ($value<$cut_off) { pop(@qscopy); }else{ last; } } $sub2=substr($sub1,0,@qscopy); @sub2=split('',$sub2); @qscopy=reverse @qscopy; @final_values=(); for ($i=0;$i<@qscopy-($kmer-1);$i=$i+$kmer) { @scores=@qscopy[$i..$i+$kmer-1]; $sum=0; foreach $score (@scores) { $sum+=$score; } if (($sum/$kmer)>$cut_off) { push(@final_values,@sub2[$i..$i+$kmer-1]); } } print "$header1"; foreach $base (@final_values) { print "$base"; } if (@final_values != 0){ print "\n\n"; } } }else{ print "Error! Can't find the file\n"; }
In reply to Quality trimming of fastq file by artu5
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |