Changes
no edit summary
<p><span style="font-size:14px"><strong>There is a given sequence, and if there is this script can extract "MKKTGIKG in " from the sequence, it will match and print it to the new "output.txt" file.</strong></span> </p>
<p><span style="font-size:14px">#!/usr/bin/perl<br />
use strict;<br />
use warnings;<br />
<strong> open(<strong>OUT</strong>, ">output.txt") </strong> or die "Can't open file $_\n"; ##it creates new text file<br /> my <strong>$seq</strong> ="ASMKATAHQMKKTGIKGMSTYALLRL";<br /> if (print OUT "Original sequence: $seq\n";<br /><strong> $seq =~ s/(MKKTGIKG)//g;</strong>/){ ##finding particular matchings in a scalar variable<br /> <strong>print OUT "After extraction: $1seq\n"; ##$1 means matched item in a parenthesis</span></p> <p>-----------------------------------------------------</p> <p><strong>The output file content:<br /strong>}<br /p> else { print OUT $seq;} ##if there is no match, will print out original <p>Original sequence: ASMKATAHQMKKTGIKGMSTYALLRL<br /span>After extraction: ASMKATAHQMSTYALLRL<br /p> <p> </p>