can download plant phenotype data in the same way as plot phenotype data
[sgn.git] / lib / SGN / Feature / GBrowse / DataSource.pm
blobacdf2ff6173d475f64241adf8f95a4fd6f93a79f
1 package SGN::Feature::GBrowse::DataSource;
2 use Moose;
3 use namespace::autoclean;
4 use Carp;
5 use MooseX::Types::Path::Class;
6 use URI;
7 use URI::Escape;
8 use URI::QueryParam;
10 use Bio::Graphics::FeatureFile;
12 has 'name' => ( documentation => <<'',
13 name of the data source
15 is => 'ro',
16 isa => 'Str',
17 required => 1,
20 has 'description' => ( documentation => <<'',
21 short description of this data source - one line
23 is => 'ro',
24 isa => 'Str',
25 required => 1,
28 has 'extended_description' => ( documentation => <<'',
29 fuller description of this data source, 1-2 sentences
31 is => 'ro',
32 isa => 'Maybe[Str]',
35 has 'organism' => ( documentation => <<'',
36 string name of the organism(s) the *reference sequences* for this set
37 are from. Usually species name.
39 is => 'ro',
40 isa => 'Maybe[Str]',
43 has 'gbrowse' => ( documentation => <<'',
44 GBrowse Feature object this data source belongs to
46 is => 'ro',
47 required => 1,
48 weak_ref => 1,
51 has 'path' => ( documentation => <<'',
52 absolute path to the data source's config file
54 is => 'ro',
55 isa => 'Path::Class::File',
56 required => 1,
59 has 'config' => ( documentation => <<'',
60 the parsed config of this data source, a Bio::Graphics::FeatureFile
62 is => 'ro',
63 isa => 'Bio::Graphics::FeatureFile',
64 lazy_build => 1,
65 ); sub _build_config {
66 Bio::Graphics::FeatureFile->new(
67 # -file => shift->path->stringify,
68 # -safe => 1,
72 has '_databases' => (
73 is => 'ro',
74 isa => 'HashRef',
75 traits => ['Hash'],
76 lazy_build => 1,
77 handles => {
78 databases => 'values',
79 database => 'get',
81 ); sub _build__databases {
82 die 'database parsing not implemented for gbrowse 1.x';
86 sub view_url {
87 shift->_url( 'gbrowse', @_ );
90 sub image_url {
91 my ( $self, $q ) = @_;
92 $q ||= {};
93 $q->{width} ||= 600;
94 $q->{keystyle} ||= 'between',
95 $q->{grid} ||= 'on',
96 return $self->_url( 'gbrowse_img', $q );
99 sub _url {
100 my ( $self, $script, $query ) = @_;
101 my $url = $self->gbrowse->cgi_url->clone;
102 $url->path( join '', map "$_/", $url->path, $script, $self->name );
103 $url->query_form_hash( $query ) if $query;
104 return $url;
109 __PACKAGE__->meta->make_immutable;