Difference between revisions of "7) Aligning two protein sequences"

From Biolecture.org
imported>S
(Created page with "<p>Aligned two tumor protein using MEGA7 program.</p> <p>Tumor protein p53 and tumor protien p73.</p> <p>Could not upload mas output file. </p>")
 
imported>S
 
Line 1: Line 1:
<p>Aligned two tumor protein using MEGA7 program.</p>
+
<p><strong>This one compares two sequence, which user input. But is not designed for global alignment.&nbsp;</strong></p>
  
<p>Tumor protein p53 and tumor protien&nbsp;p73.</p>
+
<p>#!/usr/bin/perl<br />
 +
use strict;<br />
 +
use warnings;</p>
  
<p>Could not upload mas output file.&nbsp;</p>
+
<p>&nbsp; <strong>my $dna1 = &lt;STDIN&gt;;</strong><br />
 +
&nbsp; chomp($dna1);<br />
 +
&nbsp; &nbsp;my @string1 = split (&#39;&#39;, $dna1);<br />
 +
&nbsp; &nbsp;<strong>my $len1 = length $dna1;</strong></p>
 +
 
 +
<p>&nbsp; <strong>my $dna2 = &lt;STDIN&gt;;</strong><br />
 +
&nbsp; chomp ($dna2);<br />
 +
&nbsp; my @string2 = split (&#39;&#39;, $dna2);<br />
 +
&nbsp; <strong>my $len2 = length $dna2;</strong></p>
 +
 
 +
<p>sub max {<br />
 +
&nbsp; &nbsp; my ($max, @vars) = @_;<br />
 +
&nbsp; for (@vars) {<br />
 +
&nbsp; &nbsp;<strong> &nbsp;$max = $_ if $_ &gt; $max;</strong><br />
 +
&nbsp; &nbsp; }<br />
 +
&nbsp;return $max;<br />
 +
}</p>
 +
 
 +
<p><strong>&nbsp;my $stlen = max ($len1, $len2);</strong></p>
 +
 
 +
<p>&nbsp; <strong>foreach (my $i =0; $i &lt; $stlen; $i++) </strong>{<br />
 +
&nbsp; &nbsp; &nbsp; if ( $string1[$i] eq $string2[$i] ) {<br />
 +
&nbsp; &nbsp; &nbsp;print &quot; $string1[$i] = $string2[$i]\n&quot;;}<br />
 +
&nbsp; &nbsp;else<br />
 +
&nbsp; &nbsp; &nbsp; &nbsp; { print &quot;$string1[$i] x $string2[$i]\n&quot;; }<br />
 +
}<br />
 +
&nbsp;</p>
 +
 
 +
<p><strong>The output result sample is:</strong>&nbsp;</p>
 +
 
 +
<p>MKRRRLLYYILEUGNMCG<br />
 +
KKKRRLLYVILEUGNNNG<br />
 +
&nbsp;M x K<br />
 +
&nbsp;K = K<br />
 +
&nbsp;R x K<br />
 +
&nbsp;R = R<br />
 +
&nbsp;R = R<br />
 +
&nbsp;L = L<br />
 +
&nbsp;L = L<br />
 +
&nbsp;Y = Y<br />
 +
&nbsp;Y x V<br />
 +
&nbsp;I = I<br />
 +
&nbsp;L = L<br />
 +
&nbsp;E = E<br />
 +
&nbsp;U = U<br />
 +
&nbsp;G = G<br />
 +
&nbsp;N = N<br />
 +
&nbsp;M x N<br />
 +
&nbsp;C x N<br />
 +
&nbsp;G = G<br />
 +
&nbsp;</p>

Latest revision as of 18:47, 13 June 2017

This one compares two sequence, which user input. But is not designed for global alignment. 

#!/usr/bin/perl
use strict;
use warnings;

  my $dna1 = <STDIN>;
  chomp($dna1);
   my @string1 = split ('', $dna1);
   my $len1 = length $dna1;

  my $dna2 = <STDIN>;
  chomp ($dna2);
  my @string2 = split ('', $dna2);
  my $len2 = length $dna2;

sub max {
    my ($max, @vars) = @_;
  for (@vars) {
     $max = $_ if $_ > $max;
    }
 return $max;
}

 my $stlen = max ($len1, $len2);

  foreach (my $i =0; $i < $stlen; $i++) {
      if ( $string1[$i] eq $string2[$i] ) {
     print " $string1[$i] = $string2[$i]\n";}
   else
        { print "$string1[$i] x $string2[$i]\n"; }
}
 

The output result sample is: 

MKRRRLLYYILEUGNMCG
KKKRRLLYVILEUGNNNG
 M x K
 K = K
 R x K
 R = R
 R = R
 L = L
 L = L
 Y = Y
 Y x V
 I = I
 L = L
 E = E
 U = U
 G = G
 N = N
 M x N
 C x N
 G = G