Learn PERL Basic with Me : NCBI BLAST parser IV

Today's PERL script is very similar to the PERL script I shared yesterday. It will parse the NCBI blast output just like the previous one but in cleaner way. Unlike the previous PERL script, this one will give you the parsed result in tabular form so that you can export them directly in excel files. You can use this BLAST result file obtained from NCBI web batch BLAST to test the results. You can use this PERL script to practice the regular expression or regex analysis with PERL also.
#!/usr/bin/perl
use strict;
use warnings;
# This line will ask for the file name
print "your BLAST file name \n";

# This line will save the file name into $file
my $file = <>;

# This line will open the input file
open (FILE, "$file");
 
 # This line will open the output file 
 open (OUT, ">result.txt");

# This line will create the loop to search the substring
while ($file = <FILE>){

# This line will search the substring "Query="
if ($file =~ /Query=/) {

# This line will print the all lines containg the substring "Query="
print (OUT "\n$file\n");

} 

# This line will search the substring that start with any word but not with ">" character
if ($file =~ /^[a-z]+\|/) {


# This line will print the all lines containg the substring "Score"
print (OUT "\t$file ");

}

}


Compare the line 28 of this PERL script and another NCBI blast parser PERL script shared HERE to understand the basic cause of difference in output format

No comments:

Post a Comment

Have Problem ?? Drop a comments here!