tryingnottofailmytes has asked for the wisdom of the Perl Monks concerning the following question:
I don't really understand why this isn't working I'm not sure what the differences is between my and the posted solution, which has the for loop go backwards instead of forwards.... Can anyone offer any help?my $dna = 'atgAAAAAAAAAAGGGGGGGGGGTTTTTTTTCCCCCCCCCCCCagtcatc'; $dna = uc$dna; print "$dna\n"; my $revDNA= reverse $dna; print "$revDNA\n"; my $length = length$revDNA; my $complement = ''; for (my $i=0;$i>$length-1; $i++) { my $base= substr($revDNA,$i,1); if ($base eq 'A') { $base = 'T'; } elsif ($base eq 'T') { $base = 'U'; } elsif ($base eq 'G') { $base = 'C'; } elsif ($base eq 'C') { $base = 'G'; } $complement.=$base; } print $complement, "\n"; exit;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Trying to use substring to find a reverse complement in DNA,
by RichardK (Parson) on Dec 05, 2015 at 23:12 UTC | |
by AnomalousMonk (Archbishop) on Dec 06, 2015 at 02:32 UTC | |
by tryingnottofailmytes (Novice) on Dec 05, 2015 at 23:24 UTC | |
Re: Trying to use substring to find a reverse complement in DNA,
by johngg (Canon) on Dec 06, 2015 at 00:16 UTC | |
Re: Trying to use substring to find a reverse complement in DNA,
by Anonymous Monk on Dec 06, 2015 at 04:40 UTC | |
by Cristoforo (Curate) on Dec 06, 2015 at 04:47 UTC | |
by Laurent_R (Canon) on Dec 06, 2015 at 09:28 UTC | |
Re: Trying to use substring to find a reverse complement in DNA,
by BillKSmith (Monsignor) on Dec 06, 2015 at 14:55 UTC |