Hi monks,
I wondered if someone would be able to help me.
I simply want to compare two strings of dna (complements of each other)
and determine whether they are correctly matched. e.g given two strings
ATCG..
TAGC..
Compare the first position in each, second position etc...However,
if a base in the string does'nt correspond to its correct complement in the
second string i want to print out that base pair.(correct pairings are A-T and G-C) e.g.
ACTG..
TGAT..
G-T is a mispair
I thought about using substr but don't know how to use substr to compare two strings.
Here is a snippet of what i've tried. Much thanks ;-)
my @dna; # contains the sequence
my @comp; # contains the complement
while (@dna) {
foreach my $base (@dna) {
++$counter;
}
foreach my $base2 (@comp) {
++$counter2;
}
if (($base[$counter] == 'A') && ($base2[$counter2] !~ 'T') {
print "mismatch : $base[$counter] \t $base2[$counter2]\n
+";
}
# etc
}
but obviuously using this approach i will have to type out the same line for
each base in the sequence.
update (broquaint): title change (was newbie seeks help comparing strings)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.