forked from josephryan/estimate_genome_size.pl
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfind_valleys.pl
executable file
·107 lines (80 loc) · 3.06 KB
/
find_valleys.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
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
#!perl
# Copyright (C) 2012,2013 Joseph F. Ryan
#
# 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/>.
use strict;
use warnings;
use Getopt::Long;
use Pod::Usage;
our $VERSION = 0.03;
our $AUTHOR = 'Joseph F. Ryan <joseph.ryan@whitney.ufl.edu>';
MAIN: {
my $opt_version = 0;
my $opt_help = 0;
my $opt_results = Getopt::Long::GetOptions( "version" => \$opt_version,
"help" => \$opt_help);
$opt_version && version();
pod2usage({-exitval => 0, -verbose => 2}) if $opt_help;
my $file = $ARGV[0] or usage();
open IN, $file or die "cannot open $file:$!";
my $first = <IN>;
chomp $first;
$first =~ m/^\s*\d+\s+(\d+)\s*$/ || die "unexpected input file format\n";
my $val = $1;
my $last_line = $first;
while (my $line = <IN>) {
chomp $line;
$line =~ m/^\s*\d+\s+(\d+)\s*$/ || die "unexpected input file format\n";
my $current_val = $1;
if ($current_val > $val) {
my $diff = $current_val - $val;
print "valley: $line (diff = $diff) - LAST: $last_line\n";
}
$last_line = $line;
$val = $current_val;
}
}
sub usage {
die "usage: $0 [--version] [--help] HISTO_FILE\n";
}
sub version {
die "find_valleys.pl $VERSION\n";
}
__END__
=head1 NAME
B<find_valleys.pl> - identify possible peaks in histogram data
=head1 AUTHOR
Joseph F. Ryan <joseph.ryan@whitney.ufl.edu>
=head1 SYNOPSIS
find_valleys.pl HISTO_FILE
=head1 DESCRIPTION
The script takes histogram file from jellyfish and identifies places where
the values begin to descend. It will print the descending coordinates as well
as the previous coordinates. It is suggested to interpret these results by
examining the actual histogram file and a plot generated by jellyplot.pl
=head1 BUGS
Please report them to <joseph.ryan@whitney.ufl.edu>
=head1 COPYRIGHT
Copyright (C) 2012 Joseph F. Ryan
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