#!/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 |