Hi everyone! First of all, I'm sorry for my English, I'm not mothertongue and I hope what I will write is understandable. I'm writing you for an help: I'm studying for the first time in my life bioinformatics and Perl and I wrote this program but there are two things I can't do. Could you help me? Here it is my program:
#!/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"; }
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

In reply to Quality trimming of fastq file by artu5

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.