Why does perl read fastq files as all 1s?
1
0
Entering edit mode
8.4 years ago
top1214 ▴ 20

So I'm trying to pull some stuff from a fastq file using perl.

#!/usr/bin/perl -w
use strict;
use warnings;

my $open = $pairfile.$j.".fq";
    open (FILE, "<$open") or die "\nCouldn't open file $open $!";
    while($line = <FILE> && $a<$q){
        print $line;
}

Produces an infinite number of '1's. That's it just '1'. What am I doing horribly wrong?

Doing

more FCC5V4BANXX-WHZEBkvtDAAADTAAPEI-100_L7_1.fq

produces the expected

@HISEQ:351:C5V4BANXX:7:1101:1204:2054 1:N:0
NCTGGTAAAGAAACTCGCACACACACACACACACGCACGCACGCACACGCTTACCGAAAACTGTAAGTTTATGAATATTTTTTACACTGTGGCCAATATTTTAGGGAAGTCAGCATCACTAAATG
+
#==ABGGGGGGGGGGGGGGGGGGGGGGGGGDGGGGGGGGGCGEE>GGGGGGGGGGGGGGGGGGFEBFFGGGGF=BFCFGGGGG@FFGGCFGGFFGGG.CEGGGEGG?:DG6BCG5@B=>CG=EBG
next-gen • 1.3k views
ADD COMMENT
1
Entering edit mode

Oh wow. Never mind. The logical test was reporting as true (1), and that was being assigned to $line.

ADD REPLY
1
Entering edit mode

This code will not compile!

ADD REPLY
0
Entering edit mode

Indeed it won't. OP, please provide the real code you used in the future because that will get you a better answer and save people time.

ADD REPLY
2
Entering edit mode
8.4 years ago

Try using "and" instead of "&&". The issue is with order of precedence of "=" and "&&".

ADD COMMENT

Login before adding your answer.

Traffic: 2389 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