Monday, June 8, 2009

perl problem -4 (easy)

hi everyone,

Write a program that scans a given DNA string for incorrect nucleotides (i.e other than A,G,C,T) and replace them with a *

Example input
AGUCGACFTGCTCGATC

Example output

AG*CGAC*TGCTCGATC

4 comments:

  1. Isn't U one of the nucleotide bases? When translated T becomes U right? Correct me if I am wrong but m-RNA sequences will contain U, and so a * must be placed at places other than A,T, C, G and U. But if we are looking at an m-RNA sequence then, there must be no T's. So how do you propose to approach this problem? This can definitely be applied to areas of data curation in new databases.

    ReplyDelete
  2. Thats why I have specified 'DNA' string. DNA when transcribed into mRNA have 'U'.(T in DNA will be converted to U in mRNA).Translation is a different process where mRNA is converted to protein.DNA strings wont contain 'U'.They will contain only AGCT . mRNA will contain AGCU. So u have to place a * at U also.

    ReplyDelete
  3. HERE IS A SOLUTION TO PERL PROBLEM 4 BY AMIT

    my $input="AGUCGACFTGCTCGATC";
    my @temp=split("",$input);
    my $output="";

    foreach my $char ( @temp ) {
    if ( $char =~ /[AGCT]/ ) {
    $output .= $char;
    }
    else
    {
    $output .= "*";
    }

    }

    print "\n Output : $output \n";

    ReplyDelete
  4. chomp($input = <>);
    $input =~ s/[^AGTC]/\*/g;
    print "$input\n";

    ReplyDelete