Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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)


In reply to need help comparing DNA compliments by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (None)
    As of 2024-04-25 00:23 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found