6 use CXGN
::Page
::FormattingHelpers qw
/ info_section_html page_title_html html_optional_show/;
7 use CXGN
::Chado
::Publication
;
12 use CXGN
::Tools
::Pubmed
;
13 use CXGN
::Tools
::Text qw
/ sanitize_string /;
14 use CXGN
::DB
::Connection
;
16 use base qw
/ CXGN::DB::ModifiableI /;
18 my $page=CXGN
::Page
->new("Fetch PubMed","Naama");
19 my $dbh = CXGN
::DB
::Connection
->new();
21 my $logged_in_person_id=CXGN
::Login
->new($dbh)->verify_session();
22 my $logged_in_user=CXGN
::People
::Person
->new($dbh, $logged_in_person_id);
23 my $logged_in_person_id=$logged_in_user->get_sp_person_id();
24 my $logged_in_username=$logged_in_user->get_first_name()." ".$logged_in_user->get_last_name();
25 my $logged_in_user_type=$logged_in_user->get_user_type();
27 #only curators can access this page
28 if($logged_in_user_type eq 'curator') {
30 my %args=$page->get_all_encoded_arguments();
31 my $ids = $args{"pubmed_ids"};
32 my $curator_id= $args{curator_id
};
33 my $action = $args{action
};
37 my @pubmeds = split (/\r\n/, $ids);
40 foreach(@fail) { $fail_str .= "<li>$_</li>\n"; }
43 <table width=80% align=center>
45 <p>Could not feth pubmed ids for the following reasons</p>
49 <p>Please use your browser\'s back button to try again.</p>
51 <tr><td><br /></td></tr>
56 print qq | <br/><b> Fetched the following publications from PubMed</b> | ;
59 foreach my $pubmed (@pubmeds) {
60 my $pub = CXGN::Chado::Publication->new($dbh);
61 $pub->set_accession($pubmed);
62 CXGN::Tools::Pubmed->new($pub); #call eutils and populates the publication object with all necessary fields
63 if ($pub->get_title()) {
65 my $pub_ref=$pub->print_pub_ref();
66 $pubmed_string .= $pubmed . "|";
68 <table width
=80% align
=center
>
69 <tr
><td
><p
><b
>$count.</b> $pub_ref (PMID:$pubmed)</p></td></tr
>
70 <tr
><td
><br
/></td
></tr
>
76 <form method="post" action="">
77 <input type="submit" name="action" value="Confirm store">
78 <input type = "hidden" name="curator_id" value=$curator_id>
79 <input type = "hidden" name="publications" value=$pubmed_string>
81 <a href="javascript:history.back(1)">Go back without storing the publications</a>
86 }elsif ($action eq 'Confirm store') {
88 my $ids = $args{publications};
89 my $curator_id = $args{curator_id} ;
91 my @pubmeds = split (/\|/, $ids);
93 print qq | <br/><b> stored the following publications from PubMed</b><br /> | ;
94 print qq| (assigned to curator $curator_id) | ;
96 foreach my $pubmed (@pubmeds) {
98 my $pub = CXGN::Chado::Publication->new($dbh);
100 $pub->set_accession($pubmed);
101 $pub->add_dbxref("PMID:$pubmed");
102 CXGN::Tools::Pubmed->new($pub); #call eutils and populates the publication object with all necessary fields
103 my $pub_ref=$pub->print_pub_ref();
104 my $e_id = $pub->get_eid;
106 $pub->add_dbxref("DOI:$e_id");
110 unless ($pub->is_curated() ) {
111 $pub->set_sp_person_id($logged_in_person_id);
112 $pub->set_curator_id($curator_id); #
113 $pub->set_status('pending');
114 $pub->store_pub_curator();
115 $pub->d("Assigned publication $pubmed to curator $curator_id");
118 <table width
=80% align
=center
>
119 <tr
><td
><p
><b
>$count.</b> $pub_ref (PMID:$pubmed)</p></td></tr
>
120 <tr
><td
><br
/></td
></tr
>
124 print qq | <a href
="/chado/fetch_pubmed.pl">Go back to fetch publications page
</a ><br />|;
125 print qq| <a href
= "/search/pub_search.pl?w9b3_status=pending">See publications pending curation
</a><br />|;
127 my @curators= CXGN
::People
::Person
::get_curators
($dbh);
128 my %names = map {$_ => CXGN
::People
::Person
->new($dbh, $_)->get_first_name() } @curators;
129 my $curator_options=qq|<option value
="">--Assign publications to curator
--</option
>|;
130 for my $curator_id (keys %names) {
131 my $curator= $names{$curator_id};
132 $curator_options .=qq|<option value
="$curator_id">$curator</option
>|;
137 <form method="post" action="fetch_pubmed.pl">
138 <table cellpadding="2" cellspacing="2">
139 <th colspan="2">Curators may use this form to bulk fetch publications from PubMed.<br /> </th>
140 <tr><td><textarea id="" cols="20" rows="10" name="pubmed_ids" value ="Insert a list of PubMed IDs"></textarea></td>
142 <select id="curator_id" name="curator_id"> $curator_options </select>
144 <tr><td><input type="submit" name="fetch_pubmeds" value="Store"><input type="reset" value="Reset form" /></td></tr>
153 else { $page->client_redirect('/solpeople/login.pl'); }
160 $self->print_confirm_form();
164 sub print_confirm_form {
166 my %args= $self->get_args();
168 my $query= sanitize_string($args{query});