|
From: <rb...@us...> - 2010-08-11 22:12:19
|
Revision: 5108
http://sashimi.svn.sourceforge.net/sashimi/?rev=5108&view=rev
Author: rbs66
Date: 2010-08-11 22:12:12 +0000 (Wed, 11 Aug 2010)
Log Message:
-----------
Added RTCalc tab to Petunia, under Utilities. Made by Richie Stauffer.
Modified Paths:
--------------
trunk/trans_proteomic_pipeline/CGI/tpp_gui/tpp_gui.pl
Modified: trunk/trans_proteomic_pipeline/CGI/tpp_gui/tpp_gui.pl
===================================================================
--- trunk/trans_proteomic_pipeline/CGI/tpp_gui/tpp_gui.pl 2010-08-11 18:16:13 UTC (rev 5107)
+++ trunk/trans_proteomic_pipeline/CGI/tpp_gui/tpp_gui.pl 2010-08-11 22:12:12 UTC (rev 5108)
@@ -137,6 +137,7 @@
'DecoyValPeps' , 'Decoy Peptide Validation',
'DecoyValProts' , 'Decoy Protein Validation',
'genLibraCond' , 'Generate Condition File',
+ 'calcRetTime' , 'Run RTCalc',
'switchRawFile' , 'switchRawFile',
'mzxmlgen' , 'Convert to mzXML',
'mzmlgen' , 'Convert to mzML',
@@ -193,6 +194,7 @@
'decoyvalprots' , \&pageDecoyValProts,
'decoyfasta' , \&pageDecoyFasta,
'conditionxml', \&pageLibraCondition,
+ 'rtcalc', \&pageRTCalc,
'mzxml2search', \&pageMzXml2Other,
'dta2mzxml' , \&pageDta2MzXml,
'indexmzxml' , \&pageIndexMzXml,
@@ -434,6 +436,8 @@
$page = &filterMascotFile();
} elsif ( $action eq $web_actions{'genLibraCond'} ) {
$page = &generateLibraConditionFile();
+ } elsif ( $action eq $web_actions{'calcRetTime'} ) {
+ $page = &calculateRetentionTime();
} elsif ( $action eq $web_actions{'updatePaths'} ) {
$page = &updateAllPaths();
} elsif ( $action eq $web_actions{'chargefile'} ) {
@@ -3529,8 +3533,295 @@
return 'conditionxml';
}
+########################################################################
+# pageRTCalc - made by Richard Stauffer (RBS), August 2010
+#
+# creates GUI for Retention Time Predictions page
+#
+########################################################################
+sub pageRTCalc
+{
+ my $infile;
+ my $outfile;
+
+ for (@session_data)
+ {
+ chomp;
+ if (/$proc_types{'lastdir'}:/)
+ {
+ $infile = $';
+ $outfile = $';
+ last;
+ }
+ }
+ $outfile .= 'rtcalc.txt';
+
+ my @sorttypes = ('None',
+ 'Alphabetical', 'Reverse Alphabetical',
+ 'Lowest to Highest', 'Highest to Lowest',
+ 'Shortest to Longest', 'Longest to Shortest');
+
+ #start form
+ print start_form('POST', $tpp_url);
+ #first tab - Choose Output Location and File Name
+ print
+ &printTitle(title => '1. Choose Output Location and File Name'),
+ "<div class = formentry>",
+ #single line textbox takes output file path
+ "Output File: ",
+ textfield(-name => 'rtcalc_outfile',
+ -value => $outfile,
+ -size => 80,
+ -maxlength => 140),
+ "</div>\n";
+
+ #second tab - Peptide List
+ print
+ br,
+ &printTitle(title => '2. Load or paste peptide list'),
+ "<div class = formentry>",
+
+ "Either choose an input file: ",
+ textfield(-name => 'rtcalc_infile',
+ -value => $infile,
+ -size => 80,
+ -maxlength => 140),
+ checkbox(-name => "rtcalc_loadfile",
+ -value => 'false',
+ -label => 'Use File (instead of pasted list)'),
+ br, br,
+
+ #multiline textbox takes list of peptides
+ "Or paste a list of peptides: (separate peptides with whitespace)",
+ br,
+ textarea(-name=>'rtcalc_peplist',
+ -rows => 20,
+ -columns => 104),
+ br, br,
+ "Sort type: ",
+ popup_menu(-name => 'rtcalc_sorttype',
+ -default => 'None',
+ -values => \@sorttypes),
+ br,
+ checkbox(-name => "rtcalc_printresults",
+ -value => 'false',
+ -label => 'Show results when finished'),
+ "</div>\n",
+ br;
+
+ #third tab - Calculate Retention Times
+ print
+ &printTitle(title => '3. Calculate Retention Times'),
+ "<div class = formentry>",
+
+ #submit button
+ submit(-name => 'Action',
+ -value => $web_actions{'calcRetTime'}),
+ "</div>\n";
+
+ #end form
+ print endform;
+}
+
########################################################################
+# calculateRetentionTime - made by Richard Stauffer (RBS), August 2010
+#
+# generates text file of input peptides with calculated retention time
+#
+########################################################################
+sub calculateRetentionTime
+{
+ my $txtfile = param('rtcalc_outfile');
+ my $txtinput;
+
+ #check for errors
+ if (!$txtfile)
+ {
+ push @messages, "Please specify an output file!";
+ Delete('rtcalc_outfile');
+ return 'rtcalc';
+ }
+
+ #set $txtinput
+ if(param('rtcalc_loadfile')) #load list from file
+ {
+ $txtinput = param('rtcalc_infile');
+ my $infile;
+
+ unless(open($infile, $txtinput)) #try to load input file
+ {
+ push @messages, "The input file <b>$txtinput</b> does not exist or it could not be loaded properly.";
+ return 'rtcalc';
+ }
+
+ #copy input file text to $txtinput
+
+ undef $/; #undefine $/ so file will read to end
+ $txtinput = <$infile>;
+ $/ = "\n"; #redefine $/ to newline default
+
+ close($infile);
+ }
+ else #use list from text box
+ {
+ $txtinput = param('rtcalc_peplist');
+
+ if (!$txtinput)
+ {
+ push @messages, "There are no peptides listed.";
+ Delete('rtcalc_peplist');
+ return 'rtcalc';
+ }
+ }
+
+ my $slash = chop($txtfile);
+ $txtfile .= $slash;
+ if ($slash eq "/" || $slash eq "\\")
+ {
+ $txtfile .= "rtcalc.txt";
+ push @messages, "No file name specified, saved as rtcalc.txt.";
+ }
+
+ open(TXTFILE, ">$txtfile") || &fatalError("Cannot create rtcalc.txt: $txtfile: $!");
+ print TXTFILE uc($txtinput);
+ close(TXTFILE);
+
+ my $txtresult = `RTCalc.exe PEPS=$txtfile`;
+
+ my $peperror = length($txtresult) == 0;
+
+ if (!$peperror)
+ {
+ #sort final list as desired
+ my $sorttype = param('rtcalc_sorttype');
+
+ if ($sorttype ne 'None')
+ {
+ #load every line of $txtresult into an array
+ my @resultlines = split(/\n/, $txtresult);
+
+ if (scalar(@resultlines) > 1)
+ {
+ if ($sorttype eq 'Alphabetical') {$sorttype = 1;}
+ elsif ($sorttype eq 'Reverse Alphabetical') {$sorttype = 2;}
+ elsif ($sorttype eq 'Lowest to Highest') {$sorttype = 3;}
+ elsif ($sorttype eq 'Highest to Lowest') {$sorttype = 4;}
+ elsif ($sorttype eq 'Shortest to Longest') {$sorttype = 5;}
+ elsif ($sorttype eq 'Longest to Shortest') {$sorttype = 6;}
+
+ #sort method
+ #based on sort type rewrite result lines in a new order
+ #sort with perl method
+ #reformat lines back to normal
+
+ if ($sorttype == 1)
+ {
+ @resultlines = sort(@resultlines);
+ }
+ elsif ($sorttype == 2)
+ {
+ @resultlines = sort{$b cmp $a} (@resultlines);
+ }
+ else
+ {
+ my @tmpvals;
+
+ foreach my $line (@resultlines)
+ {
+ @tmpvals = split(/\t/, $line);
+
+ $line =
+ {
+ PEP => $tmpvals[0], #peptide
+ RT => $tmpvals[1], #retention time
+ LENGTH => length($tmpvals[0]) #length of peptide
+ };
+ }
+
+ if ($sorttype == 3 || $sorttype == 4)
+ {
+ foreach my $line (@resultlines)
+ {
+ $line = "$line->{RT}\t$line->{PEP}";
+ }
+ }
+ else
+ {
+ foreach my $line (@resultlines)
+ {
+ $line = "$line->{LENGTH}\t$line->{PEP}\t$line->{RT}";
+ }
+ }
+
+ if ($sorttype == 3 || $sorttype == 5)
+ {
+ @resultlines = sort{$a <=> $b} (@resultlines); #sort numerically ascending
+ }
+ else
+ {
+ @resultlines = sort{$b <=> $a} (@resultlines); #sort numerically descending
+ }
+
+ #reformat lines back to normal
+ if ($sorttype == 3 || $sorttype == 4)
+ {
+ foreach my $line (@resultlines) #RT\tPEP
+ {
+ @tmpvals = split(/\t/, $line);
+ $line = "$tmpvals[0]\t$tmpvals[1]";
+ }
+ }
+ else
+ {
+ foreach my $line (@resultlines) #LENGTH\tPEP\tRT
+ {
+ @tmpvals = split(/\t/, $line);
+ $line = "$tmpvals[1]\t$tmpvals[2]";
+ }
+ }
+ }
+
+ $txtresult = "";
+ foreach my $line (@resultlines)
+ {
+ $txtresult .= "$line\n";
+ }
+ chop($txtresult);
+ }
+ }
+ }
+ else
+ {
+ push @messages, "There was a problem calculating the retention time scores, most likely some of the peptides in the list could not be recognized.";
+ $txtresult = "Error! Some peptides may not have been recognized.";
+ }
+
+ open(TXTFILE, ">$txtfile") || &fatalError("Cannot load rtcalc.txt: $txtfile: $!");
+ print TXTFILE "$txtresult";
+ close(TXTFILE);
+
+ my $url = $txtfile;
+ $url =~ s/$www_root/\//;
+
+ if (!$peperror)
+ {
+ push @messages, "The file <b>$txtfile</b> has been successfully generated. [<a target=\"_blank\" href=\"$url\">View</a>]";
+ }
+ else
+ {
+ push @messages, "The file <b>$txtfile</b> has failed to generate properly. [<a target=\"_blank\" href=\"$url\">View</a>]";
+ }
+
+ if (param("rtcalc_printresults"))
+ {
+ push @messages, "<b>Results:</b>\n\n$txtresult";
+ }
+
+ return 'rtcalc';
+}
+
+########################################################################
# filterMascotFile
#
# filter file in tpp from mascot according to Mascot JobId, Mascot user Name,
@@ -3938,7 +4229,7 @@
{ name => 'mzXML Utils', pages=> 'mzxml,mzxml2search,dta2mzxml,indexmzxml'},
{ name => 'Analysis Pipeline', pages=> 'msconvert,runsearch,topepxml,xinteract,iprophet,runprophet'},
{ name => 'Decoy', pages=> 'decoyvalpeps,decoyvalprots,decoyfasta'},
- { name => 'Utilities', pages=> 'filebrowser,updatepaths,qualscore,pepc,conditionxml'},
+ { name => 'Utilities', pages=> 'filebrowser,updatepaths,qualscore,pepc,conditionxml,rtcalc'},
{ name => 'SpectraST Tools', pages=> 'spectrastlib,getspeclibs,lib2html,marimba'}
);
if ($pipeline eq 'Mascot') {
@@ -3974,6 +4265,7 @@
decoyvalpeps => 'Decoy Peptide Validation',
decoyvalprots => 'Decoy Protein Validation',
conditionxml=>'Libra Conditions',
+ rtcalc => 'Retention Time Prediction',
spectrastlib=>'SpectraST Library Import',
getspeclibs=> 'Download Spectral Libraries',
lib2html => 'Lib2HTML',
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|