#!/usr/bin/perl -w use strict; #open blastx output file my $file = shift @ARGV; #define variables my ($queryname, $temseq, $wormid, $geneano, $evalue); #a flag for determine top hits my $first = 0; #read in file open (IN, "<$file"); while (my $line = ) { #pull out queryname if ($line =~ /^Query=\s+(\d+)/) { $queryname = $1; $first = 1; } #pull out wormID and gene annotation elsif ($first == 1 && $line =~ /^>/) { chomp ($line); $temseq = $line; #append the 2nd line containing the annotation $line = ; $temseq .= $line; if ($temseq =~ /^>(\S+)\s\S+\s\S+\s(.+)\sprotein/) { $wormid = $1; $geneano = $2; } } #pull out evalue and print elsif ($first == 1 && $line =~ /Expect =\s(\S+),\sP/) { $evalue = $1; print "$queryname, $wormid, $geneano, $evalue\n"; $first = 0; } } close IN;