#!/usr/bin/perl use strict; use warnings; use diagnostics; unless (open (INFILE, "<", "/scratch/SampleDataFiles/test.fasta")){ die "Unable to open file", $!; } local $/ = ">"; #find and print desired sequence while () { chomp; #always chomp if ( $_ =~ /^(.*?)$(.*)$/ms ) { #match first line as header my $header = $1; #assign the parts of the match my $seq = $2; $seq =~ s/\n//g; #get rid of whitespace while($seq =~ /([VILMFWCA]{8,})/g){ #search for desired sequence my $location = pos($seq); #find location my $length = length($1); #determine length print "Hydrophobic stretch found in: ", $header, "\n"; #printing outputs for results print $1, "\n"; print "The match was at position: ", $location - $length + 1, "\n\n"; } } } close INFILE; #### Hydrophobic stretch found in: P30450 | Homo sapiens (Human). | NCBI_TaxID=9606; | 365 | Name=HLA-A; Synonyms=HLAA; AVVAAVMW The match was at position: 325 Hydrophobic stretch found in: A7MBM2 | Homo sapiens (Human). | NCBI_TaxID=9606; | 1401 | Name=DISP2; Synonyms=DISPB, KIAA1742; VAVLMLCLAVIFLC The match was at position: 170 LLALVAIFF The match was at position: 493 IWICWFAALAA The match was at position: 705 LALALAFA The match was at position: 970 #### Hydrophobic stretch found in: P30450 | Homo sapiens (Human). | NCBI_TaxID=9606; | 365 | Name=HLA-A; Synonyms=HLAA; AVVAAVMW The match was at position: 325 Hydrophobic stretch found in: A7MBM2 | Homo sapiens (Human). | NCBI_TaxID=9606; | 1401 | Name=DISP2; Synonyms=DISPB, KIAA1742; VAVLMLCLAVIFLC The match was at position: 170 Hydrophobic stretch found in: A7MBM2 | Homo sapiens (Human). | NCBI_TaxID=9606; | 1401 | Name=DISP2; Synonyms=DISPB, KIAA1742; LLALVAIFF The match was at position: 493 Hydrophobic stretch found in: A7MBM2 | Homo sapiens (Human). | NCBI_TaxID=9606; | 1401 | Name=DISP2; Synonyms=DISPB, KIAA1742; IWICWFAALAA The match was at position: 705 Hydrophobic stretch found in: A7MBM2 | Homo sapiens (Human). | NCBI_TaxID=9606; | 1401 | Name=DISP2; Synonyms=DISPB, KIAA1742; LALALAFA The match was at position: 970