Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I really wanted to solve this problem as it was rather interesting, but I couldn't figure out what you were looking for in @seg_mis, so you might want to read the node that broquaint suggested. In the meantime, here's what I whipped up. It's a bit closer, but not quite what you need. If you can show sample output for both arrays, that would help.

#!/usr/bin/perl -w use strict; use Data::Dumper; my @segments = map { [split //] } qw( ATCG AAGG ); print Dumper get_mismatches(@segments); sub get_mismatches { my ($segment, $comp_segment) = make_base_pairs(@_); my @seg_mismatches; my @seg_mis; foreach my $i ( 0 .. $#$segment ) { my $p1 = $segment->[$i]; my $p2 = $comp_segment->[$i]; if ( bad_pair($p1->[0],$p2->[0]) or bad_pair($p1->[1],$p2->[1]) ) { push @seg_mismatches => sprintf "%s%s/%s%s", @$p1, @$p2; } } return (\@seg_mismatches, \@seg_mis); } sub make_base_pairs { my @segment = @_; # assumes length of 4. Don't know if this is correct my @results; foreach my $dna (@segment) { push @results => [ [@{$dna}[0..1]], [@{$dna}[2..3]] ]; } return @results; } sub bad_pair { my ($a,$b) = @_; my %good_pairs = ( 'A'=> 'T', 'C' => 'G', 'G' => 'C', 'T' => 'A' ); return 1 if exists $good_pairs{$a} and $good_pairs{$a} eq $b; }


New address of my CGI Course.
Silence is Evil (feel free to copy and distribute widely - note copyright text)

In reply to Re: Finding DNA string mismatches by Ovid
in thread Finding DNA string mismatches by Anonymous Monk

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?

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2023-03-23 23:20 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (60 votes). Check out past polls.