×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

string mutation script behaving erraticaly

string mutation script behaving erraticaly

string mutation script behaving erraticaly

(OP)
Dear all,
I have written a perl program which mutates a a protein sequence ( based on 20 alphabets).
For each character it encounters the program generates a random number between 0 and 1
(#line_46)
Im using hash for the program. But I dont know why this problem. Try running the code.

CODE --> perl

#!/usr/bin/perl -w

use Time::HiRes qw(usleep nanosleep);



%nuc = (

F => [qw( .0001 .0001 .0001 .0000 .0000 .0000 .0000 .0001 .0002 .0008 .0006 .0000 .0004 .9944 .0000 .0000 .0001 .0003 .0028 .0000)],

T => [qw( .0022 .0002 .0013 .0004 .0001 .0003 .0002 .0002 .0001 .0011 .0002 .0008 .0006 .0001 .0005 .0032 .9874 .0000 .0002 .0009)],

N => [qw( .0004 .0001 .9867 .0036 .0000 .0004 .0006 .0006 .0021 .0003 .0001 .0013 .0000 .0001 .0002 .0020 .0009 .0001 .0004 .0001)],

V => [qw( .0013 .0002 .0001 .0001 .0003 .0002 .0002 .0003 .0003 .0057 .0011 .0001 .0017 .0001 .0003 .0002 .0010 .0000 .0002 .9866)],

K => [qw( .0002 .0037 .0025 .0006 .0000 .0012 .0007 .0002 .0002 .0004 .0001 .9858 .0020 .0000 .0003 .0008 .0011 .0000 .0001 .0001)],

E => [qw( .0010 .0000 .0007 .0056 .0000 .0035 .9865 .0004 .0002 .0003 .0001 .0004 .0001 .0000 .0003 .0004 .0002 .0000 .0001 .0002)],

Y => [qw( .0001 .0000 .0003 .0000 .0003 .0000 .0001 .0000 .0004 .0001 .0001 .0000 .0000 .0021 .0000 .0001 .0001 .0002 .9960 .0001)],

Q => [qw( .0003 .0010 .0004 .0005 .0000 .9901 .0027 .0001 .0024 .0001 .0003 .0006 .0004 .0000 .0006 .0002 .0002 .0000 .0000 .0001)],

I => [qw( .0002 .0002 .0003 .0001 .0002 .0001 .0002 .0000 .0000 .9915 .0009 .0002 .0012 .0007 .0000 .0001 .0007 .0000 .0001 .0033)],

C => [qw( .0001 .0001 .0000 .0000 .9987 .0000 .0000 .0000 .0001 .0001 .0000 .0000 .0000 .0000 .0001 .0005 .0001 .0000 .0000 .0002)],

L => [qw( .0003 .0001 .0003 .0000 .0000 .0006 .0001 .0001 .0004 .0022 .9871 .0002 .0045 .0013 .0003 .0001 .0003 .0004 .0002 .0015)],

M => [qw( .0001 .0001 .0000 .0000 .0000 .0002 .0000 .0000 .0000 .0005 .0009 .0005 .9968 .0001 .0000 .0001 .0002 .0000 .0000 .0005)],

A => [qw( .9799 .0002 .0009 .0010 .0003 .0008 .0017 .0021 .0002 .0006 .0004 .0002 .0006 .0002 .0022 .0035 .0032 .0000 .0002 .0018)],

W => [qw( .0000 .0002 .0000 .0000 .0000 .0000 .0000 .0000 .0000 .0000 .0000 .0000 .0000 .0001 .0000 .0001 .0000 .9995 .0001 .0000)],

S => [qw( .0028 .0011 .0034 .0007 .0011 .0004 .0006 .0016 .0002 .0002 .0001 .0007 .0004 .0003 .0017 .9800 .0038 .0005 .0002 .0002)],

P => [qw( .0013 .0005 .0002 .0001 .0001 .0008 .0003 .0002 .0005 .0001 .0002 .0002 .0001 .0001 .9935 .0012 .0004 .0000 .0000 .0002)],

H => [qw( .0001 .0008 .0018 .0003 .0001 .0020 .0001 .0000 .9933 .0000 .0001 .0001 .0000 .0002 .0003 .0001 .0001 .0001 .0004 .0001)],

D => [qw( .0006 .0000 .0042 .9869 .0000 .0006 .0053 .0006 .0004 .0001 .0000 .0003 .0000 .0000 .0001 .0005 .0003 .0000 .0000 .0001)],

R => [qw( .0001 .9929 .0001 .0000 .0001 .0010 .0000 .0000 .0010 .0003 .0001 .0019 .0004 .0001 .0004 .0006 .0001 .0008 .0000 .0001)],

G => [qw( .0021 .0001 .0012 .0011 .0001 .0003 .0007 .9906 .0001 .0000 .0001 .0002 .0001 .0001 .0003 .0021 .0003 .0000 .0000 .0005)]);









#SVEQRISTDIGQAYQLQGLGSNLRSIRSKTGAGEVNYIDAAKSVNDNQLLAEIG

$string='AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';

@seq=split(//,$string);

$size=scalar(@seq);

print "$size\n";



foreach $seq (@seq)

{

&mutate($seq) ;

print "##########SEQ=$seq\tRANDOM=$ran\tK=$k################";

usleep (1000000);

}



$k=0;

$p=0;

sub mutate # Start Of Sub

{

$ran=`awk 'BEGIN {{srand()} {print rand()}}'`;

for ($j = 1; $j <= 20;$j++)

{ $mut[$j]=$nuc{$seq}[$j]; }

for ($i=1; $i<=20; $i++)

{

print "$mut[$i]\t$ran\t";

if ($ran < $mut[$i])

{#print "\n$mut[$i] \t hello";

push (@names, $i);

print "i=$i";

#push (@names, '-');

}

last if $ran < $mut[$i];

print"\tran=$ran\t muti=$mut[$i]";

$k =$mut[$i];

print "K = $k";

} $p++; #counter for serial number

} # End Of Sub





# $nam=join ' ',@names;

# for ($j = 0; $j <=$size;$j++)

# {print $names[$j];}

print"\n";

for ($j = 0; $j < $size;$j++)

{

if($names[$j]==1)

{$names[$j]="A";}

elsif($names[$j]==2)

{$names[$j]="R";}

elsif($names[$j]==3)

{$names[$j]="N";}

elsif($names[$j]==4)

{$names[$j]="D";}

elsif($names[$j]==5)

{$names[$j]="C";}

elsif($names[$j]==6)

{$names[$j]="Q";}

elsif($names[$j]==7)

{$names[$j]="E";}

elsif($names[$j]==8)

{$names[$j]="G";}

elsif($names[$j]==9)

{$names[$j]="H";}

elsif($names[$j]==10)

{$names[$j]="I";}

elsif($names[$j]==11)

{$names[$j]="L";}

elsif($names[$j]==12)

{$names[$j]="K";}

elsif($names[$j]==13)

{$names[$j]="M";}

elsif($names[$j]==14)

{$names[$j]="F";}

elsif($names[$j]==15)

{$names[$j]="P";}

elsif($names[$j]==16)

{$names[$j]="S";}

elsif($names[$j]==17)

{$names[$j]="T";}

elsif($names[$j]==18)

{$names[$j]="W";}

elsif($names[$j]==19)

{$names[$j]="Y";}

else {$names[$j]="V";}

}





print "orig = $string \nmuta = ";

for ($j = 0; $j <=$size;$j++)

{print $names[$j];}

@arr = %nuc;

print "@arr";

RE: string mutation script behaving erraticaly

I'm not sure what the problem you're having is exactly.

You mention generating a random number between 0 and 1 - is it not supposed to do that? What output are you expecting? What aren't you getting?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close