-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfilter_by_coord.pl
More file actions
executable file
·112 lines (85 loc) · 2.75 KB
/
filter_by_coord.pl
File metadata and controls
executable file
·112 lines (85 loc) · 2.75 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/env perl
use warnings;
use strict;
use Data::Dumper;
use Carp;
use Getopt::Long;
use Pod::Usage;
# Check required command line parameters
unless (@ARGV > 0) {
pod2usage ( -verbose => 1 );
}
# Grabs and parses command line options
my $result = GetOptions (
'verbose|v' => sub { use diagnostics; },
'quiet|q' => sub { no warnings; },
'help|h' => sub { pod2usage ( -verbose => 1 ); },
'manual|m' => sub { pod2usage ( -verbose => 2 ); }
);
my %buffer = ();
while (1) {
my $previous = <>;
last if !defined $previous;
next if $previous =~ m/#|chr[cm]/i;
my $current = <>;
last if !defined $current;
next if $current =~ m/#|chr[cm]/i;
my $next = <>;
last if !defined $next;
next if $next =~ m/#|chr[cm]/i;
my ($previous_c, $current_c, $next_c)
= (0, 0, 0);
($previous_c) = $previous =~ m/c=(\d+)?;/;
($current_c) = $current =~ m/c=(\d+)?;/;
($next_c) = $next =~ m/c=(\d+)?;/;
if ((exists $buffer{nnc} and $buffer{nnc}->[1] > 1) and
((exists $buffer{nc} and $buffer{nc} > 1) or $previous_c > 1)) {
print $buffer{nnc}->[0];
delete $buffer{nnc};
}
if ($current_c <= 1 and $previous_c > 1 and
exists $buffer{nc} and $buffer{nc} > 1) {
print $previous;
delete $buffer{nc};
}
if ($current_c > 1) {
print $previous if $previous_c > 1;
print $current if $previous_c > 1 or $next_c > 1;
print $next if $next_c > 1;
}
elsif ($next_c > 1) {
my $nnext = <>;
last if !defined $nnext;
next if $nnext =~ m/#|chr[cm]/i;
my ($nnext_c) = $nnext =~ m/c=(\d+)?;/;
print $next if $nnext_c > 1;
$buffer{nnc} = [$nnext, $nnext_c];
}
$buffer{pc} = $previous_c;
$buffer{cc} = $current_c;
$buffer{nc} = $next_c;
}
__END__
=head1 NAME
=head1 SYNOPSIS
=head1 DESCRIPTION
=head1 OPTIONS
=head1 REVISION
=head1 AUTHOR
Pedro Silva <psilva@nature.berkeley.edu/>
Zilberman Lab <http://dzlab.pmb.berkeley.edu/>
Plant and Microbial Biology Department
College of Natural Resources
University of California, Berkeley
=head1 COPYRIGHT
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
=cut