#!/usr/local/bin/perl ############################################################################### # Program : GetPeptide # $Id$ # # Description : Prints summary of a given peptide given selection # atlas build, and peptide name or sequence. # # 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. # ############################################################################### ############################################################################### # Set up all needed modules and objects ############################################################################### use strict; use Getopt::Long; use FindBin; use POSIX qw(ceil); 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 CGI::Carp qw(fatalsToBrowser croak); use SBEAMS::Connection qw($q $log); use SBEAMS::Connection::Settings; use SBEAMS::Connection::Tables; use SBEAMS::Connection::TabMenu; use SBEAMS::PeptideAtlas; use SBEAMS::PeptideAtlas::Settings; use SBEAMS::PeptideAtlas::Tables; $sbeams = new SBEAMS::Connection; $sbeamsMOD = new SBEAMS::PeptideAtlas; $sbeamsMOD->setSBEAMS($sbeams); $sbeams->setSBEAMS_SUBDIR($SBEAMS_SUBDIR); #$q = new CGI; ############################################################################### # Set program name and usage banner for command like use ############################################################################### $PROG_NAME = $FindBin::Script; $USAGE = <Authenticate() and exit if it fails or continue if it works. ############################################################################### sub main { #### Do the SBEAMS authentication and exit if a username is not returned exit unless ($current_username = $sbeams->Authenticate( permitted_work_groups_ref=>['PeptideAtlas_user','PeptideAtlas_admin', 'PeptideAtlas_readonly'], #connect_read_only=>1, allow_anonymous_access=>1, )); #### Read in the default input parameters my %parameters; my $n_params_found = $sbeams->parse_input_parameters( q=>$q, parameters_ref=>\%parameters ); ## If no parameters are defined, set up some defaults to help with browsing ## until I get a help menu set-up if ( !exists $parameters{'searchWithinThis'} && !exists $parameters{'searchForThis'} && ( !exists $parameters{'atlas_build_name'} && !exists $parameters{'atlas_build_id'} ) ) { $parameters{'atlas_build_name'} = "Human_P0.9_Ens30_NCBI35"; $parameters{'searchWithinThis'} = "Peptide Name"; $parameters{'searchForThis'} = "PAp00000001"; } ## get project_id to send to HTMLPrinter display my $project_id = $sbeamsMOD->getProjectID( atlas_build_name => $parameters{'atlas_build_name'}, atlas_build_id => $parameters{'atlas_build_id'} ); #### Process generic "state" parameters before we start $sbeams->processStandardParameters(parameters_ref=>\%parameters); #$sbeams->printDebuggingInfo($q); #### Decide what action to take based on information so far if ($parameters{'action'} eq "???") { # Some action } else { $sbeamsMOD->display_page_header(project_id => $project_id); handle_request(ref_parameters=>\%parameters); $sbeamsMOD->display_page_footer(); } } # end main ############################################################################### # Handle Request ############################################################################### sub handle_request { my %args = @_; #### Process the arguments list my $ref_parameters = $args{'ref_parameters'} || die "ref_parameters not passed"; my %parameters = %{$ref_parameters}; # Handle search tool links... if ($parameters{searchWithinThis} eq 'Peptide+Name') { $log->info( "Adjusted Peptide+Name to Peptide Name."); $parameters{searchWithinThis} = 'Peptide Name'; } print "
\n"; my ($atlas_build_name, $atlas_build_id); ## if have atlas_build_name, but no id, get the id: if ( (exists $parameters{'atlas_build_name'}) && (!exists $parameters{'atlas_build_id'})) { $atlas_build_name = $parameters{'atlas_build_name'}; my $sql = qq~ SELECT atlas_build_id FROM $TBAT_ATLAS_BUILD WHERE atlas_build_name = '$atlas_build_name' AND record_status != 'D' ~; #$sbeams->display_sql(sql=>$sql); my ($tmp) = $sbeams->selectOneColumn($sql); unless ( $tmp ) { print qq~

Unable to use specified Atlas, please select a new one
Choose new Atlas Build ~; exit; } $parameters{'atlas_build_id'} = $tmp; $atlas_build_id = $tmp; } ## if have atlas_build_id, but no name, get the name if ( (exists $parameters{'atlas_build_id'}) && (!exists $parameters{'atlas_build_name'}) ) { $atlas_build_id = $parameters{'atlas_build_id'}; my $sql = qq~ SELECT atlas_build_name FROM $TBAT_ATLAS_BUILD WHERE atlas_build_id = '$atlas_build_id' AND record_status != 'D' ~; # $sbeams->display_sql(sql=>$sql); my ($tmp) = $sbeams->selectOneColumn($sql) or die "Cannot complete $sql ($!)"; $atlas_build_name = $tmp; $parameters{'atlas_build_name'} = $atlas_build_name; } ## if tab menu is requested, display tabs and append parameters to PROG_NAME # if ( $parameters{_tab} ) # { my $parameters_string = $sbeamsMOD->printTabMenu( parameters_ref => \%parameters, program_name => $PROG_NAME, ); #print "
parameters_string:$parameters_string
"; # } #### Define some generic variables my ($i,$element,$key,$value,$line,$result,$sql); #### Define some variables for a query and resultset my %resultset = (); my $resultset_ref = \%resultset; my (%url_cols,%hidden_cols,%max_widths,$show_sql); #### Read in the standard form values my $apply_action = $parameters{'action'} || $parameters{'apply_action'}; my $TABLE_NAME = $parameters{'QUERY_NAME'}; #### Set some specific settings for this program my $CATEGORY="Get Peptide"; my $PROGRAM_FILE_NAME = $PROG_NAME; my $base_url = "$CGI_BASE_DIR/$SBEAMS_SUBDIR/$PROGRAM_FILE_NAME"; my $help_url = "$CGI_BASE_DIR/help_popup.cgi"; ## Get and store list of atlases for use with form: my (@atlas_option_id_array, @atlas_option_name_array); my @accessible_project_ids = $sbeams->getAccessibleProjects(); my $project_string = join( ",", @accessible_project_ids ) || '0'; ## get accessible atlases: my $sql = qq~ SELECT atlas_build_id,atlas_build_name FROM $TBAT_ATLAS_BUILD WHERE project_id IN ( $project_string ) AND record_status!='D' ORDER BY atlas_build_name ~; my @rows = $sbeams->selectSeveralColumns($sql); unless ( @rows ) { print qq~

Unable to use specified Atlas, please select a new one
Choose new Atlas Build ~; exit; } foreach my $row (@rows) { my ($tmp_id, $tmp_name) = @{$row}; push(@atlas_option_id_array, $tmp_id); push(@atlas_option_name_array, $tmp_name); } #### Build search options for textbox: my @peptide_search_constraint = ( "peptide_name_constraint", "peptide_sequence_constraint" ); my @textbox_option_tags = ( "Peptide Name", "Peptide Sequence" ); #### Apply any parameter adjustment logic $parameters{display_options} = 'ShowSQL'; my ($selected_atlas_build_name, $selected_key, $selected_key_search); ## Display HTML FORM to select Atlas and Search constraints: my $atlas_build_name = $parameters{atlas_build_name}; my $searchKey = $parameters{searchWithinThis}; my $searchValue = $parameters{searchForThis}; unless ( $apply_action eq "QUERY" ) { ## if receive from link, don't assign null $apply_action = $parameters{"query"}; } ### if receive $parameters{atlas_build_id} from link, get atlas build name #if ( $parameters{atlas_build_id} ) { # for (my $i=0; $i<=$#atlas_option_id_array; $i++) { # if ( $parameters{atlas_build_id} eq $atlas_option_id_array[$i] ) { # $atlas_build_name = $atlas_option_name_array[$i] # } # } #} if ($sbeams->output_mode() eq 'html') { print "

"; print ""; print $q->start_form(-method=>"POST", -action=>"$base_url", ); print $q->popup_menu(-name=> "atlas_build_name", -values=> [@atlas_option_name_array], -default=>$atlas_build_name, ); print "  Search "; print $q->popup_menu(-name=> "searchWithinThis", -values=> [@textbox_option_tags], -default=>$searchKey, ); print " for: "; print $q->textfield( "searchForThis", $selected_key_search); print $q->submit(-name => "query", -value => 'QUERY', -label => 'QUERY'); print $q->endform; print ""; ## xxxx $help_url print "

"; } ## store form values in %parameters: for (my $i=0; $i<=$#atlas_option_name_array; $i++){ if ( $atlas_build_name eq $atlas_option_name_array[$i]) { $parameters{atlas_build_name} = $atlas_build_name; $parameters{atlas_build_id} = $atlas_option_id_array[$i]; } } for (my $i=0; $i<=$#textbox_option_tags;$i++){ if ( $searchKey eq $textbox_option_tags[$i]) { $parameters{$peptide_search_constraint[$i]} = $searchValue; } } ######################################################################### #### Process all the constraints #### If atlas_build_id was not selected, stop here unless ($parameters{atlas_build_name}) { $sbeams->reportException( state => 'ERROR', type => 'INSUFFICIENT CONSTRAINTS', message => 'You must select an Atlas Build', ); return; } #### Build ATLAS_BUILD constraint my $atlas_build_clause = $sbeams->parseConstraint2SQL( constraint_column=>"AB.atlas_build_id", constraint_type=>"int_list", constraint_name=>"Atlas Build", constraint_value=>$parameters{atlas_build_id} ); return if ($atlas_build_clause eq '-1'); #### Build PEPTIDE_NAME constraint my $peptide_name_clause = $sbeams->parseConstraint2SQL( constraint_column=>"P.peptide_accession", constraint_type=>"plain_text", constraint_name=>"Peptide Name", constraint_value=>$parameters{peptide_name_constraint} ); return if ($peptide_name_clause eq '-1'); #### Build PEPTIDE_SEQUENCE constraint my $peptide_sequence_clause = $sbeams->parseConstraint2SQL( constraint_column=>"P.peptide_sequence", constraint_type=>"plain_text", constraint_name=>"Peptide Sequence", constraint_value=>$parameters{peptide_sequence_constraint} ); return if ($peptide_sequence_clause eq '-1'); ## want to replace LIKE with = , as want a single peptide returned $peptide_name_clause =~ s/LIKE/=/gi; #print "peptide_name_clause: $peptide_name_clause
"; $peptide_sequence_clause =~ s/LIKE/=/gi; #print "peptide_sequence_clause: $peptide_sequence_clause
"; #### Define the SQL statement $sql = qq~ SELECT distinct P.peptide_accession, P.peptide_sequence, PI.best_probability, PI.n_observations, PI.n_genome_locations, PI.n_protein_mappings, PM.chromosome, PM.start_in_chromosome, PM.end_in_chromosome, PM.strand, BS.biosequence_name, P.molecular_weight, P.peptide_isoelectric_point, PI.n_samples, PI.n_protein_samples, PI.empirical_proteotypic_score, O.full_name, PI.original_protein_name, P.SSRCalc_relative_hydrophobicity FROM $TBAT_PEPTIDE_INSTANCE PI INNER JOIN $TBAT_PEPTIDE P ON ( PI.peptide_id = P.peptide_id ) INNER JOIN $TBAT_ATLAS_BUILD AB ON ( PI.atlas_build_id = AB.atlas_build_id ) LEFT JOIN $TBAT_BIOSEQUENCE_SET BSS ON ( AB.biosequence_set_id = BSS.biosequence_set_id ) LEFT JOIN $TB_ORGANISM O ON ( BSS.organism_id = O.organism_id ) LEFT JOIN $TBAT_PEPTIDE_MAPPING PM ON ( PI.peptide_instance_id = PM.peptide_instance_id ) LEFT JOIN $TBAT_BIOSEQUENCE BS ON ( PM.matched_biosequence_id = BS.biosequence_id ) LEFT JOIN $TB_DBXREF DBX ON ( BS.dbxref_id = DBX.dbxref_id ) WHERE 1 = 1 $atlas_build_clause $peptide_name_clause $peptide_sequence_clause ORDER BY PM.chromosome, BS.biosequence_name, PM.start_in_chromosome ~; unless ( $peptide_name_clause || $peptide_sequence_clause ) { $sbeams->display_sql(sql=>$sql); print qq~ No name or sequence constraint found, unable to proceed ~; return; } ######################################################################### #### If QUERY, display the data if ($apply_action =~ /QUERY/i ) { my @rows = $sbeams->selectSeveralColumns($sql) or print "Peptide not found. Please check selections and try again.
"; if (@rows) { my (@peptide_accession, @peptide_sequence); my (@best_probability, @n_observations, @n_genome_locations, @n_protein_mappings); my (@chrom, @start_chrom, @end_chrom, @strand); my (@biosequence_name); my ( @mw, @pi, @nsamp, @nprotsamp, @epscore, @organism, @original_name, @SSRCalc_relative_hydrophobicity ); my $i=0; ##index counter my %chrom_map; foreach my $row (@rows) { my ($pa, $seq, $prob, $n_obs, $n_g_loc, $n_prot_map, $chr, $s_chr, $e_chr, $str, $b_name, $mw, $pi, $ns, $nps, $eps, $org, $orig_name, $SSRCalc_relative_hydrophobicity ) = @{$row}; $peptide_accession[$i] = $pa; $peptide_sequence[$i] = $seq; $best_probability[$i] = $prob; $n_observations[$i] = $n_obs; $n_genome_locations[$i] = $n_g_loc; $n_protein_mappings[$i] = $n_prot_map; $chrom[$i] = $chr; $start_chrom[$i] = $s_chr; $end_chrom[$i] = $e_chr; $strand[$i] = $str; $biosequence_name[$i] = $b_name; $mw[$i] = sprintf( "%0.2f", $mw); $pi[$i] = sprintf( "%0.1f", $pi ); $nsamp[$i] = $ns; $nprotsamp[$i] = $nps; $epscore[$i] = $eps; $organism[$i] = $org; $original_name[$i] = $orig_name; $SSRCalc_relative_hydrophobicity[$i] = $SSRCalc_relative_hydrophobicity; #print "sql returns: $n_observations[$i] $sample_tag[$i]
"; my $key = join( ':::', $chr, $s_chr, $e_chr, $str, $seq ); # Could just push, thought this was clearer. if ( !$chrom_map{$key} ) { # First time through, point to arrayref $chrom_map{$key} = [$b_name]; } else { # Subsequent visits push an item onto the list push @{$chrom_map{$key}}, $b_name; } $i++; } ##xxxx PRINT RETURN to HTML HERE... my $summary_header = $sbeamsMOD->encodeSectionHeader( text => "$peptide_accession[0]", bold => 1 ); my $summ =<<" END"; $summary_header END my $bestp = ( $best_probability[0] == 1 ) ? 1 : sprintf( "%0.2f", $best_probability[0] ); $summ .= $sbeamsMOD->encodeSectionItem( key => 'Peptide Accession', value => $peptide_accession[0], key_width => '20%' ); $summ .= $sbeamsMOD->encodeSectionItem( key => 'Peptide Sequence', value => $peptide_sequence[0], ); $summ .= $sbeamsMOD->encodeSectionItem( key => 'Best Probability', value => $bestp, ); $summ .= $sbeamsMOD->encodeSectionItem( key => 'Times Observed:', value => $n_observations[0], ); $summ .= $sbeamsMOD->encodeSectionItem( key => 'Avg Molecular Weight', value => "$mw[0]", ) if $mw[0]; $summ .= $sbeamsMOD->encodeSectionItem( key => 'pI (approx)', value => "$pi[0]", ) if $pi[0]; if ( defined $SSRCalc_relative_hydrophobicity[0] ) { $summ .= $sbeamsMOD->encodeSectionItem( key => 'SSRCalc relative hydrophobicity', value => sprintf("%.2f",$SSRCalc_relative_hydrophobicity[0]), ); } if ( defined $epscore[0] ) { $summ .= $sbeamsMOD->encodeSectionItem( key => '# Samples', value => "$nsamp[0]", ); $summ .= $sbeamsMOD->encodeSectionItem( key => '# Protein Samples', value => "$nprotsamp[0]", ); $summ .= $sbeamsMOD->encodeSectionItem( key => 'Proteotypic score', value => sprintf( "%0.1f", $epscore[0] ), ); } print "

\n"; print "$summ\n"; my $mapHTML = qq~ ~; #
 
'; $n_genome_locations[0] = 0 if $n_genome_locations[0] < 0; $mapHTML .= $sbeamsMOD->encodeSectionHeader( text => "Genome Mappings: $n_genome_locations[0]", bold => 1 ); my $last_chrom = ""; my $last_protein = ""; my $last_seq_used_length = ""; my $n_indices=$#peptide_accession; my @rows; for my $key ( keys( %chrom_map ) ) { my @map = split( ':::', $key ); my $current_chrom = $map[0]; my $tmp_start = $map[1]; my $tmp_end = $map[2]; my $tmp_strand = $map[3]; my $peptide_sequence = $map[4]; # Defer... my $current_prot = $map[$i]; my $current_prot = $chrom_map{$key}->[0]; # For now just use the first # This indicates an unmapped peptide next unless $current_prot; ## $current_peptide_seq is the entire peptide sequence, even if split over 2 exons my $current_peptide_seq = $peptide_sequence; # if ($current_chrom ne $last_chrom) { # $mapHTML .= "\n"; # } my $tmp_protein = $current_prot; my $tmp_seq; #### get residues on given exons #### my $exon_bp_length = ceil( (abs($tmp_end - $tmp_start)/3.) ); ## if the strand is negative, count residues on exon starting from end if ($tmp_strand eq "-") { if ($tmp_protein eq $last_protein) { $tmp_seq = substr($current_peptide_seq, ((length $current_peptide_seq) - $last_seq_used_length - $exon_bp_length), ((length $current_peptide_seq) - $last_seq_used_length ) ); } else { $tmp_seq = substr($current_peptide_seq, ((length $current_peptide_seq) - $exon_bp_length), (length $current_peptide_seq) ); } } elsif ($tmp_strand eq "+") { if ($tmp_protein eq $last_protein) { $tmp_seq = substr($current_peptide_seq, $last_seq_used_length, (length $current_peptide_seq)); } else { $tmp_seq = substr($current_peptide_seq, 0, $exon_bp_length); } } $last_seq_used_length = length($tmp_seq); # Set up protein[s] display my $protein_display = makeProteinLink( name => $tmp_protein, build => $parameters{atlas_build_id}); my $extra = $#{$chrom_map{$key}}; if ( $extra ) { my $all = join ', ', @{$chrom_map{$key}}; my $all_links; for my $p ( @{$chrom_map{$key}} ) { $all_links .= makeProteinLink( build => $parameters{atlas_build_id}, name => $p, target => '_prot_info' ) . "
\n"; } $mapHTML .= $sbeams->getPopupDHTML(); my $session_key = $sbeams->getRandomString( num_chars => 20, char_set => ['A'..'Z', 'a'..'z', 0..9] ); $sbeams->setSessionAttribute( key => $session_key, value => $all_links ); my $url = "$CGI_BASE_DIR/help_popup.cgi?title=Alternate%20Mappings;session_key=$session_key;email_link=no"; my $more = qq~   [$extra more]~; $protein_display = "
$protein_display $more
"; } my $range = makeEntrezLink( start => $tmp_start, end => $tmp_end, strand => $tmp_strand, chrom => $current_chrom, org => $organism[0] ); push @rows, [ $current_chrom, $protein_display, $tmp_seq, $range, "$tmp_strand" ] if $tmp_seq; $last_chrom = $current_chrom; $last_protein = $current_prot; # if ($i < $n_indices && ($current_chrom ne $chrom[$i+1]) ) { # next unless @rows; # unshift @rows, ['Chrom', 'Protein', 'Residues on Exon', 'Exon Range', 'Strand']; # $mapHTML .= $sbeamsMOD->encodeSectionTable( header => 1, # rows => \@rows, # width => '600', # align => [qw(left left center center)] # ); # @rows = (); # } } if ( @rows ) { unshift @rows, ['Chr', 'Protein', 'Residues on Exon', 'Exon Range', 'Strand']; $mapHTML .= $sbeamsMOD->encodeSectionTable( header => 1, width => '600', align => [qw(center left left center center)], rows => \@rows ); } else { $mapHTML .= qq~ ~; } print "$mapHTML\n"; ## End mapping loop ## Begin modified peptide table my $modHTML .= $sbeamsMOD->encodeSectionHeader( text => "Modified Peptides", bold => 1 ); my $modSQL = qq~ SELECT distinct modified_peptide_sequence, MPI.peptide_charge, MPI.monoisotopic_parent_mz, MPI.best_probability, MPI.n_observations, MPI.n_sibling_peptides, MPI.sample_ids FROM $TBAT_PEPTIDE_INSTANCE PI INNER JOIN $TBAT_PEPTIDE P ON ( PI.peptide_id = P.peptide_id ) JOIN $TBAT_MODIFIED_PEPTIDE_INSTANCE MPI ON ( PI.peptide_instance_id = MPI.peptide_instance_id ) INNER JOIN $TBAT_ATLAS_BUILD AB ON ( PI.atlas_build_id = AB.atlas_build_id ) LEFT JOIN $TBAT_BIOSEQUENCE_SET BSS ON ( AB.biosequence_set_id = BSS.biosequence_set_id ) LEFT JOIN $TB_ORGANISM O ON ( BSS.organism_id = O.organism_id ) LEFT JOIN $TBAT_PEPTIDE_MAPPING PM ON ( PI.peptide_instance_id = PM.peptide_instance_id ) LEFT JOIN $TBAT_BIOSEQUENCE BS ON ( PM.matched_biosequence_id = BS.biosequence_id ) LEFT JOIN $TB_DBXREF DBX ON ( BS.dbxref_id = DBX.dbxref_id ) WHERE 1 = 1 $atlas_build_clause $peptide_name_clause $peptide_sequence_clause ORDER BY modified_peptide_sequence, MPI.peptide_charge ASC ~; my @mod_peps = $sbeams->selectSeveralColumns( $modSQL ); if ( scalar @mod_peps ) { $modHTML .= $sbeams->getPopupDHTML(); for my $pep ( @mod_peps ) { $pep->[2] = sprintf("%0.4f", $pep->[2]); $pep->[3] = sprintf("%0.2f", $pep->[3]) unless $pep->[3] == 1; $pep->[3] = 1 if $pep->[3] == 1; $pep->[6] = sample_view( $pep->[6] ); } unshift @mod_peps, ['Modified Sequence', 'Charge', 'Mono Parent m/z', 'Best Prob', '# Obs', '# Siblings', 'Sample IDs' ]; $modHTML .= $sbeamsMOD->encodeSectionTable( header => 1, width => '600', align => [qw(left center right right right center center)], rows => \@mod_peps ); print "
$modHTML\n"; } my $sampleSQL = qq ~ SELECT PS.sample_id FROM $TBAT_PEPTIDE_INSTANCE PI INNER JOIN $TBAT_PEPTIDE P ON ( PI.peptide_id = P.peptide_id ) INNER JOIN $TBAT_ATLAS_BUILD AB ON ( PI.atlas_build_id = AB.atlas_build_id ) INNER JOIN $TBAT_PEPTIDE_INSTANCE_SAMPLE PIS ON ( PI.peptide_instance_id = PIS.peptide_instance_id ) INNER JOIN $TBAT_SAMPLE PS ON ( PIS.sample_id = PS.sample_id ) WHERE 1 = 1 $atlas_build_clause $peptide_name_clause $peptide_sequence_clause ~; my @samples = $sbeams->selectOneColumn( $sampleSQL ); my ($sheader, $sHTML) = $sbeamsMOD->getSampleDisplay(sample_ids => \@samples); print "" . $sheader; print "
Chromosome $current_chrom:
This peptide was identified in our original Sequest search, but cannot be mapped to the reference database.
~; $mapHTML .= "The original name from the search was $original_name[0]\n
" if $original_name[0]; $mapHTML .= qq~ Click here to BLAST search this sequence at NCBI.
 
$sHTML
\n"; } #### If QUERY was not selected, then tell the user to enter some parameters } else { if ($sbeams->invocation_mode() eq 'http') { print "

Select parameters above and press QUERY

\n"; } else { print "You need to supply some parameters to contrain the query\n"; } } } # end handle_request sub sample_view { my $samples = shift; my $tot = $samples =~ tr/,/,/; # If we have 5 or fewer, go with the flow return($samples) if $tot <= 5; $samples =~ s/\s//g; my @samples = split(',', $samples); my $viewable = join( ',', @samples[0..3] ); my $session_samples = "$viewable,
\n"; my $cnt = 0; my $sep = ''; for ( my $j = 4; $j <= $#samples; $j++ ) { $cnt++; $session_samples .= $sep . $samples[$j]; $sep = ','; unless( $cnt % 4 ) { $session_samples .= ",
\n"; $sep = ''; } } $session_samples .= "
\n"; my $more = $tot - 4; my $key = $sbeams->getRandomString(num_chars => 20); $sbeams->setSessionAttribute( key => $key, value => $session_samples ); my $url = "$CGI_BASE_DIR/help_popup.cgi?title=Observed%20in%20Samples;session_key=$key;email_link=no"; my $morelink = qq~   [$more more]~; return "$viewable $morelink"; } sub makeProteinLink { my %args = @_; for ( qw( name build ) ) { die "missing parameter $_" unless $args{$_}; } my $target = ( $args{target} ) ? "TARGET=$args{target}" : ''; my $link = "= 2000 ) ? 0 : int((2000 - $len)/2); my $extra = 1000; my $org = $args{org}; $org =~ s/ /_/g; my $chr = $args{chrom}; # Entrez uses roman numerals for yeast chromosomes... if ( $org =~ /^Sacch/ ) { $chr = $sbeams->getRomanNumeral( number => $chr ) || $chr; # Fallback... } my $vc_start = $args{start} - $extra; my $vc_end = $args{end} + $extra; if ( $args{start} > $args{end} ) { $vc_start = $args{end} - $extra; $vc_end = $args{start} + $extra; } $vc_start = 0 if $vc_start < 0; my $link = "" . "
$args{start} - $args{end}
"; return $link; }