6 A simple script that retrieves common names and their ids, and
7 writes out id of the selected organism into a file.
8 It is used to work with the Ajax form for the QTL webform.
14 Isaak Y Tecle iyt2@cornell.edu
25 use CXGN
::Scrap
::AjaxPage
;
26 use CXGN
::DB
::Connection
;
28 use CXGN
::Phenome
::Qtl
;
30 use CatalystX
::GlobalContext
qw( $c );
32 my $doc = CXGN::Scrap::AjaxPage->new();
33 $doc->send_http_header();
36 my ($common_name, $common_name_id, $type, $sp_person_id) = $doc->get_encoded_arguments("organism", "organism_id", "type", "sp_person_id");
38 my $dbh = CXGN::DB::Connection->new();
39 my ($login_person_id, $login_user_type)=CXGN::Login->new($dbh)->verify_session();
41 if ($login_user_type eq 'curator' || $login_user_type eq 'submitter' || $login_user_type eq 'sequencer') {
43 if ($type eq 'browse') {
44 &browse_organisms($dbh, $type, $common_name);
46 elsif ($type eq 'associate') {
47 &associate_organism($dbh, $type, $common_name_id, $login_person_id);
52 sub browse_organisms {
53 my ($dbh, $type, $common_name) = @_;
56 if ($type eq 'browse')
60 my $sth = $dbh->prepare ("SELECT common_name_id, common_name
61 FROM sgn.common_name WHERE common_name ILIKE '$common_name%'"
65 while (my ($common_name_id, $common_name) = $sth->fetchrow_array())
67 $organisms .= "$common_name_id*$common_name_id -- $common_name |";
74 sub associate_organism {
75 my ($dbh, $type, $common_name_id, $sp_person_id) = @_;
77 my $qtl = CXGN::Phenome::Qtl->new($sp_person_id);
78 my ($temp_qtl_dir, $temp_user_dir) = $qtl->create_user_qtl_dir($c);
80 my $f = file( $temp_user_dir, 'organism.txt' )->openw
81 or die "Can't create file: $! \n";
82 $f->print( "common_name_id\t$common_name_id" );