
stelbac
Novice
Jan 10, 2012, 9:00 AM
Views: 1517
|
MAKE A BLAST PARSER TO PRINT ONLY E-VALUE & SCORE FROM A BLAST_OUTPUT.TXT FILE IN A NEW STATS.TXT THROUGHT SIMPLE PERL!
|
|
|
MY WORK TILL NOW IS THE FOLLOWING: PLEASE HELP ME I AM A STUDENT OF BIOLOGY IN GREECE NOT EXPERT IN PERL... *ESPECIALLY I WANT SOMEONE TO TELL ME HOW TO PRINT MY RESULTS IN A STATS.TXT FILE AND NOT IN COMMAND PROMPT.. #!/usr/bin/perl use strict; use warnings; open(INFILE, "blast_output.txt") my($subject_ident, $comment_line, $subject_length); my %hits; while (<INFILE>) { if (/^>/) $subject_length = 0; $comment_line = $_; while (1) { my $next_line = <INFILE>; if ($next_line =~ /Length = (\d+)/ ) { $subject_length = $1; last; } else { # continuation of comment line chomp $next_line; $next_line =~ s/^\s+/ /; # remove leading $next_line =~ s/\s+$/ /; # and trailing multiple spaces $comment_line .= $next_line; } } $comment_line =~ />(\S+)\s/; $subject_ident = $1; $hits{$subject_ident}{subject_length} = $subject_length; $hits{$subject_ident}{comment_line} = $comment_line; } } my ($Score,$Expect) while (<INFILE>) { if (/Score=/){ my $score_line =$_; $score_line =~ /Score.*Expect = ([-.e\d]+)/; $e_value = $1; } } my ($Query_start, $Query_end, $subjct_start, $subjct_end); while (<INFILE>) { if ($subjct_ident && exists $hits{$subject_ident}{hit_data} && (/^>/ || /Score =/ || /^Lambda/ ) ) { push @{ $hits{$subject_ident}[-1] }, $Query_start, $Query_end, $subjct_start, $subjct_end; last if (/^Lambda/); $Query_start = $Query_end = $subjct_start = $subjct_end = 0; } } for each my $subject_ident (sort keys %hits) { print "$subject_ident:\n"; print " $hits{$subject_ident}{comment_line}\n"; print " Length = $hits{$subject_ident}{subject_length}\n"; foreach my $hit ( @{$hits{$subject_ident}{hit_data}} ) { print "@$hit\n"; } print "\n"; } THANK YOUUU!
|