-
Notifications
You must be signed in to change notification settings - Fork 0
/
pick.pl
executable file
·44 lines (35 loc) · 971 Bytes
/
pick.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/env perl
use strict;
BEGIN {
use FindBin '$Bin';
require "$Bin/share/flagdefinitions.pl";
}
if (@ARGV != 3) {
print STDERR "usage: ./zpick.pl block leftmap rightmap "
. "< classification\n";
exit;
};
my $blockstring = shift(@ARGV);
my ($leftmapfn, $rightmapfn) = @ARGV;
my $compiled = eval
'sub { local %_ = %{ shift @_; }; '. $blockstring .' }';
die $@ unless($compiled);
open(my $left , "<", $leftmapfn);
open(my $right, "<", $rightmapfn);
my $leftl; my $rigtl; my $ln;
while (<STDIN>) {
my %in = parse_class;
if ($compiled->(\%in)) {
# Find the sequences
while(($ln != $in{INDEX} * 4 + 2) && defined($leftl = <$left>)) {
$rigtl = <$right>;
$ln = $.;
}
print join("\t", $in{INDEX}, $in{FLAG},
$in{LEFTCHR}, $in{LEFTPOS}, $in{LEFTRST}, $leftl);
print join("\t", $in{INDEX}, $in{FLAG},
$in{RIGHTCHR}, $in{RIGHTPOS}, $in{RIGHTRST}, $rigtl);
}
}
close LEFT;
close RIGT;