<commit_before>/*************************************************************************\
| Javascript for Hydrobobicity                                            |
| Date: 13-04-29                                                          |
| Created by: <NAME>			                          		  |
| File IO code from http://www.html5rocks.com/en/tutorials/file/dndfiles/ |
\*************************************************************************/

//===========================================================================================
// Global Variables
//===========================================================================================
var FastaString = "";
var FastaHeader = "";
var AAseq = [];
var AALabels = [];
var AAHydrobobityPh2 = [];
var AAHydrobobityPh7 = [];
var AATablePh2 = { 	A:  47,
					R: -26,
					N: -41,
					D: -18,
					C:  52,
					Q: -18,
					E:  8,
					G:  0,
					H: -42,
					I:  100,
					L:  100,
					K: -37,
					M:  74,
					F:  92,
					P: -46,
					S: -7,
					T:  13,
					W:  84,
					Y:  49,
					V:  79 }

var AATablePh7 = { 	A:  41,
					R: -14,
					N: -28,
					D: -55,
					C:  49,
					Q: -10,
					E: -31,
					G:  0,
					H:  8,
					I:  99,
					L:  97,
					K: -23,
					M:  74,
					F:  100,
					P: -46,
					S: -5,
					T:  13,
					W:  97,
					Y:  63,
					V:  76 }
					
var AAOneLetterToThreeLetter = { 	A: 'Ala',
									R: 'Arg',
									N: 'Asn',
									D: 'Asp',
									C: 'Cys',
									Q: 'Gln',
									E: 'Glu',
									G: 'Gly',
									H: 'His',
									I: 'Ile',
									L: 'Leu',
									K: 'Lys',
									M: 'Met',
									F: 'Phe',
									P: 'Pro',
									S: 'Ser',
									T: 'Thr',
									W: 'Trp',
									Y: 'Tyr',
									V: 'Val' }
					
//===========================================================================================
// Funtions:
//===========================================================================================
function handleDropzoneFileSelect(event) 
{
	event.stopPropagation();
	event.preventDefault();
	
	var file = event.dataTransfer.files[0]; // FileList object.
	parseFile(file);
}
//-------------------------------------------------------------------------------------------
function handleDragOver(event) 
{
	event.stopPropagation();
	event.preventDefault();
	event.dataTransfer.dropEffect = 'copy'; // Explicitly show this is a copy.
}
//-------------------------------------------------------------------------------------------
function parseFile(file) 
{
	var reader = new FileReader();
	reader.onload = function(e) 
	{
		FastaString = reader.result;
		//alert(FastaString);
		FastaExtraction(FastaString);
		generateAAHydrobobityArrays(AAseq);
		generateChart(); 
	}
	reader.readAsText(file);
}
//-------------------------------------------------------------------------------------------
function FastaExtraction(FastaString) 
{
	var FastaSeq = "";
	var FastaComponents = FastaString.split(/\n/g);

	FastaHeader = FastaComponents[0];
	console.log(FastaHeader);
	for(var x = 1; x < FastaComponents.length; x++)
	{
		FastaSeq += FastaComponents[x];
	}
	AAseq = FastaSeq.toUpperCase().split('');
	console.log(AAseq);
}
//-------------------------------------------------------------------------------------------
function generateAAHydrobobityArrays(AAseq) 
{
	for(var x = 1; x < AAseq.length; x++)
	{
		if (AAseq[x] in AATablePh2)
		{
			AAHydrobobityPh2.push(AATablePh2[AAseq[x]]);
			AAHydrobobityPh7.push(AATablePh7[AAseq[x]]);
			AALabels.push(AAOneLetterToThreeLetter[AAseq[x]])
		}
		else
		{
			alert("Ambiguous Amino Acid Found!");
			AAHydrobobityPh2.push(0);
			AAHydrobobityPh7.push(0);
			AALabels.push("?");
		}
	}
	console.log(AAHydrobobityPh2);
	console.log(AAHydrobobityPh7);
	console.log(AALabels);
}
//-------------------------------------------------------------------------------------------
function generateChart()
{
	var data = {
			labels : AALabels,
			datasets : [
			{
				fillColor : "rgba(220,220,220,0.5)",
				strokeColor : "rgba(220,220,220,1)",
				pointColor : "rgba(220,220,220,1)",
				pointStrokeColor : "#fff",
				data : AAHydrobobityPh2
			},
			{
				fillColor : "rgba(151,187,205,0.5)",
				strokeColor : "rgba(151,187,205,1)",
				pointColor : "rgba(151,187,205,1)",
				pointStrokeColor : "#fff",
				data : AAHydrobobityPh7
			}
		]
	}
	//Get the context of the canvas element we want to select
	var ctx = $("#myChart")[0].getContext("2d");
	ctx.canvas.width = AAseq.length * 10.5;
	ctx.canvas.height = parseInt(parseInt($("#canvasContainer").css("height")) * 0.98);
	var myNewChart = new Chart(ctx).Line(data);
}

//===========================================================================================
// Onload Code
//===========================================================================================
function onLoad() 
{
	// Check for the various File API support.
	if (window.File && window.FileReader && window.FileList && window.Blob) <commit_msg>Move protocol-independent URLs back to static HTTP<commit_after>/*************************************************************************\
| Javascript for Hydrobobicity                                            |
| Date: 13-04-29                                                          |
| Created by: <NAME>			                          		  |
| File IO code from http://www.html5rocks.com/en/tutorials/file/dndfiles/ |
\*************************************************************************/

//===========================================================================================
// Global Variables
//===========================================================================================
var FastaString = "";
var FastaHeader = "";
var AAseq = [];
var AALabels = [];
var AAHydrobobityPh2 = [];
var AAHydrobobityPh7 = [];
var AATablePh2 = { 	A:  47,
					R: -26,
					N: -41,
					D: -18,
					C:  52,
					Q: -18,
					E:  8,
					G:  0,
					H: -42,
					I:  100,
					L:  100,
					K: -37,
					M:  74,
					F:  92,
					P: -46,
					S: -7,
					T:  13,
					W:  84,
					Y:  49,
					V:  79 }

var AATablePh7 = { 	A:  41,
					R: -14,
					N: -28,
					D: -55,
					C:  49,
					Q: -10,
					E: -31,
					G:  0,
					H:  8,
					I:  99,
					L:  97,
					K: -23,
					M:  74,
					F:  100,
					P: -46,
					S: -5,
					T:  13,
					W:  97,
					Y:  63,
					V:  76 }
					
var AAOneLetterToThreeLetter = { 	A: 'Ala',
									R: 'Arg',
									N: 'Asn',
									D: 'Asp',
									C: 'Cys',
									Q: 'Gln',
									E: 'Glu',
									G: 'Gly',
									H: 'His',
									I: 'Ile',
									L: 'Leu',
									K: 'Lys',
									M: 'Met',
									F: 'Phe',
									P: 'Pro',
									S: 'Ser',
									T: 'Thr',
									W: 'Trp',
									Y: 'Tyr',
									V: 'Val' }
					
//===========================================================================================
// Funtions:
//===========================================================================================
function handleDropzoneFileSelect(event) 
{
	event.stopPropagation();
	event.preventDefault();
	
	var file = event.dataTransfer.files[0]; // FileList object.
	parseFile(file);
}
//-------------------------------------------------------------------------------------------
function handleDragOver(event) 
{
	event.stopPropagation();
	event.preventDefault();
	event.dataTransfer.dropEffect = 'copy'; // Explicitly show this is a copy.
}
//-------------------------------------------------------------------------------------------
function parseFile(file) 
{
	var reader = new FileReader();
	reader.onload = function(e) 
	{
		FastaString = reader.result;
		//alert(FastaString);
		FastaExtraction(FastaString);
		generateAAHydrobobityArrays(AAseq);
		generateChart(); 
	}
	reader.readAsText(file);
}
//-------------------------------------------------------------------------------------------
function FastaExtraction(FastaString) 
{
	var FastaSeq = "";
	var FastaComponents = FastaString.split(/\n/g);

	FastaHeader = FastaComponents[0];
	console.log(FastaHeader);
	for(var x = 1; x < FastaComponents.length; x++)
	{
		FastaSeq += FastaComponents[x];
	}
	AAseq = FastaSeq.toUpperCase().split('');
	console.log(AAseq);
}
//-------------------------------------------------------------------------------------------
function generateAAHydrobobityArrays(AAseq) 
{
	for(var x = 1; x < AAseq.length; x++)
	{
		if (AAseq[x] in AATablePh2)
		{
			AAHydrobobityPh2.push(AATablePh2[AAseq[x]]);
			AAHydrobobityPh7.push(AATablePh7[AAseq[x]]);
			AALabels.push(AAOneLetterToThreeLetter[AAseq[x]])
		}
		else
		{
			alert("Ambiguous Amino Acid Found!");
			AAHydrobobityPh2.push(0);
			AAHydrobobityPh7.push(0);
			AALabels.push("?");
		}
	}
	console.log(AAHydrobobityPh2);
	console.log(AAHydrobobityPh7);
	console.log(AALabels);
}
//-------------------------------------------------------------------------------------------
function generateChart()
{
	var data = {
			labels : AALabels,
			datasets : [
			{
				fillColor : "rgba(220,220,220,0.5)",
				strokeColor : "rgba(220,220,220,1)",
				pointColor : "rgba(220,220,220,1)",
				pointStrokeColor : "#fff",
				data : AAHydrobobityPh2
			},
			{
				fillColor : "rgba(151,187,205,0.5)",
				strokeColor : "rgba(151,187,205,1)",
				pointColor : "rgba(151,187,205,1)",
				pointStrokeColor : "#fff",
				data : AAHydrobobityPh7
			}
		]
	}
	//Get the context of the canvas element we want to select
	var ctx = $("#myChart")[0].getContext("2d");
	ctx.canvas.width = AAseq.length * 10;
	ctx.canvas.height = parseInt($("#canvasContainer").css("height")) * 0.98;
	var options = {scaleLineWidth: 0.5};
	var myNewChart = new Chart(ctx).Line(data, options);
}

//===========================================================================================
// Onload Code
//===========================================================================================
function onLoad() 
{
	// Check for the various File API support.
	if (window.File && window.FileReader && window.FileList && window.Blob) 
{'fraction_non_alphanumeric': 0.3558459696727853, 'fraction_numerical': 0.035015961691939344, 'mean_word_length': 1.9686111933668937, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1408669', 'n_tokens_mistral': 4167, 'n_tokens_neox': 3074, 'n_words': 623}