#!/usr/bin/perl # Read search terms into array @terms open (SRC, $searchTermsFile) || die "can't open search terms file"; @terms = ; chomp (@terms); @terms = sort @terms; my @annotationlist; #------------------------------------------------------- # Search each line in annotations file for match with search terms %nTermHits = (); $nTotalHits = 0; open (ANN, $annotationsFile) || die "$annotationsFile won't open\n"; while ($line = ) { #chomp($line); @fields = split(/\t/, $line); $annotation = $fields [2]; foreach $term (@terms) { if($annotation =~ /(\b($term)\b|$term-)\b|(-$term)\b/i) { $nTermHits {$term}++; $nTotalHits++; push(@annotationlist, "$annotation\n"); } }} #@annotationlist = sort @annotationlist; #print "@annotationlist\n"; #--------------------------------------- foreach $term (@terms) { if ($nTermHits {$term} > 0) { printf "%s\t%d\n", $term, $nTermHits {$term}; } } print "Total hits: $nTotalHits\n"; #-----------------------------