5 use lib
'.','./blib','../../blib/lib';
10 Usage: $0 [options] feature_type1 feature_type2...
12 Dump out a GFF-formatted histogram of the density of the indicated set
16 --dsn <dsn> Data source (default dbi:mysql:test)
17 --adaptor <adaptor> Schema adaptor (default dbi::mysqlopt)
18 --user <user> Username for mysql authentication
19 --pass <password> Password for mysql authentication
20 --bin <bp> Bin size in base pairs.
21 --aggregator <list> Comma-separated list of aggregators
22 --sort Sort the resulting list by type and bin
23 --merge Merge features with same method but different sources
27 my ($DSN,$ADAPTOR,$AGG,$USER,$PASSWORD,$BINSIZE,$SORT,$MERGE);
28 GetOptions
('dsn:s' => \
$DSN,
29 'adaptor:s' => \
$ADAPTOR,
31 'password:s' => \
$PASSWORD,
32 'aggregators:s' => \
$AGG,
38 my @types = @ARGV or die $usage;
41 $DSN ||= 'dbi:mysql:test';
42 $ADAPTOR ||= 'dbi::mysqlopt';
43 $BINSIZE ||= 1_000_000
; # 1 megabase bins
46 push @options,(-user
=>$USER) if defined $USER;
47 push @options,(-pass
=>$PASSWORD) if defined $PASSWORD;
48 push @options,(-aggregator
=>[split /\s+/,$AGG]) if defined $AGG;
50 my $db = Bio
::DB
::GFF
->new(-adaptor
=>$ADAPTOR,-dsn
=> $DSN,@options)
51 or die "Can't open database: ",Bio
::DB
::GFF
->error,"\n";
53 my @features = $db->features(-binsize
=>$BINSIZE,-types
=>\
@types);
57 for my $f (@features) {
59 my $class = $name->class;
60 $name =~ s/^(.+:.+):.+$/$1/;
61 $f->group(Bio
::DB
::GFF
::Featname
->new($class,$name));
62 my $source = $f->source;
65 if (my $already_there = $MERGE{$f->source,$f->abs_ref,$f->abs_start}) {
66 $already_there->score($already_there->score + $f->score);
68 $MERGE{$f->source,$f->abs_ref,$f->abs_start} = $f;
71 @features = values %MERGE;
74 # sort features by type, ref and start if requested
78 || $a->abs_ref cmp $b->abs_ref
79 || $a->start <=> $b->start
84 for my $f (@features) {
85 print $f->gff_string,"\n";
93 bp_generate_histogram.pl -- Generate a histogram of Bio::DB::GFF features
97 bp_generate_histogram.pl -d gadfly variation gene:curated
101 Use this utility to generate feature density histograms from
102 Bio::DB::GFF databases. The result is a GFF data file that is
103 suitable for loading with load_gff.pl.
107 The following options are recognized:
112 --dsn <dsn> Data source (default dbi:mysql:test)
113 --adaptor <adaptor> Schema adaptor (default dbi::mysqlopt)
114 --user <user> Username for mysql authentication
115 --pass <password> Password for mysql authentication
116 --aggregator <list> Comma-separated list of aggregators
128 Lincoln Stein E<lt>lstein@cshl.orgE<gt>
130 Copyright (c) 2001 Cold Spring Harbor Laboratory
132 This library is free software; you can redistribute it and/or modify
133 it under the same terms as Perl itself. See DISCLAIMER.txt for
134 disclaimers of warranty.