#!/usr/local/bin/perl ############################################################################### # Program : GetSELExperiments # Author : Terry Farrah # Description : Javascipt browser for SRM experiments # # SBEAMS is Copyright (C) 2000-2021 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 CGI::Carp qw(fatalsToBrowser croak); use Getopt::Long; use FindBin; use POSIX qw(ceil floor); use LWP::Simple; use lib "$FindBin::Bin/../../lib/perl"; use vars qw ($sbeams $sbeamsMOD $q $current_contact_id $current_username $PROG_NAME $USAGE %OPTIONS $QUIET $VERBOSE $DEBUG $DATABASE $TABLE_NAME $PROGRAM_FILE_NAME $CATEGORY $DB_TABLE_NAME @MENU_OPTIONS); use SBEAMS::Connection qw($q $log); use SBEAMS::Connection::Settings; use SBEAMS::Connection::Authenticator; use SBEAMS::Connection::Tables; use SBEAMS::Connection::TabMenu; use SBEAMS::PeptideAtlas; use SBEAMS::PeptideAtlas::Settings; use SBEAMS::PeptideAtlas::Tables; $sbeams = new SBEAMS::Connection; my $sbeamsMOD = new SBEAMS::PeptideAtlas; $sbeamsMOD->setSBEAMS($sbeams); $sbeams->setSBEAMS_SUBDIR($SBEAMS_SUBDIR); use SBEAMS::PeptideAtlas::PASSEL; use SBEAMS::Connection::PubMedFetcher; ############################################################################### # Set program name and usage banner for command line use ############################################################################### $PROG_NAME = $FindBin::Script; $USAGE = <Authenticate() and exit if it fails or continue if it works. ############################################################################### sub main { # This script is very simple. # Display PeptideAtlas header and footer. # In between, sandwich some static HTML. # Also create the static data file. exit unless ($current_username = $sbeams->Authenticate( permitted_work_groups_ref=>['PeptideAtlas_user','PeptideAtlas_admin', 'PeptideAtlas_readonly', 'PeptideAtlas_exec'], allow_anonymous_access=>1, )); #### Read in the default input parameters my %parameters; $parameters{uploaded_file_not_saved} = 1; my $n_params_found = $sbeams->parse_input_parameters( q=>$q,parameters_ref=>\%parameters); #$sbeams->printDebuggingInfo($q); #### Process generic "state" parameters before we start $sbeams->processStandardParameters(parameters_ref=>\%parameters); #### Decide what action to take based on information so far if ($parameters{action} eq "???") { # Some action } else { my $project_id = $sbeamsMOD->getProjectID( atlas_build_id => $parameters{atlas_build_id} ); $sbeamsMOD->display_page_header(project_id => $project_id); if(defined $parameters{SEL_experiment_id}){ showSELExperiment(ref_parameters=>\%parameters); }else{ handle_request(ref_parameters=>\%parameters); } $sbeamsMOD->display_page_footer(); } } # end main ############################################################################### # Handle Request ############################################################################### sub showSELExperiment{ my %args = @_; my $ref_parameters = $args{'ref_parameters'} || die "ref_parameters not passed"; my %parameters = %{$ref_parameters}; my $SEL_experiment_id = $parameters{SEL_experiment_id}; my $passel = new SBEAMS::PeptideAtlas::PASSEL; my $json = new JSON; # Collect a JSON hash containing data from all of the experiments. # Store also in string form to use for searching, sorting. my $json_filename_all = "$PHYSICAL_BASE_DIR/tmp/PASSEL_experiments_all.json"; $passel->srm_experiments_2_json_all() if (! -e $json_filename_all); open (JSONFILE, "$json_filename_all") || die "Can't open $json_filename_all for reading\n"; my $json_href = $json->decode(join(" ",)); close JSONFILE; my $tabMenu = $sbeamsMOD->getTabMenu( parameters_ref => \%parameters, program_name => $PROG_NAME, ); my %labels = ( experiment_title => 'Experiment Title', comment => 'Experiment Description', description => 'Sample Description', publication_name => 'Publication', abstract => 'Abstract', sample_date => 'Sample Date', contributors => 'Contributors', taxonomy => 'Organism', instrumentation => 'Instrument', spikein => 'Spikein', ); if ($sbeams->output_mode() eq 'html'){ print $tabMenu->asHTML() ; print "

\n"; #print "Metadata:

\n"; foreach my $sample (@{$json_href->{"MS_QueryResponse"}{samples}}){ next if($sample->{SEL_experiment_id} != $SEL_experiment_id); my $datasetIdentifier = $sample->{datasetIdentifier}; print "

$datasetIdentifier
\n"; my $link = "http://www.PeptideAtlas.org/PASS/$datasetIdentifier"; #$HTML_BASE_DIR ."/PASS/$datasetIdentifier"; print qq~ Download raw data and supporting files

~; foreach my $key (qw(experiment_title comment description publication_name abstract taxonomy instrumentation spikein counts contributors sample_date)){ if($key !~ /(publication|counts)/){ if($sample->{$key} ne ''){ print "$labels{$key}: $sample->{$key}
\n"; } }elsif($key =~ /count/){ print qq~ Experiment Summary:
  • Transition Group Measured: $sample->{counts}{"transition_groups"} [Explore Transition Groups]
  • Number of Ms Runs: $sample->{counts}{"runs"}
  • Number of Proteins: $sample->{counts}{"prots"}
  • Distinct Peptide Sequences: $sample->{counts}{"peps"}
~; }elsif($key =~ /publication/){ if(defined $sample->{publication}{ids}){ my @ids = @{$sample->{publication}{ids}}; print "Publication:"; foreach my $id (@ids){ #### Get the XML data from NCBI my $url = "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?". "db=pubmed&id=$id&retmode=text&rettype=abstract"; my $content = get $url or die "Couldn't get $url"; my $ref = ''; if($content !~ /Cannot process ID/){ my @lines = split("\n", $content); shift @lines; $ref = shift @lines; $ref =~ s/^\d+\.\s+//; shift @lines; $ref = $lines[0] . " ". $ref; print qq~ $ref $id
~; }else{ if(defined $sample->{publication_name}){ print " $sample->{publication_name}
"; } } } }else{ if(defined $sample->{publication_name}){ print "Publication: $sample->{publication_name}
"; } } } } } print "
\n"; print "
\n"; } } sub handle_request { my %args = @_; #### Process the arguments list my $ref_parameters = $args{'ref_parameters'} || die "ref_parameters not passed"; my %parameters = %{$ref_parameters}; #### Show current user context information #$sbeams->printUserContext(); #### Get the HTML to display the tabs my $tabMenu = $sbeamsMOD->getTabMenu( parameters_ref => \%parameters, program_name => $PROG_NAME, ); print $tabMenu->asHTML() if ($sbeams->output_mode() eq 'html'); my $html; # Javascript stuff $html = qq~ Repository ~; print $html; # Text at the top of the window $html = qq~

SRM Experiments Available in PASSEL


Please wait a few seconds for table to display.
Then, click individual experiments for detailed info and links to raw data.
Click TxGrps link for PASSEL transition group tables.


~; print $html; # Filter experiments using Search, then click individual experiments # for detailed info and links to transition lists and experimental results. # Search boxes and buttons $html = qq~ ~; print $html; # Display of data table $html = qq~


~; print $html; }