<commit_before>'use strict';

/**
 * @ngdoc service
 * @name helmeditor2App.CanvasDisplayService
 * @description
 * # CanvasDisplayService
 * Service in the helmeditor2App.
 */
angular.module('helmeditor2App')
  .service('CanvasDisplayService', function () {
    // AngularJS will instantiate a singleton by calling 'new' on this function

	var self = this;

   // node id
	var nodeId = 0;

    //number printed by node
    var nodeNum = 0;

	//node height
	var nodeHeight = 25;

	//node width
	var nodeWidth = 25;

	//regular node radius
	var radiusX = 3;
	var radiusY = 3;

	self.createRibose = function (nodeName,  nodeColor, xPos, yPos) {
		//console.log('adding ribose node ' + nodeName +' at: (' + xPos + ',' +yPos +')');
	 	return self.createNode(nodeName, 'NUCLEOTIDE', 'lightgrey', false, xPos, yPos, 'r');
	};

	self.createBase = function (nodeName,  nodeColor, xPos, yPos) {
		//console.log('adding base node ' + nodeName +' at: (' + xPos + ',' +yPos +')');
	 	return self.createNode(nodeName, 'NUCLEOTIDE', nodeColor, true, xPos, yPos, 'b');
	};

	self.createPhosphate = function (nodeName,  nodeColor, xPos, yPos) {
		//console.log('adding phosphate node ' + nodeName +' at: (' + xPos + ',' +yPos +')');
	 	return self.createNode(nodeName, 'NUCLEOTIDE', nodeColor, false, xPos, yPos, 'p');
	};


	// create a new node
	self.createNode = function (nodeName, sequenceType, nodeColor, isRotate, xpos, ypos, nodeType) {

		var rotateDegree = '0';
		var rx = radiusX;
		var ry = radiusX;
		var textColor;

		nodeWidth = self.getNodeWidth(nodeName, isRotate);

		if(isRotate){
			rotateDegree = '45';
		}
		if(nodeType === 'p'){//for phosphate, round the rectangle corners to look like circle
			rx = radiusX +10;
			ry = radiusY +10;			
		}
        if(nodeColor === 'red' || nodeColor === 'purple'){
			textColor = '#FFFFFF';
		} else {
			 textColor = '#000000';
		}

		var newNode = {
			name: nodeName,
            seqType : sequenceType,  //Nucleotide, Peptide, or Chem
			id: nodeId,
			x: xpos,
			y: ypos,
			rx:rx,
			ry: ry,
			lowery: ypos,
			colour: nodeColor,
			height:nodeHeight,
			width:nodeWidth,
			transformx:xpos+nodeHeight/2,
			transformy:ypos+nodeWidth/2,
			transformDegree:rotateDegree,
			seqVisible:	'hidden',
			nodeVisible: 'hidden',
			annotationVisible: 'hidden',
			textColor: textColor,
			nodeType:nodeType,
			annotationText:''
		};

		if (sequenceType === 'PEPTIDE') {
			 newNode.annotationText = 'n';
		}
		else if (sequenceType === 'NUCLEOTIDE') {
			newNode.annotationText = '5\'' ;
		}

		//number nodes if Peptide, or if Nucleotide and a base node
        if ((sequenceType === 'PEPTIDE') || (sequenceType === 'NUCLEOTIDE' && nodeType === 'b')){
            nodeNum++;
            newNode.num = nodeNum;
            newNode.seqVisible = 'visible';
            newNode.nodeVisible = 'visible';
        }
        // adjust the positioning and viisbility of base and chem nodes in lower pane
    	if ((sequenceType === 'CHEM') || (sequenceType === 'NUCLEOTIDE' && nodeType === 'b')){
        	newNode.lowery = newNode.lowery-120;
        	newNode.nodeVisible = 'visible';
        }
        nodeId++;

        if(newNode.num === 1){
        	newNode.annotationVisible = 'visible';
        }
		return newNode;
	};

	self.createConnection = function(sourceNode, destNode){
		var conn = {
			source: sourceNode,
			dest: destNode
		};
		return conn;
	};

	/*Identify a ribose node*/
	self.isRiboseNode = function(node){
	 	var riboseArr = ['R', 'dR', 'sR', 'mR', 'fR', 'LR', 'MOE', 'FMOE',
	 					 'mph', 'PONA','qR', 'RGNA', 'SGNA'	,'12ddR', '25R',
	 					 '4sR' , 'aFR', 'aR', 'eR', 'FR', 'hx', 'ILR', 'tR',
	 					 'UNA', '3A6','3FAM', '3SS6', '5A6','5cGT','5FAM',
	 					 '5FBC6', 'am12', 'am6'];

        //TO-DO: make test case insensitive
	 	if(riboseArr.indexOf(node) !== -1){
	 		return true;
	 	}
	 	return false;
	};

	/*Identify a phosphate node*/
	self.isPhosphateNode = function(node){
		if(node === 'P' || node === 'sP' || node === 'naP' ||  node === 'nasP'){
			return true;
        }
		return false;
	};

	/*get color for a node*/
	self.getNodeColor = function(nodeName){

		var color;
		switch(nodeName){
		
			case 'A':
			case 'cpmA': 
			case 'eaA': 
			case 'daA':
			case 'dabA':
			case 'meA':
			case 'baA':	
			case 'clA':	
			color =	'lightgreen'; 
			break;

			case 'C':
			case 'prpC':
			case '5meC': 
			case 'cpC': 
			case 'cdaC':		
			color =	'red'; 
			break;
			
			case 'G':
			color = 'orange'; 
			break;
			
			case 'T':
			case 'U': 
			case '5eU': 
			case '5fU':
			case 'prpU':
			case 'cpU':
			case '5tpU':
			case 'tfU':
			case '5iU':
			color =	'cyan'; 
			break;
		
			default: 
			color = 'lightgrey';
		}
		return color;		
    };

	/* helper method to calculate width of a node*/
    self.getNodeWidth = function(nodeName, isRotate){
		if(!isRotate){
	    	if(nodeName.length === 3){
				return 30;
			}else if(nodeName.length >= 4){ 
				return 55;
			}
		}
		return 25;
    };

    /*getter/setter for nodeNum*/
	self.getNodeNum = function(){
		return nodeNum;
	};<commit_msg>change default color to the light violet from light grey<commit_after>'use strict';

/**
 * @ngdoc service
 * @name helmeditor2App.CanvasDisplayService
 * @description
 * # CanvasDisplayService
 * Service in the helmeditor2App.
 */
angular.module('helmeditor2App')
  .service('CanvasDisplayService', function () {
    // AngularJS will instantiate a singleton by calling 'new' on this function

	var self = this;

   // node id
	var nodeId = 0;

    //number printed by node
    var nodeNum = 0;

	//node height
	var nodeHeight = 25;

	//node width
	var nodeWidth = 25;

	//regular node radius
	var radiusX = 3;
	var radiusY = 3;

	self.createRibose = function (nodeName,  nodeColor, xPos, yPos) {
		//console.log('adding ribose node ' + nodeName +' at: (' + xPos + ',' +yPos +')');
	 	//return self.createNode(nodeName, 'NUCLEOTIDE', 'lightgrey', false, xPos, yPos, 'r');
	 	return self.createNode(nodeName, 'NUCLEOTIDE', '#c6c3fe', false, xPos, yPos, 'r');
	};

	self.createBase = function (nodeName,  nodeColor, xPos, yPos) {
		//console.log('adding base node ' + nodeName +' at: (' + xPos + ',' +yPos +')');
	 	return self.createNode(nodeName, 'NUCLEOTIDE', nodeColor, true, xPos, yPos, 'b');
	};

	self.createPhosphate = function (nodeName,  nodeColor, xPos, yPos) {
		//console.log('adding phosphate node ' + nodeName +' at: (' + xPos + ',' +yPos +')');
	 	return self.createNode(nodeName, 'NUCLEOTIDE', nodeColor, false, xPos, yPos, 'p');
	};


	// create a new node
	self.createNode = function (nodeName, sequenceType, nodeColor, isRotate, xpos, ypos, nodeType) {

		var rotateDegree = '0';
		var rx = radiusX;
		var ry = radiusX;
		var textColor;

		nodeWidth = self.getNodeWidth(nodeName, isRotate);

		if(isRotate){
			rotateDegree = '45';
		}
		if(nodeType === 'p'){//for phosphate, round the rectangle corners to look like circle
			rx = radiusX +10;
			ry = radiusY +10;			
		}
        if(nodeColor === 'red' || nodeColor === 'purple'){
			textColor = '#FFFFFF';
		} else {
			 textColor = '#000000';
		}

		var newNode = {
			name: nodeName,
            seqType : sequenceType,  //Nucleotide, Peptide, or Chem
			id: nodeId,
			x: xpos,
			y: ypos,
			rx:rx,
			ry: ry,
			lowery: ypos,
			colour: nodeColor,
			height:nodeHeight,
			width:nodeWidth,
			transformx:xpos+nodeHeight/2,
			transformy:ypos+nodeWidth/2,
			transformDegree:rotateDegree,
			seqVisible:	'hidden',
			nodeVisible: 'hidden',
			annotationVisible: 'hidden',
			textColor: textColor,
			nodeType:nodeType,
			annotationText:''
		};

		if (sequenceType === 'PEPTIDE') {
			 newNode.annotationText = 'n';
		}
		else if (sequenceType === 'NUCLEOTIDE') {
			newNode.annotationText = '5\'' ;
		}

		//number nodes if Peptide, or if Nucleotide and a base node
        if ((sequenceType === 'PEPTIDE') || (sequenceType === 'NUCLEOTIDE' && nodeType === 'b')){
            nodeNum++;
            newNode.num = nodeNum;
            newNode.seqVisible = 'visible';
            newNode.nodeVisible = 'visible';
        }
        // adjust the positioning and viisbility of base and chem nodes in lower pane
    	if ((sequenceType === 'CHEM') || (sequenceType === 'NUCLEOTIDE' && nodeType === 'b')){
        	newNode.lowery = newNode.lowery-120;
        	newNode.nodeVisible = 'visible';
        }
        nodeId++;

        if(newNode.num === 1){
        	newNode.annotationVisible = 'visible';
        }
		return newNode;
	};

	self.createConnection = function(sourceNode, destNode){
		var conn = {
			source: sourceNode,
			dest: destNode
		};
		return conn;
	};

	/*Identify a ribose node*/
	self.isRiboseNode = function(node){
	 	var riboseArr = ['R', 'dR', 'sR', 'mR', 'fR', 'LR', 'MOE', 'FMOE',
	 					 'mph', 'PONA','qR', 'RGNA', 'SGNA'	,'12ddR', '25R',
	 					 '4sR' , 'aFR', 'aR', 'eR', 'FR', 'hx', 'ILR', 'tR',
	 					 'UNA', '3A6','3FAM', '3SS6', '5A6','5cGT','5FAM',
	 					 '5FBC6', 'am12', 'am6'];

        //TO-DO: make test case insensitive
	 	if(riboseArr.indexOf(node) !== -1){
	 		return true;
	 	}
	 	return false;
	};

	/*Identify a phosphate node*/
	self.isPhosphateNode = function(node){
		if(node === 'P' || node === 'sP' || node === 'naP' ||  node === 'nasP'){
			return true;
        }
		return false;
	};

	/*get color for a node*/
	self.getNodeColor = function(nodeName){

		var color;
		switch(nodeName){
		
			case 'A':
			case 'cpmA': 
			case 'eaA': 
			case 'daA':
			case 'dabA':
			case 'meA':
			case 'baA':	
			case 'clA':	
			color =	'lightgreen'; 
			break;

			case 'C':
			case 'prpC':
			case '5meC': 
			case 'cpC': 
			case 'cdaC':		
			color =	'red'; 
			break;
			
			case 'G':
			color = 'orange'; 
			break;
			
			case 'T':
			case 'U': 
			case '5eU': 
			case '5fU':
			case 'prpU':
			case 'cpU':
			case '5tpU':
			case 'tfU':
			case '5iU':
			color =	'cyan'; 
			break;
		
			default: 
			//color = 'lightgrey';
			color = '#c6c3fe';
		}
		return color;		
    };

	/* helper method to calculate width of a node*/
    self.getNodeWidth = function(nodeName, isRotate){
		if(!isRotate){
	    	if(nodeName.length === 3){
				return 30;
			}else if(nodeName.length >= 4){ 
				return 55;
			}
		}
		return 25;
    };

    /*getter/setter for nodeNum*/
	self.getNodeNum = function(){
		return nodeNum;
	};
{'fraction_non_alphanumeric': 0.16399805919456575, 'fraction_numerical': 0.012809315866084425, 'mean_word_length': 2.8085735402808574, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3303412', 'n_tokens_mistral': 4367, 'n_tokens_neox': 3735, 'n_words': 947}