Here's an approach to the problem of comparing records. Validity checking stub functions are included just as a suggestion of good practice; there are other ways of handling this. I notice that the  'HG00096.' section in each record pair always seems to be the same. If so, a check for this might be included in the
    m{ \A .{9} (?: \x00\x00){13} \z }xms
regex, but I would prefer to do it in a separate validity check. If the initial sections of each pair up to and including the M/P character are guaranteed to be good, it's only necessary to check for equality of the tail section, e.g., with a
    m{ (?: \x00\x00){13} \z }xms
regex.

File filter_MP_records_1.pl:

use warnings; use strict; <DATA>; # discard first line/record of data MP_PAIR: while (my $m = <DATA>) { my $bad; # badness message from validity checks (empty if ok) die qq{bad M record '$m': $bad} if $bad = bad_M_record($m); defined(my $p = <DATA>) or die qq{M record '$m' has no P record}; die qq{bad P record '$p': $bad} if $bad = bad_P_record($p); die qq{bad MP pair '$m'/'$p': $bad} if $bad = bad_MP_pair({M => $m +, P => $p}); chomp($m, $p); my $x = $m ^ $p; # detect equal sub-regions # are ' 0 1 0 0 1 1' sequences at end of records the same? next MP_PAIR unless $x =~ m{ \A .{9} (?: \x00\x00){13} \z }xms; do_something_with({M => $m, P => $p}); } # end while MP_PAIR # stubs for validity checking functions. sub bad_M_record { return ''; } sub bad_P_record { return ''; } sub bad_MP_pair { return ''; } sub do_something_with { my ($hr_MP_args, ) = @_; printf qq{M '%s' \nP '%s' \n\n}, @{ $hr_MP_args }{ qw(M P) }; } __DATA__ INDIV 16051347(G-C) 16051497(A-G) 16052239(A-G) 16052513(G-C) 16052618 +(G-A) 16053659(A-C) 16054667(C-G) HG00096.M 0 0 0 1 1 1 1 1 0 0 0 0 0 HG00096.P 0 0 1 0 0 0 0 1 0 0 0 0 0 HG00097.M 1 1 0 0 0 0 0 0 0 0 0 1 0 HG00097.P 0 0 1 0 0 1 0 1 1 1 0 0 0 HG00099.M 1 1 0 0 0 0 0 0 0 0 0 0 0 HG00099.P 0 0 0 0 1 1 0 0 1 1 0 1 0 HG00100.M 0 0 1 1 1 1 1 1 1 1 1 1 1 HG00100.P 1 1 0 0 0 1 0 0 1 1 0 1 0 HG00101.M 1 1 0 0 0 1 0 0 1 1 0 1 0 HG00101.P 0 0 1 1 1 1 1 1 1 1 1 1 0 HG00102.M 1 1 0 0 0 0 0 0 0 0 0 1 0 HG00102.P 0 0 1 0 0 1 0 1 1 1 0 1 0 EQ99991.M 0 1 0 0 1 1 0 0 0 1 1 1 0 EQ99991.P 0 1 0 0 1 1 0 0 0 1 1 1 0 HG00103.M 0 0 0 0 0 0 0 0 0 0 0 0 0 HG00103.P 1 0 0 0 0 0 0 0 0 0 0 0 0 EQ99992.M 1 0 1 0 1 0 1 0 1 0 1 0 1 EQ99992.P 1 0 1 0 1 0 1 0 1 0 1 0 1
Output:
c:\@Work\Perl\monks\A1 Transcendence>perl filter_MP_records_1.pl M 'EQ99991.M 0 1 0 0 1 1 0 0 0 1 1 1 0' P 'EQ99991.P 0 1 0 0 1 1 0 0 0 1 1 1 0' M 'EQ99992.M 1 0 1 0 1 0 1 0 1 0 1 0 1' P 'EQ99992.P 1 0 1 0 1 0 1 0 1 0 1 0 1'


Give a man a fish:  <%-{-{-{-<


In reply to Re: SEEKING HELP by AnomalousMonk
in thread SEEKING HELP by A1 Transcendence

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



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.