Merge pull request #5177 from solgenomics/topic/solgs/refactor-solgs-pipeline
[sgn.git] / cgi-bin / phenome / locus_browser.pl
blob5d60c793af675f35e58223219ef863ba9f8e2d1d
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 $sp_person_id = $c->user() ? $c->user->get_object()->get_sp_person_id() : undef;
29 my $schema= $c->dbic_schema('CXGN::Phenome::Schema', undef, $sp_person_id);
31 my ($login_person_id, $login_user_type)=CXGN::Login->new($dbh)->verify_session();
33 if ($login_user_type eq 'curator' || $login_user_type eq 'submitter' || $login_user_type eq 'sequencer') {
35 if ($type eq 'browse locus') {
36 if (!$organism) { ($locus_name, $organism) = split(/,\s*/, $locus_name); }
37 $locus_name =~ /(\w+)/;
38 $locus_name =$1;
39 if (($locus_name) && ($organism)) {
40 my $locus_query = "SELECT locus_id, locus_symbol, locus_name, common_name FROM phenome.locus
41 JOIN sgn.common_name USING (common_name_id)
42 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'";
43 my $sth = $dbh->prepare($locus_query);
44 $sth->execute();
45 my ($obj_id, $symbol, $name, $obj_organism) = $sth->fetchrow_array();
46 my $available_loci;
47 while($symbol) {
48 $available_loci .= "$obj_id*$obj_organism -- $symbol -- $name|";
49 ($obj_id, $symbol, $name, $obj_organism) = $sth->fetchrow_array();
51 print "$available_loci";