Open main menu

Biolecture.org β

Changes

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>..."
<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 &quot;output.txt&quot; file.</strong></span> &nbsp;</p>

<p><span style="font-size:14px">#!/usr/bin/perl<br />
&nbsp;use strict;<br />
&nbsp;use warnings;<br />
&nbsp;open(<strong>OUT</strong>, &quot;&gt;output.txt&quot;) or die &quot;Can&#39;t open file $_\n&quot;; &nbsp; &nbsp; &nbsp;##it creates new text file<br />
&nbsp;my <strong>$seq</strong> =&quot;ASMKATAHQMKKTGIKGMSTYALLRL&quot;;<br />
&nbsp;if (<strong> $seq =~ /(MKKTGIKG)</strong>/){ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##finding particular&nbsp;matchings in a scalar variable<br />
&nbsp;<strong>print OUT &quot;$1\n&quot;; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##$1 means matched item in a parenthesis</strong><br />
}<br />
&nbsp;else { print OUT $seq;} &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;##if there is no match, will print out original sequence</span><br />
&nbsp;</p>
Anonymous user