update empty fixture to something that is more up to date.
[sgn.git] / cgi-bin / phenome / locus_browser.pl
blobaec0cc47f7692cd3d8848d6ec7aa5d91f30c715b
1 use CatalystX::GlobalContext qw( $c );
2 use strict;
3 use warnings;
5 use CXGN::Scrap::AjaxPage;
6 use CXGN::DB::Connection;
7 use CXGN::Login;
8 use CXGN::Contact;
9 use CXGN::People::Person;
11 use CXGN::Phenome::LocusgroupMember;
12 use CXGN::Phenome::Locus;
13 use CXGN::Chado::Cvterm;
14 use CXGN::Feed;
15 use CXGN::Tools::Organism;
17 use JSON;
20 my $doc = CXGN::Scrap::AjaxPage->new();
21 $doc->send_http_header();
23 my ($type, $locus_name, $object_id, $organism, $subject_id, $relationship_id, $evidence_id, $reference_id, $lgm_id) = $doc->get_encoded_arguments("type", "locus_name", "object_id", "organism", "locus_id", "locus_relationship_id", "locus_evidence_code_id", "locus_reference_id", "lgm_id");
27 my $dbh = CXGN::DB::Connection->new();
28 my $schema= $c->dbic_schema('CXGN::Phenome::Schema');
30 my ($login_person_id, $login_user_type)=CXGN::Login->new($dbh)->verify_session();
32 if ($login_user_type eq 'curator' || $login_user_type eq 'submitter' || $login_user_type eq 'sequencer') {
34 if ($type eq 'browse locus') {
35 if (!$organism) { ($locus_name, $organism) = split(/,\s*/, $locus_name); }
36 $locus_name =~ /(\w+)/;
37 $locus_name =$1;
38 if (($locus_name) && ($organism)) {
39 my $locus_query = "SELECT locus_id, locus_symbol, locus_name, common_name FROM phenome.locus
40 JOIN sgn.common_name USING (common_name_id)
41 WHERE (locus_symbol ILIKE '$locus_name%' OR locus_name ILIKE '%$locus_name%') AND (locus_id != $object_id) AND (common_name ILIKE '$organism%') AND locus.obsolete='f'";
42 my $sth = $dbh->prepare($locus_query);
43 $sth->execute();
44 my ($obj_id, $symbol, $name, $obj_organism) = $sth->fetchrow_array();
45 my $available_loci;
46 while($symbol) {
47 $available_loci .= "$obj_id*$obj_organism -- $symbol -- $name|";
48 ($obj_id, $symbol, $name, $obj_organism) = $sth->fetchrow_array();
50 print "$available_loci";