<?xml version='1.0'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:atom="http://www.w3.org/2005/Atom" >
<channel>
	<title><![CDATA[BOL: Perl script to check fastq reads qualities !]]></title>
	<link>https://bioinformaticsonline.com/snippets/view/36916/perl-script-to-check-fastq-reads-qualities?</link>
	<atom:link href="https://bioinformaticsonline.com/snippets/view/36916/perl-script-to-check-fastq-reads-qualities?" rel="self" type="application/rss+xml" />
	<description><![CDATA[]]></description>
	
	<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/36916/perl-script-to-check-fastq-reads-qualities</guid>
	<pubDate>Tue, 12 Jun 2018 04:42:20 -0500</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/36916/perl-script-to-check-fastq-reads-qualities</link>
	<title><![CDATA[Perl script to check fastq reads qualities !]]></title>
	<description><![CDATA[<code>#!/usr/bin/env perl

use strict;
use warnings;

sub readfq {
	my ($fh, $aux) = @_;
	@$aux = [undef, 0] if (!defined(@$aux));
	return if ($aux-&gt;[1]);
	if (!defined($aux-&gt;[0])) {
		while (&lt;$fh&gt;) {
			chomp;
			if (substr($_, 0, 1) eq &#039;&gt;&#039; || substr($_, 0, 1) eq &#039;@&#039;) {
				$aux-&gt;[0] = $_;
				last;
			}
		}
		if (!defined($aux-&gt;[0])) {
			$aux-&gt;[1] = 1;
			return;
		}
	}
	my $name = /^.(\S+)/? $1 : &#039;&#039;;
	my $seq = &#039;&#039;;
	my $c;
	$aux-&gt;[0] = undef;
	while (&lt;$fh&gt;) {
		chomp;
		$c = substr($_, 0, 1);
		last if ($c eq &#039;&gt;&#039; || $c eq &#039;@&#039; || $c eq &#039;+&#039;);
		$seq .= $_;
	}
	$aux-&gt;[0] = $_;
	$aux-&gt;[1] = 1 if (!defined($aux-&gt;[0]));
	return ($name, $seq) if ($c ne &#039;+&#039;);
	my $qual = &#039;&#039;;
	while (&lt;$fh&gt;) {
		chomp;
		$qual .= $_;
		if (length($qual) &gt;= length($seq)) {
			$aux-&gt;[0] = undef;
			return ($name, $seq, $qual);
		}
	}
	$aux-&gt;[1] = 1;
	return ($name, $seq);
}

my @aux = undef;
my ($name, $seq, $qual);
my ($n, $slen, $qlen) = (0, 0, 0);
while (($name, $seq, $qual) = readfq(\*STDIN, \@aux)) {
	++$n;
	$slen += length($seq);
	$qlen += length($qual) if ($qual);
print join(&quot;\t&quot;, $n, $slen, $qlen), &quot;\n&quot;;
}
#print join(&quot;\t&quot;, $n, $slen, $qlen), &quot;\n&quot;;

__END__
 my @aux = undef; # this is for keeping intermediate data
  while (my ($name, $seq, $qual) = readfq(\*STDIN, \@aux)) { 
     if( (length($seq) &gt;= 21) &amp;&amp; (length($seq) &lt;= 25) ) { 
         print &quot;@$name\n&quot;;
         print &quot;$seq\n&quot;; 
         print &quot;+\n&quot;;
         print &quot;$qual\n&quot;;
     }
  }</code>]]></description>
	<dc:creator>Abhimanyu Singh</dc:creator>
</item>

</channel>
</rss>