#!/usr/local/bin/perl ############################################################################### # $Id: Glyco_prediction.cgi 4670 2006-04-22 01:54:05Z dcampbel $ # # SBEAMS is Copyright (C) 2000-2005 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. ############################################################################### ############################################################################### # Get the script set up with everything it will need ############################################################################### use strict; use vars qw ($q $sbeams $sbeamsMOD $PROG_NAME $current_contact_id $current_username $glyco_query_o); use lib qw (../../lib/perl); use CGI::Carp qw(fatalsToBrowser croak); use Data::Dumper; use SBEAMS::Connection qw($q $log); use SBEAMS::Connection::Settings; use SBEAMS::Connection::Tables; use SBEAMS::Connection::DataTable; use SBEAMS::Glycopeptide; use SBEAMS::Glycopeptide::Settings; use SBEAMS::Glycopeptide::Tables; use SBEAMS::Glycopeptide::Get_glyco_seqs; use SBEAMS::Glycopeptide::Glyco_query; $sbeams = new SBEAMS::Connection; $sbeamsMOD = new SBEAMS::Glycopeptide; $sbeamsMOD->setSBEAMS($sbeams); $glyco_query_o = new SBEAMS::Glycopeptide::Glyco_query; $glyco_query_o->setSBEAMS($sbeams); ############################################################################### # Global Variables ############################################################################### $PROG_NAME = 'main.cgi'; $sbeams->setSBEAMS_SUBDIR($SBEAMS_SUBDIR); my $base_url = "$CGI_BASE_DIR/$SBEAMS_SUBDIR/massSearch"; { # Main # Authenticate or exit exit unless ($current_username = $sbeams->Authenticate( permitted_work_groups_ref=>['Glycopeptide_user','Glycopeptide_admin', 'Glycopeptide_readonly'], # connect_read_only=>1, allow_anonymous_access=>1, )); #### Read in the default input parameters my %params; $sbeams->parse_input_parameters( q=>$q, parameters_ref=>\%params ); $sbeams->processStandardParameters(parameters_ref=>\%params); ## get project_id to send to HTMLPrinter display my $project_id = $sbeams->getCurrent_project_id(); my $page = $sbeams->getGifSpacer( 800 ) . "
\n"; #### Decide what action to take based on information so far if( $params{action} eq 'search') { $page .= print_form( \%params ); $page .= run_search( \%params ); } else { $page .= print_form( \%params ); } # Display page $sbeamsMOD->display_page_header(project_id => $project_id); # $sbeams->printStyleSheet(); print "$page"; $sbeamsMOD->display_page_footer(); } # end main sub run_search { my $params = shift; my $content; for my $arg ( qw( mass_list mass_window) ) { unless ( $params->{$arg} ) { $content .= "Missing required parameter: $arg
\n"; return $content; } } # for my $p ( keys( %$params ) ) { $content .= "$p => " . $params->{$p} . "
\n"; } my $mass_list = $params->{mass_list}; $mass_list =~ s/\s+/ /gm; my @masses = split( " ", $mass_list ); my $peptides = $sbeamsMOD->runMassSearch( masses => \@masses, %{$params} ); my $peptide_table = SBEAMS::Connection::DataTable->new( BORDER => 0 ); my $type = ( $params->{search} eq 'iden' ) ? 'Identified' : 'Predicted'; $peptide_table->addRow( ['Search Mass', 'IPI', "$type sequence", 'Peptide Mass', 'Mass Delta', '# ox Met', 'Protein Name' ] ); $peptide_table->setRowAttr( ROWS => [1], BGCOLOR => '#C0D0C0' ); my $current_group; my $grp_row = 2; my $bgcolor = '#FFFFFF'; for my $peptide ( @$peptides ) { my ( $grp, $smass, $ipi, $seq, $dbmass, $prot, $delta, $ox_met ) = @$peptide; $current_group = $grp unless $current_group; $dbmass = sprintf( "%0.3f", $dbmass ); if ( $dbmass =~ /0.000/ ) { $dbmass = 'na'; } $delta = sprintf( "%0.3f", $delta ); if ( $delta =~ /0.000/ ) { $delta = 'na'; } $prot = $sbeams->truncateStringWithMouseover( string => $prot, len => 50 ); $ipi = "$ipi"; $peptide_table->addRow( [ $smass, $ipi, $seq, $dbmass, $delta, $ox_met, $prot] ); unless ( $grp == $current_group ) { my $current_row = $peptide_table->getRowNum(); # $log->info( "group row is $grp_row, current row is $current_row, bgcolor is $bgcolor" ); $peptide_table->setRowAttr( ROWS => [$grp_row..$current_row - 1], BGCOLOR => $bgcolor ); $grp_row = $current_row; $bgcolor = ( $bgcolor eq '#E0E0E0' ) ? '#FFFFFF' : '#E0E0E0'; $current_group = $grp; } my $current_row = $peptide_table->getRowNum(); $peptide_table->setRowAttr( ROWS => [$grp_row..$current_row], BGCOLOR => $bgcolor ); } $content .= $peptide_table->asHTML(); return $content; } sub print_form { my $params = shift; my $content = <<" END";
Run Mass Search
Enter desired constraints to run a mass-based search versus the identified or theoretical peptides in the database. Note that your prophet cutoff will impact the number of results returned
END # Table to hold form elements my $f_table = SBEAMS::Connection::DataTable->new( BORDER => 1 ); # Hashes to hold form labels/fields my $input_labels = get_input_labels($params); my $input_fields = get_input_fields($params); # Loop through and add items to the form table for my $key ( qw(mass_list mass_window ox_met alk_cys mass_type search charge ) ) { $f_table->addRow(["$input_labels->{$key}", $input_fields->{$key}]); } my @buttons = $sbeams->getFormButtons( types => [qw(submit reset)] ); $f_table->addRow( [join(" ", @buttons)] ); $f_table->setColAttr( COLS => [1], ROWS => [8], COLSPAN => 2 ); # $f_table->setColAttr( COLS => [1], ROWS => [1..6], ALIGN => 'RIGHT' ); $f_table->setColAttr( COLS => [1], ROWS => [8], ALIGN => 'CENTER' ); $f_table->setColAttr( COLS => [2], ROWS => [1..7], ALIGN => 'LEFT' ); $content .=<<" END";
$f_table
END return $content; } sub get_input_labels { my $params = shift; my %in = ( mass_list => 'Mass(es) to search, 1 per line:', mass_window => 'Mass search range:', ox_met => 'Oxidized Methionine (+ 15.9949):', alk_cys => 'Alkylated Cys (+ 57.0215):', mass_type => 'Type of mass values:', search => 'Search subject:', charge => 'Peptide charge state:', ); return \%in; } sub get_input_fields { my $params = shift; my $mass_list = $params->{mass_list} || ''; $mass_list = ""; my $mass_window = $params->{mass_window} || ''; $mass_window = ""; my $mw_amu = ( $params->{mw_units} && $params->{mw_units} eq 'amu' ) ? 'CHECKED' : ''; my $mw_ppm = 'CHECKED' unless $mw_amu; my $mw_radio =<<" END"; PPM AMU END my $ch_neu = ( $params->{charge} && $params->{charge} eq 'neu' ) ? 'CHECKED' : ''; my $ch_one = 'CHECKED' unless $ch_neu; my $ch_radio =<<" END"; Neutral H+ END my $none = ( !$params->{ox_met} || $params->{ox_met} eq 'none' ) ? 'CHECKED' : ''; my $one = ( $params->{ox_met} eq 'one' ) ? 'CHECKED' : ''; my $two = ( $none || $one ) ? '' : 'CHECKED'; my $ox_met_radio =<<" END"; None One Two END my $yes = ( !$params->{alk_cys} || $params->{alk_cys} eq 'yes' ) ? 'CHECKED' : ''; my $no = ( !$yes ) ? 'CHECKED' : ''; my $alk_cys_radio =<<" END"; Yes No END my $mono = ( !$params->{mass_type} || $params->{mass_type} eq 'mono' ) ? 'CHECKED' : ''; my $avg = ( !$mono ) ? 'CHECKED' : ''; my $mass_type_radio =<<" END"; Monoisotopic END #Avg my $iden = ( !$params->{search} || $params->{search} eq 'iden' ) ? 'CHECKED' : ''; my $pred = ( !$iden ) ? 'CHECKED' : ''; my $search_radio =<<" END"; Identifed Predicted END my %in = ( mass_list => $mass_list, mass_window => $mass_window . " " . $mw_radio, ox_met => $ox_met_radio, alk_cys => $alk_cys_radio, mass_type => $mass_type_radio, search => $search_radio, charge => $ch_radio ); return \%in; }