#!/usr/local/bin/perl ############################################################################### # Program : uploadTransitions # $Id: $ # # SBEAMS is Copyright (C) 2000-2008 Institute for Systems Biology # This program is governed by the terms of the GNU General Public License (GPL) # version 2 as published by the Free Software Foundation. It is provided # WITHOUT ANY WARRANTY. See the full description of GPL terms in the # LICENSE file distributed with this software. # ############################################################################### use strict; use lib qw (../../lib/perl); use File::Basename; use SBEAMS::Connection qw($q $log); use SBEAMS::Connection::Settings; use SBEAMS::PeptideAtlas; use SBEAMS::PeptideAtlas::Settings; use SBEAMS::PeptideAtlas::TraMLParser; ## Globals ## my $sbeams = new SBEAMS::Connection; my $pepatlas = new SBEAMS::PeptideAtlas; $pepatlas->setSBEAMS($sbeams); my $program = basename( $0 ); main(); sub main { my $current_username = $sbeams->Authenticate( allow_anonymous_access => 1) || die "Authentication failed"; my $params = process_params(); $params->{apply_action} ||= 'show form'; for my $param ( keys( %$params ) ) { $log->info("Params say: $param => $params->{$param}"); } if ( $params->{apply_action} eq 'Upload file' ) { upload_transitions( $params ); print $q->redirect( $q->self_url() ); } elsif ( $params->{apply_action} eq 'show form' ) { $pepatlas->printPageHeader( force_header => 1 ); print_upload_form( $params ); } $pepatlas->printPageFooter(); } # end main sub upload_transitions { my $params = shift; # read file $pepatlas->validate_transition_data( %$params ); # Insert transitions my $ids = $pepatlas->insert_transition_data( set_name => $params->{transition_set} ); # my $ids = [1,2,3,4]; # print table of transitions if ( $ids ) { $sbeams->set_page_message( msg => 'Saved ' . scalar( @$ids ) . ' transitions', type => 'Info' ); # print_results( $ids ); } else { $sbeams->set_page_message( msg => 'No transitions saved', type => 'Error' ); } # exit if ( $params->{output_mode} eq 'tsv' ) { $pepatlas->printPageHeader( force_header => 1 ); print "Success\t".scalar(@$ids)." transitions uploaded\n"; exit; } else { return; } exit; } sub process_params { my $params = {}; # Process parameters $sbeams->parse_input_parameters( parameters_ref => $params, q => $q ); # Process "state" parameters $sbeams->processStandardParameters( parameters_ref => $params ); # for my $param ( keys( %$params ) ) { $log->debug( "Params say: $param => $params->{$param}" ); } $q->delete( 'apply_action' ); my $error_text; $params->{transition_set} ||= 'Uploaded_set_' . time(); $params->{type} ||= 'tabtext'; for my $required ( qw(transition_file transition_set ) ) { if ( !defined $required ) { my $sep = ( $error_text ) ? ', ' : ''; $error_text ||= 'Missing required parameters: '; $error_text .= $sep . $required; } } show_error( $error_text ) if $error_text; my $uploaded_file = $q->param( 'transition_file' ); my @transition_file; while ( my $line = <$uploaded_file> ) { push @transition_file, $line; } $log->info( "file has $#transition_file elements" ); $params->{transition_file_data} = \@transition_file; # for my $p ( keys (%$params ) ) { $log->debug( "$p => $params->{$p}" ); } return $params; } sub show_error { print STDERR "Foshizzle\n"; exit; $sbeams->set_page_message( msg => 'This functionality is not yet complete', type => 'Error' ); print $q->redirect( $q->self_url() ); } sub print_upload_form { my $params = shift; $sbeams->printUserContext(); my $pad = ' ' x 5; my $excel = "(template)"; my $tsv = "(template)"; my $traml = "(information)"; my @buttons = $sbeams->getFormButtons( name => 'apply_action', value => 'Upload file', types => [ qw(submit reset) ] ); my $buttons = join $pad, @buttons; my $info_text = get_info_text(); # Download template:$template_links print <<" END";

Upload The Transitions

Transition set name:
Transitions file:
Type: Excel $excel | TSV $tsv | TraML $traml
$buttons

$info_text END #$buttons } # end showMainPage sub get_info_text { my $content =<<" END";
   
This form allows you to upload a file of 'validated' transitions, rather than entering them manually one at a time. You can download a template file in Excel, TSV, or TraML format from the links above, and enter your data in the columns provided, as described in the table below.
modified_peptide_sequenceSequence of the peptide including any modifications in standard notation, e.g. THC[160]AAHR
peptide_chargeCharge on the precursor ion
q1_mzparent mass to charge ratio: q1
q3_mzproduct ion mass to charge ratio: q3
q3_ion_labelLabel for the product ion (e.g. y1-7, b2-6, etc.)
transition_suitability_level_idUser-specified quality metric. Permissible values are Best, OK, and No, all others will be stored as 'OK'
publication_idArticle title of publication related to this entry, if any
annotator_nameName of person uploading transitions
collision_energyCollision energy setting used during validation run, or best CE setting if multiple runs were performed
retention_timeRetention time (in minutes) of parent peptide
instrumentInstrument used for analysis of transition pair
commentAny additional comments or information you wish to provide
END my @toggle = $sbeams->make_toggle_section( textlink => 1, hidetext => "Hide Explanation", showtext => "Show Explanation", box_style => 1, content => $content ); return "$toggle[1]

$toggle[0]"; }