can download plant phenotype data in the same way as plot phenotype data
[sgn.git] / lib / SGN / Feature / LocusPages.pm
blobac55799bff915e805e1f999371a54052a82b2547
1 package SGN::Feature::LocusPages;
2 use Moose;
3 use namespace::autoclean;
5 use URI;
7 use CXGN::Phenome;
9 use SGN::SiteFeatures::CrossReference;
11 extends 'SGN::Feature';
13 has '+description' => (
14 default => 'Genetic loci',
17 sub xrefs {
18 my ( $self, $query ) = @_;
20 return if ref $query;
22 return ( $self->_name_xrefs( $query ),
23 #$self->_phenotype_xrefs( $query ),
27 sub _name_xrefs {
28 my ( $self, $q ) = @_;
30 my $search = CXGN::Phenome->new;
31 my $query = $search->new_query;
32 $query->locus_obsolete(" = 'f' ");
33 $query->any_name("lower(&t) = ? ", lc $q );
34 my $result = $search->do_search($query);
36 # fetch at most 5 results, hashing by locus name
37 my %results = map { $_->[1] => $_ } reverse grep $_, map { $result->next_result } 1..5;
39 # make xrefs out of them
40 my @xrefs;
41 for my $locus_name ( sort keys %results ) {
42 my $r = $results{$locus_name};
44 my $text = qq|$r->[14] locus $r->[2]|;
45 $text .= " ($locus_name)" unless $locus_name eq $r->[2];
47 push @xrefs, SGN::SiteFeatures::CrossReference->new({
48 feature => $self,
49 text => $text,
50 url => URI->new( '/phenome/locus_display.pl?locus_id='.$r->[0] ),
51 });
54 return @xrefs;