This is a test version of Biostars. For the public version, visit https://www.biostars.org.
problem using FastqExtract.pl script

Hi all,

Recently, I tried to use the perl script FastqExtract.pl to extract paired FASTQ reads based on the BLAST outputs but error occurred and said “could not open file”.

I converted the fastq files to fasta files before the blastn task, did this cause any problem for downstream analysis? Then, I just conducted the blastn task and output the tabular format results as suggested. I always failed when using the script and I am not sure what’s wrong going on here.

I hope there is someone also using this script can solve my problem. I really appreciate your help if you could help me out of this. Thank you.

The original paper can be found here: https://academic.oup.com/mbe/article/32/9/2302/1028967/Soup-to-Tree-The-Phylogeny-of-Beetles-Inferred-by#supplementary-data

The perl script can be found here: https://oup.silverchair-cdn.com/oup/backfile/Content_public/Journal/mbe/32/9/10.1093_molbev_msv111/2/msv111_Supplementary_Data.zip?Expires=1504084867&Signature=deTRtdQb9FcWWfByxxpNb4VLjcMOL71jZB9mX0x1pgGLD62U5WUkaNlbCCgTe5sl1CpkTvAIV1UJct25TL0nGO1xGZ516aEfEl3WsPmaT1rUttd6wY1TYm0FCJKhnN6vNSyagqTpRiCz0EoWaiCFypXBbSV9JvWqaI8ii-CsfMlsImfoaxioLk91U0pi9vBJwE1DZxRu2PmT0~UDYOZUvvVuXZwBqb8chECpTNMdKAbxG0meUph8UxoFsQvmrb-mseRgNI2DfaiSdQqKf0~q5TsQECM1MnUAJ06SP75WZw-L4D8WadbzZskxyPkQnzNwMjcnrdqoxDm6OP0H8sSLyA__&Key-Pair-Id=APKAIUCZBIA4LVPAVW3Q

fastq mitochondrial genome ngs

you should give your command line. “could not open file” is an error concerning input files wrong name or wrong path/ directory generally.

Hi Titus,

Thank you for answering my question. The command lines are about using the perl script FastqExtract.pl which I put in the same directory with all my fastq files and blastn results. Hope the command lines help clarify my question. Cheers

$ perl FastqExtract.pl

what is the name of the BLAST output file?

blastn.out

what is the name of the raw reads file?

11_3_2.fastq

what is the read identifier (first 6 header characters, not inc @)?

ST-E00

could not open file

Hi ,

I put he the code : print "what is the name of the BLAST output file?\n";

 $blastIn = <STDIN>;
    chomp $blastIn;
    print "what is the name of the raw reads file?\n";
    $filename = <STDIN>;
    chomp $filename;
    print "what is the read identifier (first 6 header characters, not inc @)?\n";
    $idf = <STDIN>;
    chomp $idf;
    #INPUT:
    $fastq = $filename;
    open(FASTQ, "<$fastq") or print "could not open file $fastq";
    #HEADERS:
    $headers = $blastreader;
    chomp $headers;
    open(HEADERS, "$headers") or print "could not open file $headers";
    @headers = <HEADERS>;
    close HEADERS;
    foreach $head(@headers){
    if($head =~ m/\w/){
    @head = split(" ", $head);
    #add to hash
    $headers{$head[0]}=1}
    }
    $outfile = "$fastq\.out";
    open(OUTFILE, ">$outfile") or print "could not open file $outfile";
    ########################################
    open(FASTQ, "<$fastq");
    while(<FASTQ>){
    $line = $_;
    if($flag == 1){$flag = 2; print OUTFILE $line;}
    elsif($flag == 2){$flag = 3; print OUTFILE $line;}
    elsif($flag == 3){$flag = 0; print OUTFILE $line;}
    elsif($line =~ m/$idf:/){
    @line = split(" ", $line);
    $line[0] =~ s/\@//ig;
    if(exists $headers{$line[0]}){
    ++$counter; $flag = 1;
    print "$counter\:\t\t$line";
    print OUTFILE "$line";
    }
    }
    }
    close OUTFILE;

I think the problem could come from the HEADERS part : is there any specification for the Header blast format ? Did you use the same blast ?

Best

Hi there,

It might be a problem with the blast because I first convert the fastq file to fasta file which I then used to perform the blastn task. However, I used the fastq file to go through the FastqExtract script against the fasta blast results. The reason I did so is I cannot directly perform the blastn task with fastq files (maybe I did this wrong). So, can fastq files be diretly used for blast?

Also, I also had doubt about the Header. I will keep on trying to test the script.

Meanwhile, your suggestions and answers are always welcome and appreciated. Thank you.

Cheers

Hi ,

to check if it s the header you should replace

open(HEADERS, "$headers") or print "could not open file $headers";

by

open(HEADERS, "$headers") or print "could not open file header $headers";

and then you will know if it's the header is wrong. By the way i don't really understand what is $blastreader in this code , i think there is something wrong.

Blast doesn't use fastq to my knowledge.

Best

well, I check with your suggestion and it turns out to be a problem of the header. However, even if I crop the header both in fastq files and blast results to make them look the same, the error message "could not open file (header)" still exists.

Now, I am not sure whether I use this script in a proper way, i.e., did the blast correctly, use the right fastq files (merged or un-merged). I still cannot figure out what' wrong going on when I am using this script which it's so frustrating. Anyway, thank you for your help. I would appreciate if you are happy to go on solving my problem.

Cheers

0 answers

No answers yet.

Log in to answer this question.