Basic P S Architecture

The web interface - basic architecture

PS’s web interface uses HTML, JS, CSS and PHP to perform client and server side operations. This page describes a basic interaction diagram of the aforementioned components.


Basic PS architecture

ProteoSign’s architecture is briefly described in the diagram below which is part of our publication. A brief diagram showing PS’s architecture

PS server files - php scripts

ProteoSign’s web interface is used to upload MQ and PD data files, define the experimental structure and parameters and launch the analysis. Many procedures are executed server sided through some php scripts that are located in the server. The server files are all located in the html folder of the server and have the following structure: PS folder architecture PS clients start by displaying index.html on their browsers, styling it with style.css and enhancing it with script.js. Every time a server sided procedure should be executed, PS’s javascript makes an ajax call to a server sided php program sending all necessary data. The procedure is completed asynchronously and the response is returned in json format. The most simple example of such a procedure is getRSS(). In step 4 and while the user waits for analysis results, PS displays some RSS elements - by default some links to interesting big data recent publications. The following diagram overally describes how client’s JS and server’s php communicate: A brief diagram showing an AJAX call in pS Let’s take a look at the following javascript procedure getRSS()

var getRSS = function (rssurl, renderelem) {
	// Get RSS elements from RSS feed
	var thedata = new FormData();
	thedata.append('session_id', sessionid);
	thedata.append('rssurl', rssurl);
	$.ajax({
		url: cgi_bin_path + 'get_rss.php',
		type: 'POST',
		// Form data
		data: thedata,
		//Options to tell jQuery not to worry about content-type.
		processData: false,
		cache: false,
		contentType: false,
		beforeSend: function (jqXHR, settings) {
		    // Add content to be executed right before AJAX call
		}
	}).done(function (data, textStatus, jqXHR) {
		renderRSSData(data, renderelem);
	}).fail(function (jqXHR, textStatus, errorThrown) {
		// Add failure content here
	});
}

In this example thedata is populated with the current session_id (which is a timestamp assigned to the current PS session) and the rss url, ajax is called with the necessary options and in case of PHP’s success the renderRSSData is called with all returned data. In case of PHP’s failure for example due to a timeout error, a fail function can be executed. Taking a look of the same procedure server sided let’s see the following php code:

// get_rss.php
 <?php
	$server_response = [];
	$url = $_POST["rssurl"];
	$xml = simplexml_load_file($_POST["rssurl"]);
	$i = 0;
	if(!empty($xml))
	{
		foreach ($xml->channel->item as $item)
		{
			$server_response[trim((string)$item->title)] = trim((string)$item->link);
			$i++;
			if ($i > 40) break;
		}
	}
	header('Content-type: application/json');
	echo json_encode($server_response);
 ?>

get_rss.php loads the rss file using an xml parser and gets the useful information creating an array ($server_response[title] = [link]). It encodes it to json and sens it back to Javascript. In more complicated php scripts, two typical data elements are returned: $server_response[success] and $server_response[message] that describe whether the script has encounted any fatal errors during its execution and error messages respectively. Note that if $server_response[success] == false PHP will have completed execution so JAVAscript’s .done routine will be executed. For example in onFeedbackPanelSendclick() the .done function is:

.done(function (data, textStatus, jqXHR) {
		// If the connection finished successfully display a thank you message
		if (data.success == true)
		{
			msgbox("<p>Thank you! Your feedback has been submitted successfully!</p>");
			dlgFadeoutFeedback();
			$("#userFeedback").val("");
			var mytext = 600 + " characters left";
			$("#FBcharleft").text(mytext);
		}
		else{
		   msgbox("<p>An error occured! Please try again.</p>");
		}
	})

Notice that the php script might have been executed completely but unsuccessfully, in this case data.success should be set to false.

PS server files - R execution

After setting all parameters and hitting the submit button, perform_analysis.php script cretes an environment with all necessary files inside the sessions directory (uploads/[session_id]). These are:

  • A parameters file
  • A php log file that describe the procedure program if the experiment and the experiment type
  • A tabular file “exp_struct.txt” that containthe experimental structure
  • LFQ_conditions.txt another tabular file that contain the conditions in an LFQ experiment and the rawfiles they are assigned to
  • LS_array, a tabular file that describe any possible label swaps
  • Rename_array.txt a tabular file that contains information for merging conditions to one
  • msdiffexp_peptide.txt: the PD derived uploaded file or the evidence.txt file from MQ
  • msdiffexp_protein.txt: the MQ protein_groups.txt file (in case we deal with a PD derived experiment this file is not present)
  • README.txt a static file that is always copied to the result folder and describes all other files in this folder.
  • Plot_Generator.R a static file that is always copied to the result folder and lets the user customize the rerult plots
  • MSdiffexp_definitions.R an R script that is executed before MSdiffexp.R execution to parametrize the PS run
  • MSdiffexp.R main R program for PS

After this environment preparation, perform_analysis.php calls MSdiffexp.R:

if (command_exists('RScript.exe'))
{
	exec('RScript.exe MSdiffexp.R > msdiffexp_log.txt'); // Windows version
}
else if (command_exists('R'))
{
	exec('R CMD BATCH --slave MSdiffexp.R msdiffexp_log.txt'); // linux version
}
else
{
	error_log("[client: " . $_SERVER['REMOTE_ADDR'] . "] perform_analysis.php [" . $_POST["session_id"] . "]> Error: no R script executable was found!");
	$server_response['msg'] .= "No valid R script executables were found! Aborted analysis!";
	goto end;
}

After its completion all results are zipped into a file and a download link is provided.