#!/usr/bin/perl use strict; use warnings; my $infile = $ARGV[0]; unless (open (INFILE, "$infile")){ print STDERR "Can't open $infile $!\n"; die; } my ($header, $count , $match) = ('',0,0); print "\n\n"; #This algorithm will work only when the sequence is on one line while () { chomp; if ($_ =~ />(.*)/) { #a header line $header = $1; $count++; #keep running total of sequence number } else { #not a header my $i = 0; while ( $_ =~ /([VILMFWCA]{8,})/g) { my $domain = $1; my $len = length $domain; $len--; if ($i == 0){ print "Hydrophobic strecth found in: $header\n"; $match++; $i++; } print "$domain\n"; print "The match was at potistion: ", pos() - $len, "\n";; } if ($i > 0){ print "\n\n"; } } } close INFILE; print "Hydrophobic region(s) found in $match sequences out of $count sequences\n";