in reply to SEEKING HELP
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:
Output: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
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: <%-{-{-{-<
|
|---|