I'll not comment further on the fact that you're popping values from the array being visited by your foreach statement (and the fact that it seems weird that you are using pop in that context where it would seem that you probably want to shift values in that context, but you shouldn't do it anyway), I guess the point has been made clear.
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.If you don't know how to write to a file, then you simply need to open the file at the beginning of your script:
This line opens file result.txt for writing (">") and assigns it to the file handle $OUT.my $outfile = "result.txt"; open my $OUT, ">", $outfile or die "could not open $outfile $!"; # idi +omatic way to open a file for writing
Once this is done (do that only once), anytime you want to write to this file just add the $OUT file handle to your print statement:
At the end, it is good practice to close the file:print $OUT "text to be printed to the file\n";
although it is often not really necessary (Perl will usually close it for you when exiting, in some cases even before that).close $OUT;
I hope this helps you getting forward.
There are many other things to be said about your code, but I will only add one thing. You should have these two lines (called pragmas) at the top of your script:
This will force you to declare each variable (usually with the my keyword). For example, taking the first few lines of your script:use strict; use warnings;
You might initially think it is an annoyance to have to declare each variable before you use it, because you'll get a lot of errors when trying to run your program once you've added these two pragmas, but you'll learn pretty soon that this is in fact very helpful: Perl will tell you early (often at compile time) about many errors that you might make and that would otherwise go unnoticed until much later at execution time (and it is generally much better to see the errors early).#!/usr/bin/perl use strict; use warnings; # quality trimming of fastq file print "Write the window length\n"; my $kmer = <STDIN>; chomp $kmer; print "Write the minimum quality score cut-off\n"; my $cut_off = <STDIN>; chomp $cut_off; my $file = "lib-pool-fosmid.fastq";
The point is that, if you use these pragmas, Perl will find many of your errors for you and tell you about them, and you'll save a lot of time at the end of the day.
Update: removed a silly syntax mistake in the file opening statement. Thanks to AnomalousMonk for pointing it out.
In reply to Re: Quality trimming of fastq file
by Laurent_R
in thread Quality trimming of fastq file
by artu5
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |