Merge branch 'master' into topic/simple_image_upload
[sgn.git] / cgi-bin / solpeople / top-level.pl
blob9fcb4f3bcc35e9120a1427407fae5eb3d16e3a04
1 #DEPRECATED
2 #####################
3 #This page now points to the url /solpeople/profile/<sp_person_id> in the controller SGN::Controller::People
4 #####################
6 use strict;
8 use CXGN::DB::Connection;
9 use CXGN::Page;
10 use CXGN::Login;
11 use CXGN::People;
12 use CXGN::People::Person;
13 use CXGN::BlastWatch;
14 use CXGN::Phenome::Locus;
15 use CXGN::Cview::MapFactory;
16 use CXGN::Page::FormattingHelpers qw/info_section_html page_title_html
17 info_table_html simple_selectbox_html
18 html_optional_show columnar_table_html/;
20 our $c;
21 use CatalystX::GlobalContext qw($c);
24 my $page = CXGN::Page->new( "solpeople main menu", "john" );
25 my $dbh = CXGN::DB::Connection->new();
26 my $site_name = $c->config->{project_name};
28 my $sp_person_id = CXGN::Login->new($dbh)->verify_session();
30 my $sp = CXGN::People::Person->new( $dbh, $sp_person_id );
31 unless ($sp_person_id) {
32 $page->error_page( "Login ID not found.",
33 "", "", "Login ID not found: $sp_person_id" );
35 unless ( $sp->get_username() ) {
36 $page->error_page( "Username not found.",
37 "", "", "Username not found for sp_person_id '$sp_person_id'" );
39 my $username = $sp->get_first_name() . " " . $sp->get_last_name();
41 #my $research_update=$sp->get_research_update();
42 #my $contact_update=$sp->get_contact_update();
44 $page->add_style( text => <<EOS);
45 div#queryTable
47 margin: 0px 0px 0px 0px;
48 display: none;
50 EOS
51 $page->header();
53 print <<END_HTML;
55 <script type = "text/javascript">
56 <!--
57 function toggleLayer(whichLayer) {
58 if (document.getElementById) {
59 var style2 = document.getElementById(whichLayer).style;
60 style2.display = style2.display? "":"block";
62 else if (document.all) {
63 var style2 = document.all[whichLayer].style;
64 style2.display = style2.display? "":"block";
66 else if (document.layers) {
67 var style2 = document.layers[whichLayer].style;
68 style2.display = style2.display? "":"block";
71 function showSequence(sequence) {
72 document.getElementById("Heading").innerHTML="<strong>Full sequence: </strong>";
73 document.getElementById("fullSequence").innerHTML=sequence;
75 function hideSequence() {
76 document.getElementById("Heading").innerHTML="";
77 document.getElementById("fullSequence").innerHTML="";
79 //-->
80 </script>
81 END_HTML
83 print page_title_html("My $site_name");
84 print qq|<div align="center">Welcome <b>$username</b></div>\n|;
85 print
86 qq|<div align="right" style="margin-bottom: 0.5em">Not $username? <a href="login.pl?logout=yes">[log out]</a></div>\n|;
87 print info_section_html( title => 'General Tools', contents => <<EOHTML);
88 <a href="personal-info.pl?action=edit&sp_person_id=$sp_person_id">View or update personal (contact and research) information</a><br />
89 <a href="change-account.pl?action=edit&sp_person_id=$sp_person_id">Update account information</a><br />
90 <a href="/forum/topics.pl">Post to SGN forum</a><br />
91 EOHTML
93 # my $queries =
94 # qq|<div id="queryTable">|
95 # . CXGN::BlastWatch::get_queries( $dbh, $sp_person_id )
96 # . '</div>';
97 # print info_section_html( title => 'BLAST Watch', contents => <<EOHTML);
98 # <div style="margin-bottom: 1em">BLAST Watch is an SGN service that lets users submit recurring BLAST queries to SGN. Our software repeats your BLAST search every week and notifies you by email if the BLAST results change.</div>
99 # <a href="/tools/blast/watch/index.pl">Submit a query to SGN BLAST Watch</a><br />
100 # <a href="javascript:toggleLayer('queryTable');" title="View your BLAST Watch queries">View your BLAST Watch queries</a>
101 # $queries
102 # EOHTML
104 #return 1 if the first term is eq to one of the other terms given
105 sub in(@) {
106 my $t = shift;
107 ( grep { $t eq $_ } @_ ) ? 1 : 0;
110 #now assemble the sequencing tools stuff
111 if ( in( $sp->get_user_type, qw/curator sequencer/ ) ) {
113 #make a form for uploading TPF and AGP files
114 my $tpf_agp_upload = do {
115 if ( $sp->get_user_type eq 'curator' ) {
116 tpf_agp_upload_forms(<<EOHTML);
117 <!-- the string 'TYPE' will be replaced in each instance by tpf_agp_upload_forms() -->
118 <label for="chrnuminputTYPE">For Chromosome #: </label><input id="chrnuminputTYPE" name="chr" type="text" size="2" maxlength="2" />
119 EOHTML
121 elsif ( $sp->get_user_type eq 'sequencer'
122 and my @projects =
123 grep { $_ >= 1 && $_ <= 12 }
124 $sp->get_projects_associated_with_person )
126 my $chrinput =
127 @projects > 1
128 ? simple_selectbox_html(
129 name => 'chr',
130 choices => \@projects,
131 label => 'For Chromosome #:',
133 : qq|For Chromosome #: <b>$projects[0]</b> <input type="hidden" value="$projects[0]" name="chr" />|;
134 tpf_agp_upload_forms($chrinput);
138 print info_section_html( title => 'Sequencer Tools', contents => <<EOHTML);
139 <a href="attribute_bacs.pl">Attribute a BAC to your chromosome sequencing project</a><br />
140 <a href="/maps/physical/clone_il_view.pl">View/update BAC IL mapping information (list view)</a><br />
141 <div style="vertical-align: middle; font-weight: bold"><a href="/maps/physical/clone_reg.pl">View/update all BAC registry info (list view) <img style="border: none" src="/documents/img/new.gif" /></a></div>
142 <a href="/sequencing/tpf.pl">View TPF Files</a><br />
143 <a href="/sequencing/agp.pl">View AGP Files</a><br />
144 $tpf_agp_upload
145 EOHTML
148 # if( in( $sp->get_user_type(), qw/submitter curator/ ) )
150 # print info_section_html(title => 'EST Submission Pages', contents => <<EOHTML);
151 # <a href="/data-submit/top-level.pl">Data submission start page</a>
152 # EOHTML
155 if ( in( $sp->get_user_type(), qw/submitter curator/ ) ) {
156 print info_section_html( title => 'QTL data submission',
157 contents => <<EOHTML);
158 <a href="/phenome/qtl_form.pl">Upload and analyse your QTL data</a>
159 EOHTML
162 my @pops = CXGN::Phenome::Population->my_populations($sp_person_id);
164 if (@pops) {
165 my $pop_list = my_populations(@pops);
166 print info_section_html( title => 'Populations', contents => $pop_list );
169 #### solGS submitted jobs list ##########
170 my $solgs_jobs = SGN::Controller::solGS::AnalysisQueue->solgs_analysis_status_log($c);
172 my $solgs_jobs_table;
174 if(@$solgs_jobs) {
175 $solgs_jobs_table = columnar_table_html(
176 headings => [ 'Analysis name', 'Submitted on', 'Status', 'Result page'],
177 data => $solgs_jobs,
178 __alt_freq => 2,
179 __align => 'llll',
181 } else {
182 $solgs_jobs_table = 'You have no submitted jobs.'
185 print info_section_html(
186 title => 'solGS submitted analysis jobs',
187 contents => $solgs_jobs_table
190 #######
193 if ( $sp->get_user_type() eq 'curator' ) {
194 print info_section_html( title => 'Curator Tools', contents => <<EOHTML);
195 <a href="/solpeople/admin/crash_test.pl">Test website error handling</a><br />
196 <a href="/solpeople/admin/stats.pl">View user stats</a><br />
197 <a href="/solpeople/admin/quick_create_account.pl">Create new user account</a><br />
198 <a href="/solpeople/admin/create_organization.pl">Create new organization</a>
199 EOHTML
202 if ( $sp->get_user_type() =~ /curator/i ) {
203 my $publications =
204 qq| <a href= "/search/pub_search.pl">Search the SGN publication database </a><br />|;
205 $publications .=
206 qq| <a href= "/search/pub_search.pl?w9b3_assigned_to=$sp_person_id">See your assigned publications</a><br />|;
207 $publications .=
208 qq| <a href= "/search/pub_search.pl?w9b3_status=pending">See publications pending curation</a><br />|;
209 $publications .=
210 qq| <a href= "/chado/fetch_pubmed.pl">Load new publications from PubMed</a><br />|;
212 print info_section_html(
213 title => 'Literature mining',
214 contents => $publications
218 if ( $sp->get_user_type() =~ /submitter|curator|sequencer/i ) {
220 my @loci =
221 CXGN::Phenome::Locus::get_locus_ids_by_editor( $dbh, $sp_person_id );
222 my $top = 50;
223 my $more = 0;
224 my $max = @loci;
225 if ( @loci > 24 ) {
226 $more = @loci - 24;
227 $max = 24;
230 my $locus_editor_info = qq { None.<br /> };
231 if ( @loci > 0 ) {
232 $locus_editor_info = "";
235 for ( my $i = 0 ; $i < ($max) ; $i++ ) {
236 my $locus = CXGN::Phenome::Locus->new( $dbh, $loci[$i] );
237 my $symbol = $locus->get_locus_symbol();
238 my $locus_id = $locus->get_locus_id();
240 $locus_editor_info .=
241 qq { <a href="/phenome/locus_display.pl?locus_id=$locus_id&amp;action=view">$symbol</a> };
243 if ($more) {
244 $locus_editor_info .=
245 qq|<br><b>and <a href="/search/locus/>$more more</a></b><br />|;
248 print info_section_html(
249 title => 'Loci with Editor Privileges',
250 contents => $locus_editor_info
253 my @annotated_loci =
254 CXGN::Phenome::Locus::get_locus_ids_by_annotator( $dbh, $sp_person_id );
256 my $more = 0;
257 my $max = @annotated_loci;
258 if ( @annotated_loci > 24 ) {
259 $more = @annotated_loci - 24;
260 $max = 24;
263 my ( $locus_annotations, $more_annotations );
265 for ( my $i = 0 ; $i < $top ; $i++ ) {
266 my $locus = CXGN::Phenome::Locus->new( $dbh, $annotated_loci[$i] );
267 my $symbol = $locus->get_locus_symbol();
268 my $locus_id = $locus->get_locus_id();
270 if ( $i < $max ) {
271 $locus_annotations .=
272 qq | <a href="/locus/$locus_id/view">$symbol</a> |;
274 else {
275 $more_annotations .=
276 qq { <a href="/locus/$locus_id/view">$symbol</a> };
280 if ($more) {
281 $locus_annotations .= " and $more more, not shown.<br />";
283 $locus_annotations .=
284 html_optional_show( 'locus_annotations', 'Show more',
285 qq|<div class="minorbox">$more_annotations</div> |,
289 $locus_annotations .=
290 qq| <a href="../phenome/recent_annotated_loci.pl">[View annotated loci by date]</a> |;
291 print info_section_html(
292 title => 'Annotated Loci',
293 contents => $locus_annotations
296 my $map_factory = CXGN::Cview::MapFactory->new($dbh);
297 my @user_maps = $map_factory->get_user_maps();
298 my $html = "";
300 if ( @user_maps > 0 ) {
301 $html .=
302 "<table alt=\"\" ><tr><td><i>Name</i></td><td></td><td></td><td><i>status</i></td></tr>";
303 foreach my $um (@user_maps) {
304 my $public = " (not public) ";
305 if ( $um->get_map()->get_is_public() ) { $public = "(public)"; }
306 $html .=
307 "<tr><td><b>"
308 . $um->get_short_name()
309 . "</b></td><td> <a href=\"/cview/umap.pl?action=view&amp;user_map_id="
310 . $um->get_id()
311 . "\" >[view]</a></td><td><a href=\"/cview/umap.pl?action=edit&amp;user_map_id="
312 . $um->get_id()
313 . "\">[configure]</a></td><td>$public</td></tr>";
316 $html .= "</table>";
319 # BROKEN!
320 # print info_section_html(title => 'User Maps', contents=> <<EOHTML);
321 # <a href="/cview/upload_usermap.pl">Upload new user map</a><br />
322 # <br />
323 # $html
324 #EOHTML
328 my $user_type = $sp->get_user_type();
329 my $user_info = {
330 user => qq{ Your current user status is <b>$user_type</b>. Please contact <a href="mailto:sgn-feedback\@sgn.cornell.edu">SGN</a> to upgrade to a <b>submitter</b> account with more privileges. Submitters can upload user maps, EST data, and become locus editors. },
332 submitter => qq{ Your current user status is <b>$user_type</b>. You have the maximum user privileges on SGN. Please contact <a href="mailto:sgn-feedback\@sgn.cornell.edu">SGN</a> if you would like to change your user status.},
334 curator => qq{ Your current user status is <b>$user_type</b>. },
336 sequencer => qq{ Your current user status is <b>$user_type</b>. You have maximum user privileges on SGN. },
338 genefamily_editor => qq{ Your current user status is <b>$user_type</b>. },
341 print info_section_html( title => 'User Status',
342 contents => $user_info->{$user_type} );
344 $page->footer();
346 #returns a string containing a TPF and an AGP upload form,
347 #with the single argument interpolated in
348 sub tpf_agp_upload_forms {
349 my $chrinput = shift;
350 my ( $chrinput_agp, $chrinput_tpf ) = ( $chrinput, $chrinput );
351 $chrinput_agp =~ s/TYPE/_agp/g;
352 $chrinput_tpf =~ s/TYPE/_tpf/g;
353 return <<EOHTML;
354 <div style="margin-top: 1em">
355 <b>Upload Accessioned Golden Path (AGP) File</b><br />
356 <form action="/sequencing/agp.pl" method="post" enctype="multipart/form-data">
357 $chrinput_agp
358 <input type="hidden" name="filetype" value="agp" />
359 <label for="agpinput">File: </label>
360 <input id="agpinput" type="file" name="agp_file" value="Upload AGP file" /><input type="submit" value="Submit" />
361 </form>
362 </div>
363 <div style="margin-top: 1em">
364 <b>Upload Tiling Path Format (TPF) File</b><br />
365 <form action="/sequencing/tpf.pl" method="post" enctype="multipart/form-data">
366 $chrinput_tpf
367 <input type="hidden" name="filetype" value="tpf" />
368 <label for="tpfinput">File: </label>
369 <input id="tpfinput" type="file" name="tpf_file" value="Upload TPF file" /><input type="submit" value="Submit" />
370 </form>
371 </div>
372 EOHTML
375 sub my_populations {
376 my @pops = @_;
377 my $pops_list;
379 foreach my $pop (@pops) {
380 my $pop_name = $pop->get_name();
381 my $pop_id = $pop->get_population_id();
382 my $is_public = $pop->get_privacy_status();
383 if ($is_public) { $is_public = 'is publicly available'; }
384 if ( !$is_public ) { $is_public = 'is not publicly available yet'; }
385 $pops_list .=
386 qq |<a href="/qtl/population/$pop_id">$pop_name</a> <i>($is_public)</i><br/>|;
389 return $pops_list;