Difference between revisions of "5) Extracting a sequence MKKTGIKG from ASMKATAHQMKKTGIKGMSTYALLRL"

From Biolecture.org
imported>S
(Created page with "<p><span style="font-size:14px"><strong>There is given sequence, and if there is MKKTGIKG in sequence, it will match and print it to the new "output.txt" file.</strong>...")
(No difference)

Revision as of 17:34, 17 May 2017

There is given sequence, and if there is MKKTGIKG in sequence, it will match and print it to the new "output.txt" file.  

#!/usr/bin/perl
 use strict;
 use warnings;
 open(OUT, ">output.txt") or die "Can't open file $_\n";      ##it creates new text file
 my $seq ="ASMKATAHQMKKTGIKGMSTYALLRL";
 if ( $seq =~ /(MKKTGIKG)/){                   ##finding particular matchings in a scalar variable
 print OUT "$1\n";                           ##$1 means matched item in a parenthesis
}
 else { print OUT $seq;}                  ##if there is no match, will print out original sequence