Upload Excel file for Correlation:
ⓘ "Here you can import an Excel file with genetic correlations above the diagonal and residual correlations below the diagonal. Please set "1" to the diagonal elements. The first row and first column should be name of the Phenotype."
-
-
+
-
+
@@ -610,8 +621,13 @@
Phenotype Information
-
+
+
+ ⓘ Please click this button if the correlation values are not loaded!
+
+
+
@@ -948,7 +964,7 @@
Multiple Subpopulatio
---->
+-->
diff --git a/mobps.js b/mobps.js
index 5a9a4f2..9f30c60 100644
--- a/mobps.js
+++ b/mobps.js
@@ -343,7 +343,14 @@ app.post('/RsimResult', function(request, response) {
app.get('/Rdownload', function(request, res){
if (request.session.filename) {
var textfile = path.join(__dirname + '/Rmodules/UserScripts/'+request.session.username+'_'+request.session.filename+'.RData');
- res.download(textfile);
+ fs.readFile(textfile, function(err, data){
+ if(err){
+ var message = 'Have not found any RData file for Project ' + request.session.filename +'. Please finish R Simulation successfully and then download RData.';
+ res.send(message.fontcolor("red"));
+ }else{
+ res.download(textfile);
+ }
+ });
} else {
res.send('Please select a project to download RData!');
}
diff --git a/public/javascript/Check_Services.js b/public/javascript/Check_Services.js
index 62a0a30..0073dc3 100644
--- a/public/javascript/Check_Services.js
+++ b/public/javascript/Check_Services.js
@@ -2,71 +2,75 @@
// it will check all possibly inconsistencies if anything of the following components are changed:
function checkEverything(id){
console.log(id);
+
+
if(id == "General_Info"){
-
+
+ data_Vue.warnings1 = [];
+
gen_warn_text = "Please specify a Project Name.";
- if(!data_Vue.geninfo['Project Name'] & data_Vue.warnings.indexOf(gen_warn_text) == -1){
- data_Vue.warnings.push(gen_warn_text);
- }else if(data_Vue.geninfo['Project Name'] != "" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ if(!data_Vue.geninfo['Project Name'] & data_Vue.warnings1.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings1.push(gen_warn_text);
+ }else if(data_Vue.geninfo['Project Name'] != "" & data_Vue.warnings1.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings1.splice(data_Vue.warnings1.indexOf(gen_warn_text),1);
}
gen_warn_text = "Please specify a Species.";
- if(!data_Vue.geninfo['Species'] & data_Vue.warnings.indexOf(gen_warn_text) == -1){
- data_Vue.warnings.push(gen_warn_text);
- }else if(data_Vue.geninfo['Species'] != "" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ if(!data_Vue.geninfo['Species'] & data_Vue.warnings1.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings1.push(gen_warn_text);
+ }else if(data_Vue.geninfo['Species'] != "" & data_Vue.warnings1.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings1.splice(data_Vue.warnings1.indexOf(gen_warn_text),1);
}
gen_warn_text = "Please specify Time Unit.";
- if(!data_Vue.geninfo['Time Unit'] & data_Vue.warnings.indexOf(gen_warn_text) == -1){
- data_Vue.warnings.push(gen_warn_text);
- }else if(data_Vue.geninfo['Time Unit'] != "" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ if(!data_Vue.geninfo['Time Unit'] & data_Vue.warnings1.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings1.push(gen_warn_text);
+ }else if(data_Vue.geninfo['Time Unit'] != "" & data_Vue.warnings1.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings1.splice(data_Vue.warnings1.indexOf(gen_warn_text),1);
}
gen_warn_textEns = "Please specify an Ensembl Dataset.";
- if ((data_Vue.genetic_data == "Ens" & !data_Vue.geninfo['Ensembl Dataset'] & data_Vue.warnings.indexOf(gen_warn_textEns) == -1)){
- data_Vue.warnings.push(gen_warn_textEns);
- }else if(data_Vue.genetic_data == "Ens" & data_Vue.geninfo['Ensembl Dataset'] != "" & data_Vue.warnings.indexOf(gen_warn_textEns) > -1) {
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_textEns),1);
+ if ((data_Vue.genetic_data == "Ens" & !data_Vue.geninfo['Ensembl Dataset'] & data_Vue.warnings1.indexOf(gen_warn_textEns) == -1)){
+ data_Vue.warnings1.push(gen_warn_textEns);
+ }else if(data_Vue.genetic_data == "Ens" & data_Vue.geninfo['Ensembl Dataset'] != "" & data_Vue.warnings1.indexOf(gen_warn_textEns) > -1) {
+ data_Vue.warnings1.splice(data_Vue.warnings1.indexOf(gen_warn_textEns),1);
}
- else if (data_Vue.genetic_data != "Ens" & data_Vue.warnings.indexOf(gen_warn_textEns) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_textEns),1);
+ else if (data_Vue.genetic_data != "Ens" & data_Vue.warnings1.indexOf(gen_warn_textEns) > -1){
+ data_Vue.warnings1.splice(data_Vue.warnings1.indexOf(gen_warn_textEns),1);
}
gen_warn_textSNP = "Please specify Max.Number of SNPs. SNPs are in positive integer";
checkPosSNP = isPositiveInt(data_Vue.geninfo['Max Number of SNPs']);
- if (data_Vue.genetic_data == "Ens" & (isNaN(data_Vue.geninfo['Max Number of SNPs']) || data_Vue.geninfo['Max Number of SNPs'] < 0 || (data_Vue.geninfo['Max Number of SNPs'] != "" & checkPosSNP == false )) & data_Vue.warnings.indexOf(gen_warn_textSNP) == -1){
- data_Vue.warnings.push(gen_warn_textSNP);
- }else if((data_Vue.geninfo['Max Number of SNPs'] == "" || (data_Vue.geninfo['Max Number of SNPs'] >=0 & checkPosSNP == true)) & data_Vue.warnings.indexOf(gen_warn_textSNP) > -1) {
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_textSNP),1);
+ if (data_Vue.genetic_data == "Ens" & (isNaN(data_Vue.geninfo['Max Number of SNPs']) || data_Vue.geninfo['Max Number of SNPs'] < 0 || (data_Vue.geninfo['Max Number of SNPs'] != "" & checkPosSNP == false )) & data_Vue.warnings1.indexOf(gen_warn_textSNP) == -1){
+ data_Vue.warnings1.push(gen_warn_textSNP);
+ }else if((data_Vue.geninfo['Max Number of SNPs'] == "" || (data_Vue.geninfo['Max Number of SNPs'] >=0 & checkPosSNP == true)) & data_Vue.warnings1.indexOf(gen_warn_textSNP) > -1) {
+ data_Vue.warnings1.splice(data_Vue.warnings1.indexOf(gen_warn_textSNP),1);
}
- else if (data_Vue.genetic_data != "Ens" & data_Vue.warnings.indexOf(gen_warn_textSNP) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_textSNP),1);
+ else if (data_Vue.genetic_data != "Ens" & data_Vue.warnings1.indexOf(gen_warn_textSNP) > -1){
+ data_Vue.warnings1.splice(data_Vue.warnings1.indexOf(gen_warn_textSNP),1);
}
gen_warn_text = "Please upload Own Map.";
- if ((data_Vue.genetic_data == "Own" & !data_Vue.geninfo['Own Map Path']) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
- data_Vue.warnings.push(gen_warn_text);
- }else if(data_Vue.geninfo['Own Map Path'] != "Own" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ if ((data_Vue.genetic_data == "Own" & !data_Vue.geninfo['Own Map Path']) & data_Vue.warnings1.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings1.push(gen_warn_text);
+ }else if(data_Vue.geninfo['Own Map Path'] != "Own" & data_Vue.warnings1.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings1.splice(data_Vue.warnings1.indexOf(gen_warn_text),1);
}
gen_warn_text = "Please enter number of Chromosomes. Chromosomes are in positive integer.";
checkCus = isPositiveInteger(data_Vue.geninfo['Number of Chromosomes']) ? "true" : "false";
checkNumeric = isNumeric(data_Vue.geninfo['Number of Chromosomes']);
- if ((data_Vue.genetic_data == "Cus" & !data_Vue.geninfo['Number of Chromosomes'] & checkCus == "false") & data_Vue.warnings.indexOf(gen_warn_text) == -1){
- data_Vue.warnings.push(gen_warn_text);
+ if ((data_Vue.genetic_data == "Cus" & !data_Vue.geninfo['Number of Chromosomes'] & checkCus == "false") & data_Vue.warnings1.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings1.push(gen_warn_text);
}
- else if ((data_Vue.genetic_data == "Cus" & (data_Vue.geninfo['Number of Chromosomes'] != "" & (checkNumeric == "false") || checkCus == "false")) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
- data_Vue.warnings.push(gen_warn_text);
+ else if ((data_Vue.genetic_data == "Cus" & (data_Vue.geninfo['Number of Chromosomes'] != "" & (checkNumeric == "false") || checkCus == "false")) & data_Vue.warnings1.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings1.push(gen_warn_text);
}
- else if ((data_Vue.genetic_data == "Cus" & data_Vue.geninfo['Number of Chromosomes'] != "" & checkCus == "true") & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ else if ((data_Vue.genetic_data == "Cus" & data_Vue.geninfo['Number of Chromosomes'] != "" & checkCus == "true") & data_Vue.warnings1.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings1.splice(data_Vue.warnings1.indexOf(gen_warn_text),1);
}
- else if (data_Vue.genetic_data != "Cus" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ else if (data_Vue.genetic_data != "Cus" & data_Vue.warnings1.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings1.splice(data_Vue.warnings1.indexOf(gen_warn_text),1);
}
@@ -76,30 +80,32 @@ function checkEverything(id){
if (thisChromoNum > 0 ) {
for (i=0; i 0 ) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ else if((data_Vue.geninfo['Chromosomes Info'][i]['Length'] != "" & data_Vue.geninfo['Chromosomes Info'][i]['Length'] > 0 ) & data_Vue.warnings1.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings1.splice(data_Vue.warnings1.indexOf(gen_warn_text),1);
}
gen_warn_text = "Chromo "+(i+1)+" : "+"Please enter Chromosomes MD and must be in number.";
- if((!data_Vue.geninfo['Chromosomes Info'][i]['MD'] || isNaN(data_Vue.geninfo['Chromosomes Info'][i]['MD']) || data_Vue.geninfo['Chromosomes Info'][i]['MD'] < 0) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
- data_Vue.warnings.push(gen_warn_text);
+ if((!data_Vue.geninfo['Chromosomes Info'][i]['MD'] || isNaN(data_Vue.geninfo['Chromosomes Info'][i]['MD']) || data_Vue.geninfo['Chromosomes Info'][i]['MD'] < 0) & data_Vue.warnings1.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings1.push(gen_warn_text);
}
- else if((data_Vue.geninfo['Chromosomes Info'][i]['MD'] != "" & data_Vue.geninfo['Chromosomes Info'][i]['MD'] > 0) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ else if((data_Vue.geninfo['Chromosomes Info'][i]['MD'] != "" & data_Vue.geninfo['Chromosomes Info'][i]['MD'] > 0) & data_Vue.warnings1.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings1.splice(data_Vue.warnings1.indexOf(gen_warn_text),1);
}
gen_warn_text = "Chromo "+(i+1)+" : "+"Please enter Chromosomes Recombination and must be in number.";
- if((!data_Vue.geninfo['Chromosomes Info'][i]['Recombination'] || isNaN(data_Vue.geninfo['Chromosomes Info'][i]['Recombination']) || data_Vue.geninfo['Chromosomes Info'][i]['Recombination'] < 0) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
- data_Vue.warnings.push(gen_warn_text);
+ if((!data_Vue.geninfo['Chromosomes Info'][i]['Recombination'] || isNaN(data_Vue.geninfo['Chromosomes Info'][i]['Recombination']) || data_Vue.geninfo['Chromosomes Info'][i]['Recombination'] < 0) & data_Vue.warnings1.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings1.push(gen_warn_text);
}
- else if((data_Vue.geninfo['Chromosomes Info'][i]['Recombination'] != "" & data_Vue.geninfo['Chromosomes Info'][i]['Recombination'] > 0) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ else if((data_Vue.geninfo['Chromosomes Info'][i]['Recombination'] != "" & data_Vue.geninfo['Chromosomes Info'][i]['Recombination'] > 0) & data_Vue.warnings1.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings1.splice(data_Vue.warnings1.indexOf(gen_warn_text),1);
}
}
}
+ data_Vue.warnings = data_Vue.warnings1.concat(data_Vue.warnings2, data_Vue.warnings3, data_Vue.warnings4, data_Vue.warnings5);
+ data_Vue.warnings = data_Vue.warnings.filter(Boolean);
}
// end general info validation
@@ -107,69 +113,83 @@ function checkEverything(id){
// phenotype validation
if(id == "Phenotype_Info_Div"){
+
+
+ data_Vue.warnings2 = [];
+ count = 0;
+ for(key in data_Vue.warnings1) {
+ if(data_Vue.warnings1.hasOwnProperty(key)) {
+ count++;
+ }
+ }
+
+ if(count==0){
+ data_Vue.warnings1 = [];
+ }
+
var phenoLength = data_Vue.traitsinfo.length;
if (phenoLength > 0 ) {
for (i=0; i -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ else if (data_Vue.traitsinfo[i]['Trait Name'] != "" & data_Vue.warnings2.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings2.splice(data_Vue.warnings2.indexOf(gen_warn_text),1);
}
gen_warn_text = "Pheno "+(i+1)+": Please enter Phenotype Mean and must be in number.";
- if((!data_Vue.traitsinfo[i]['Trait Mean'] || isNaN(data_Vue.traitsinfo[i]['Trait Mean'])) & data_Vue.warnings.indexOf(gen_warn_text) == -1) {
- data_Vue.warnings.push(gen_warn_text);
+ if((!data_Vue.traitsinfo[i]['Trait Mean'] || isNaN(data_Vue.traitsinfo[i]['Trait Mean'])) & data_Vue.warnings2.indexOf(gen_warn_text) == -1) {
+ data_Vue.warnings2.push(gen_warn_text);
}
- else if (data_Vue.traitsinfo[i]['Trait Mean'] != "" & isNaN(data_Vue.traitsinfo[i]['Trait Mean']) == false & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ else if (data_Vue.traitsinfo[i]['Trait Mean'] != "" & isNaN(data_Vue.traitsinfo[i]['Trait Mean']) == false & data_Vue.warnings2.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings2.splice(data_Vue.warnings2.indexOf(gen_warn_text),1);
}
gen_warn_text = "Pheno "+(i+1)+" : "+"Please enter Phenotype Standard deviation and must be a Positive number.";
thisStdDev = data_Vue.traitsinfo[i]['Trait Std Deviation'];
- if ((!thisStdDev || isNaN(thisStdDev) || thisStdDev < 0) & data_Vue.warnings.indexOf(gen_warn_text) == -1) {
- data_Vue.warnings.push(gen_warn_text);
+ if ((!thisStdDev || isNaN(thisStdDev) || thisStdDev < 0) & data_Vue.warnings2.indexOf(gen_warn_text) == -1) {
+ data_Vue.warnings2.push(gen_warn_text);
}
- else if ((thisStdDev != "" & thisStdDev >=0) & isNaN(thisStdDev) == false & data_Vue.warnings.indexOf(gen_warn_text) > -1) {
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ else if ((thisStdDev != "" & thisStdDev >=0) & isNaN(thisStdDev) == false & data_Vue.warnings2.indexOf(gen_warn_text) > -1) {
+ data_Vue.warnings2.splice(data_Vue.warnings2.indexOf(gen_warn_text),1);
}
gen_warn_text = "Pheno"+(i+1)+" : "+"Please enter Trait Heritability and must be a number between 0 and 1. ";
- if((!data_Vue.traitsinfo[i]['Trait Heritability'] || data_Vue.traitsinfo[i]['Trait Heritability'] < 0 || data_Vue.traitsinfo[i]['Trait Heritability'] > 1) & data_Vue.warnings.indexOf(gen_warn_text) == -1) {
- data_Vue.warnings.push(gen_warn_text);
+ if((!data_Vue.traitsinfo[i]['Trait Heritability'] || data_Vue.traitsinfo[i]['Trait Heritability'] < 0 || data_Vue.traitsinfo[i]['Trait Heritability'] > 1) & data_Vue.warnings2.indexOf(gen_warn_text) == -1) {
+ data_Vue.warnings2.push(gen_warn_text);
}
- else if ((data_Vue.traitsinfo[i]['Trait Heritability'] != "" & data_Vue.traitsinfo[i]['Trait Heritability'] >= 0 & data_Vue.traitsinfo[i]['Trait Heritability'] <= 1) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ else if ((data_Vue.traitsinfo[i]['Trait Heritability'] != "" & data_Vue.traitsinfo[i]['Trait Heritability'] >= 0 & data_Vue.traitsinfo[i]['Trait Heritability'] <= 1) & data_Vue.warnings2.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings2.splice(data_Vue.warnings2.indexOf(gen_warn_text),1);
}
checkPoly = isPositiveInt(data_Vue.traitsinfo[i]['Trait Number of Polygenic Loci']);
gen_warn_text = "Pheno"+(i+1)+" : "+"Please enter polygenic loci and must be a Number.";
- if((!data_Vue.traitsinfo[i]['Trait Number of Polygenic Loci'] || data_Vue.traitsinfo[i]['Trait Number of Polygenic Loci'] < 0 || checkPoly == false) & data_Vue.warnings.indexOf(gen_warn_text) == -1) {
- data_Vue.warnings.push(gen_warn_text);
+ if((!data_Vue.traitsinfo[i]['Trait Number of Polygenic Loci'] || data_Vue.traitsinfo[i]['Trait Number of Polygenic Loci'] < 0 || checkPoly == false) & data_Vue.warnings2.indexOf(gen_warn_text) == -1) {
+ data_Vue.warnings2.push(gen_warn_text);
}
- else if ((data_Vue.traitsinfo[i]['Trait Number of Polygenic Loci'] != "" & data_Vue.traitsinfo[i]['Trait Number of Polygenic Loci'] > 0 & checkPoly == true) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ else if ((data_Vue.traitsinfo[i]['Trait Number of Polygenic Loci'] != "" & data_Vue.traitsinfo[i]['Trait Number of Polygenic Loci'] > 0 & checkPoly == true) & data_Vue.warnings2.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings2.splice(data_Vue.warnings2.indexOf(gen_warn_text),1);
}
gen_warn_text = "Pheno"+(i+1)+" : "+"Please enter Value per Unit and must be in number.";
- if((data_Vue.traitsinfo[i]['Trait Value per Unit'] == "" & data_Vue.traitsinfo[i]['Trait Value per Unit'] != "0") & data_Vue.warnings.indexOf(gen_warn_text) == -1) {
- data_Vue.warnings.push(gen_warn_text);
+ if((data_Vue.traitsinfo[i]['Trait Value per Unit'] == "" & data_Vue.traitsinfo[i]['Trait Value per Unit'] != "0") & data_Vue.warnings2.indexOf(gen_warn_text) == -1) {
+ data_Vue.warnings2.push(gen_warn_text);
}
- else if (data_Vue.traitsinfo[i]['Trait Value per Unit'] != "" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ else if (data_Vue.traitsinfo[i]['Trait Value per Unit'] != "" & data_Vue.warnings2.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings2.splice(data_Vue.warnings2.indexOf(gen_warn_text),1);
}
gen_warn_text = "Pheno"+(i+1)+" : "+"Please enter Major QTL and must be in positive number or can be zero. ";
thisMajorQTL = data_Vue.traitsinfo[i]['Trait Major QTL']
- if(thisMajorQTL < 0 & data_Vue.warnings.indexOf(gen_warn_text) ==-1){
- data_Vue.warnings.push(gen_warn_text);
+ if(thisMajorQTL < 0 & data_Vue.warnings2.indexOf(gen_warn_text) ==-1){
+ data_Vue.warnings2.push(gen_warn_text);
}
- else if(thisMajorQTL >= 0 & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ else if(thisMajorQTL >= 0 & data_Vue.warnings2.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings2.splice(data_Vue.warnings2.indexOf(gen_warn_text),1);
}
var qtlCnt = data_Vue.traitsinfo[i]['Trait Major QTL'];
@@ -184,6 +204,8 @@ function checkEverything(id){
}
}
+ data_Vue.warnings = data_Vue.warnings1.concat(data_Vue.warnings2, data_Vue.warnings3, data_Vue.warnings4, data_Vue.warnings5);
+ data_Vue.warnings = data_Vue.warnings.filter(Boolean);
} // end of phenotype validation
@@ -196,6 +218,19 @@ function checkEverything(id){
if(id == "Variables_Info"){
+
+ data_Vue.warnings3 = [];
+
+ count = 0;
+ for(key in data_Vue.warnings1) {
+ if(data_Vue.warnings1.hasOwnProperty(key)) {
+ count++;
+ }
+ }
+
+ if(count==0){
+ data_Vue.warnings1 = [];
+ }
var ownVariableCnt = data_Vue.individualsVar_options.length;
var ownVariable = data_Vue.individualsVar_options;
@@ -205,235 +240,198 @@ function checkEverything(id){
gen_warn_text = thisName+" : "+"Please enter Own variable and must be a positive number.";
- if((thisValue == "" || thisValue =="0" || thisValue <0 || isNaN(thisValue)) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
- data_Vue.warnings.push(gen_warn_text);
+ if((thisValue == "" || thisValue =="0" || thisValue <0 || isNaN(thisValue)) & data_Vue.warnings3.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings2.push(gen_warn_text);
}
- else if((thisValue != "" & thisValue >0) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ else if((thisValue != "" & thisValue >0) & data_Vue.warnings3.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings3.splice(data_Vue.warnings3.indexOf(gen_warn_text),1);
}
}
+ data_Vue.warnings = data_Vue.warnings1.concat(data_Vue.warnings2, data_Vue.warnings3, data_Vue.warnings4, data_Vue.warnings5);
+ data_Vue.warnings = data_Vue.warnings.filter(Boolean);
}
- if(id == "node-popUp"){
-
- gen_warn_text = "Please enter Name of the Node. ";
- if (!data_Vue.active_node['id'] & data_Vue.warnings.indexOf(gen_warn_text) == -1){
- data_Vue.warnings.push(gen_warn_text);
- }else if(data_Vue.active_node['id'] != "" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
- }
+ if(id == "edge-popUp" || id == "node-popUp"){
- gen_warn_text = "Please enter Positive Number or select a Variable. ";
- if (!data_Vue.active_node['Number of Individuals'] & data_Vue.warnings.indexOf(gen_warn_text) == -1){
- data_Vue.warnings.push(gen_warn_text);
- }else if((data_Vue.active_node['Number of Individuals'] != "" || data_Vue.active_node['Number of Individuals'] > 0) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
- }
-
- gen_warn_text = "Please enter Proportion of genotyped individuals of the node. And must be a number between 0 and 1.";
- if((!data_Vue.active_node['Proportion of genotyped individuals'] || data_Vue.active_node['Proportion of genotyped individuals'] < 0 || data_Vue.active_node['Proportion of genotyped individuals'] > 1) & data_Vue.warnings.indexOf(gen_warn_text) == -1) {
- data_Vue.warnings.push(gen_warn_text);
- }
- else if ((data_Vue.active_node['Proportion of genotyped individuals'] != "" & data_Vue.active_node['Proportion of genotyped individuals'] >= 0 & data_Vue.active_node['Proportion of genotyped individuals'] <= 1) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ data_Vue.warnings4 = [];
+ count = 0;
+ for(key in data_Vue.warnings1) {
+ if(data_Vue.warnings1.hasOwnProperty(key)) {
+ count++;
+ }
}
- gen_warn_text = "Please enter Proportion of Male. And must be a number between 0 and 1.";
- if((data_Vue.active_node['Sex'] == "Both" & (!data_Vue.active_node['Proportion of Male'] || data_Vue.active_node['Proportion of Male'] < 0 || data_Vue.active_node['Proportion of Male'] > 1)) & data_Vue.warnings.indexOf(gen_warn_text) == -1) {
- data_Vue.warnings.push(gen_warn_text);
- }
- else if ((data_Vue.active_node['Sex'] == "Both" & (data_Vue.active_node['Proportion of Male'] != "" & data_Vue.active_node['Proportion of Male'] >= 0 & data_Vue.active_node['Proportion of Male'] <= 1)) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
- }
- else if (data_Vue.active_node['Sex'] != "Both" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
- }
-
- }
-
-
- if(id == "edge-popUp"){
-
- gen_warn_text = "Please select Selection type. ";
- if ((data_Vue.active_edge['Breeding Type'] == "Selection" & data_Vue.active_edge['Selection Type'] == "") & data_Vue.warnings.indexOf(gen_warn_text) == -1){
- data_Vue.warnings.push(gen_warn_text);
- }else if((data_Vue.active_edge['Breeding Type'] == "Selection" & data_Vue.active_edge['Selection Type'] != "")& data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
- }else if(data_Vue.active_edge['Breeding Type'] != "Selection" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ if(count==0){
+ data_Vue.warnings1 = [];
+ }
+ nodes = data_Vue.nodes.get();
+ nodes = Array.from(nodes);
+ if(nodes.length > 0){
+ for(let i=0; i < nodes.length; i++){
+ active_node = nodes[i];
+
+ gen_warn_text = "Please assign each node with a name.";
+ if (!active_node['id'] & data_Vue.warnings4.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings4.push(gen_warn_text);
+ }
+
+ gen_warn_text = "Number of individuals in Node " + active_node['id'] + " is not specified";
+ if (!active_node['Number of Individuals'] & data_Vue.warnings4.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings4.push(gen_warn_text);
+ }
+
+ gen_warn_text = "Share of genotyped individuals in " + active_node['id'] + " must be between 0 and 1.";
+ if((!active_node['Proportion of genotyped individuals'] || active_node['Proportion of genotyped individuals'] < 0 || active_node['Proportion of genotyped individuals'] > 1) & data_Vue.warnings4.indexOf(gen_warn_text) == -1) {
+ data_Vue.warnings4.push(gen_warn_text);
+ }
+
+ gen_warn_text = "Share of male individuals in " + active_node['id'] + " must be between 0 and 1.";
+ if((active_node['Sex'] == "Both" & (!active_node['Proportion of Male'] || active_node['Proportion of Male'] < 0 || active_node['Proportion of Male'] > 1)) & data_Vue.warnings4.indexOf(gen_warn_text) == -1) {
+ data_Vue.warnings4.push(gen_warn_text);
+ }
+
+ }
}
- gen_warn_text = "Please enter Time needed for Selection. And it must be a positive number";
- if ((data_Vue.active_edge['Breeding Type'] == "Selection" & data_Vue.active_edge['Time Needed'] == null || data_Vue.active_edge['Time Needed'] < 0 || isNaN(data_Vue.active_edge['Time Needed'])) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
- data_Vue.warnings.push(gen_warn_text);
- }else if(((data_Vue.active_edge['Breeding Type'] == "Selection" & data_Vue.active_edge['Time Needed'] != null) & data_Vue.active_edge['Time Needed'] >= 0) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
- } else if(data_Vue.active_edge['Breeding Type'] != "Selection" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
- }
-
- gen_warn_text = "Please select Relationship Matrix for Selection type BVE. ";
- if (((data_Vue.active_edge['Breeding Type'] == "Selection" & data_Vue.active_edge['Selection Type'] == "BVE") & !data_Vue.active_edge['Relationship Matrix']) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
- data_Vue.warnings.push(gen_warn_text);
- }else if(((data_Vue.active_edge['Breeding Type'] == "Selection" & data_Vue.active_edge['Selection Type'] != "") &data_Vue.active_edge['Relationship Matrix'] != "") & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
- }else if(data_Vue.active_edge['Breeding Type'] != "Selection" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
- }
-
- gen_warn_text = "Please select BVE Method for Selection type BVE. ";
- if (((data_Vue.active_edge['Breeding Type'] == "Selection" & data_Vue.active_edge['Selection Type'] == "BVE") & !data_Vue.active_edge['BVE Method']) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
- data_Vue.warnings.push(gen_warn_text);
- }else if(((data_Vue.active_edge['Breeding Type'] == "Selection" & data_Vue.active_edge['Selection Type'] != "") &data_Vue.active_edge['BVE Method'] != "") & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
- }else if(data_Vue.active_edge['Breeding Type'] != "Selection" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
- }
-
- gen_warn_text = "Please enter Depth of Pedigree. And it is a Number ";
- if ((data_Vue.active_edge['Breeding Type'] == "Selection" & data_Vue.active_edge['Selection Type'] == "BVE" & data_Vue.active_edge['Relationship Matrix'] == "Pedigree") & (!data_Vue.active_edge['Depth of Pedigree'] || isNaN(data_Vue.active_edge['Depth of Pedigree'])) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
- data_Vue.warnings.push(gen_warn_text);
- }else if(((data_Vue.active_edge['Breeding Type'] == "Selection" & data_Vue.active_edge['Selection Type'] == "BVE" & data_Vue.active_edge['Relationship Matrix'] == "Pedigree") & data_Vue.active_edge['Depth of Pedigree'] != "" & data_Vue.active_edge['Depth of Pedigree'] >= 0 ) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
- }else if(((data_Vue.active_edge['Breeding Type'] == "Selection" & data_Vue.active_edge['Selection Type'] == "BVE" & data_Vue.active_edge['Relationship Matrix'] != "Pedigree") || (data_Vue.active_edge['Depth of Pedigree'] == "" || data_Vue.active_edge['Depth of Pedigree'] != "" || data_Vue.active_edge['Depth of Pedigree'] >= 0 )) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
- }else if((data_Vue.active_edge['Breeding Type'] != "Selection" & data_Vue.active_edge['Selection Type'] == "BVE" & data_Vue.active_edge['Relationship Matrix'] == "Pedigree") & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
- }
+ data_Vue.warnings = data_Vue.warnings1.concat(data_Vue.warnings2, data_Vue.warnings3, data_Vue.warnings4, data_Vue.warnings5);
+ data_Vue.warnings = data_Vue.warnings.filter(Boolean);
+ }
- gen_warn_text = "Please enter Depth of Pedigree for Single Step. And it is a Number ";
- if ((data_Vue.active_edge['Breeding Type'] == "Selection" & data_Vue.active_edge['Selection Type'] == "BVE" & data_Vue.active_edge['Relationship Matrix'] == "Single Step") & (!data_Vue.active_edge['Depth of Pedigree'] || isNaN(data_Vue.active_edge['Depth of Pedigree'])) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
- data_Vue.warnings.push(gen_warn_text);
- }else if(((data_Vue.active_edge['Breeding Type'] == "Selection" & data_Vue.active_edge['Selection Type'] == "BVE" & data_Vue.active_edge['Relationship Matrix'] == "Single Step") & data_Vue.active_edge['Depth of Pedigree'] != "" & data_Vue.active_edge['Depth of Pedigree'] >= 0 ) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
- }else if((data_Vue.active_edge['Breeding Type'] != "Selection" & data_Vue.active_edge['Selection Type'] != "BVE" || data_Vue.active_edge['Relationship Matrix'] == "Single Step" || data_Vue.active_edge['Relationship Matrix'] != "Single Step") & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
- }
-
- gen_warn_text = "Please select Cohorts Used in BVE for Selection type BVE. ";
- if (((data_Vue.active_edge['Breeding Type'] == "Selection" & data_Vue.active_edge['Selection Type'] == "BVE") & !data_Vue.active_edge['Cohorts used in BVE']) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
- data_Vue.warnings.push(gen_warn_text);
- }else if(((data_Vue.active_edge['Breeding Type'] == "Selection" & data_Vue.active_edge['Selection Type'] == "BVE") & data_Vue.active_edge['Cohorts used in BVE'] != "") & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
- }else if(data_Vue.active_edge['Breeding Type'] != "Selection" & data_Vue.active_edge['Selection Type'] == "BVE" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
- }
+ if(id == "edge-popUp" || id == "node-popUp"){
- gen_warn_text = "Please enter Time needed for Reproduction. It must be a positive number";
- if (data_Vue.active_edge['Breeding Type'] == "Reproduction" & ( data_Vue.active_edge['Time Needed'] == null || data_Vue.active_edge['Time Needed'] <0 || isNaN(data_Vue.active_edge['Time Needed'])) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
- data_Vue.warnings.push(gen_warn_text);
- }else if((data_Vue.active_edge['Breeding Type'] == "Reproduction" & data_Vue.active_edge['Time Needed'] !=null & data_Vue.active_edge['Time Needed'] >=0) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
- } else if(data_Vue.active_edge['Breeding Type'] != "Reproduction" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ count = 0;
+ for(key in data_Vue.warnings1) {
+ if(data_Vue.warnings1.hasOwnProperty(key)) {
+ count++;
+ }
}
- gen_warn_text = "Please select id for Reproduction. ";
- if (data_Vue.active_edge['Breeding Type'] == "Reproduction" & (data_Vue.active_edge['id'] == "" || data_Vue.active_edge['id'] <0) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
- data_Vue.warnings.push(gen_warn_text);
- }else if((data_Vue.active_edge['Breeding Type'] == "Reproduction" & data_Vue.active_edge['id'] !="" & data_Vue.active_edge['Time Needed'] >=0) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
- } else if(data_Vue.active_edge['Breeding Type'] != "Reproduction" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ if(count==0){
+ data_Vue.warnings1 = [];
}
- gen_warn_text = "Please enter number of repeat for breeding type Repeat. It must be a positive number ";
- if (data_Vue.active_edge['Breeding Type'] == "Repeat" & (!data_Vue.active_edge['Number of Repeat'] || data_Vue.active_edge['Number of Repeat'] < 0 || isNaN(data_Vue.active_edge['Time Needed'])) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
- data_Vue.warnings.push(gen_warn_text);
- }else if((data_Vue.active_edge['Breeding Type'] == "Repeat" & data_Vue.active_edge['Number of Repeat'] != "" & data_Vue.active_edge['Number of Repeat'] >=0) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
- }else if(data_Vue.active_edge['Breeding Type'] != "Repeat" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
- }
+ data_Vue.warnings5 = [];
- gen_warn_text = "Please enter Time needed for Cloning. And it must be a positive number";
- if (data_Vue.active_edge['Breeding Type'] == "Cloning" & (data_Vue.active_edge['Time Needed'] == null || data_Vue.active_edge['Time Needed'] <0 || isNaN(data_Vue.active_edge['Time Needed'])) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
- data_Vue.warnings.push(gen_warn_text);
- }else if((data_Vue.active_edge['Breeding Type'] == "Cloning" & data_Vue.active_edge['Time Needed'] != null & data_Vue.active_edge['Time Needed'] >=0) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
- } else if(data_Vue.active_edge['Breeding Type'] != "Cloning" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
- }
-
- gen_warn_text = "Please enter Time needed for Split. And it must be a positive number";
- if (data_Vue.active_edge['Breeding Type'] == "Split" & (data_Vue.active_edge['Time Needed'] == null || data_Vue.active_edge['Time Needed'] <0 || isNaN(data_Vue.active_edge['Time Needed'])) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
- data_Vue.warnings.push(gen_warn_text);
- }else if((data_Vue.active_edge['Breeding Type'] == "Split" & data_Vue.active_edge['Time Needed'] != null & data_Vue.active_edge['Time Needed'] >=0) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
- } else if(data_Vue.active_edge['Breeding Type'] != "Split" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
- }
-
- gen_warn_text = "Please enter Time needed for Selfing. And it must be a positive number";
- if (data_Vue.active_edge['Breeding Type'] == "Selfing" & (data_Vue.active_edge['Time Needed'] == null || data_Vue.active_edge['Time Needed'] <0 || isNaN(data_Vue.active_edge['Time Needed'])) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
- data_Vue.warnings.push(gen_warn_text);
- }else if((data_Vue.active_edge['Breeding Type'] == "Selfing" & data_Vue.active_edge['Time Needed'] != null & data_Vue.active_edge['Time Needed'] >=0) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
- } else if(data_Vue.active_edge['Breeding Type'] != "Selfing" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
- }
-
- gen_warn_text = "Please enter Time needed for Combine. It must be a positive number number";
- if (data_Vue.active_edge['Breeding Type'] == "Combine" & (data_Vue.active_edge['Time Needed'] == null || data_Vue.active_edge['Time Needed'] <0 || isNaN(data_Vue.active_edge['Time Needed'])) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
- data_Vue.warnings.push(gen_warn_text);
- }else if((data_Vue.active_edge['Breeding Type'] == "Combine" & data_Vue.active_edge['Time Needed'] != null & data_Vue.active_edge['Time Needed'] >=0) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
- } else if(data_Vue.active_edge['Breeding Type'] != "Combine" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
- }
-
- gen_warn_text = "Please enter Time needed for DH-Production. And it must be a positive number";
- if (data_Vue.active_edge['Breeding Type'] == "DH-Production" & (data_Vue.active_edge['Time Needed'] == null || data_Vue.active_edge['Time Needed'] <0 || isNaN(data_Vue.active_edge['Time Needed'])) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
- data_Vue.warnings.push(gen_warn_text);
- }else if((data_Vue.active_edge['Breeding Type'] == "DH-Production" & data_Vue.active_edge['Time Needed'] != null & data_Vue.active_edge['Time Needed'] >=0) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
- } else if(data_Vue.active_edge['Breeding Type'] != "DH-Production" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
- }
-
- gen_warn_text = "Please enter Time needed for Aging. And it must be a positive number";
- if (data_Vue.active_edge['Breeding Type'] == "Aging" & (data_Vue.active_edge['Time Needed'] == null || data_Vue.active_edge['Time Needed'] <0 || isNaN(data_Vue.active_edge['Time Needed'])) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
- data_Vue.warnings.push(gen_warn_text);
- }else if((data_Vue.active_edge['Breeding Type'] == "Aging" & data_Vue.active_edge['Time Needed'] != null & data_Vue.active_edge['Time Needed'] >=0) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
- } else if(data_Vue.active_edge['Breeding Type'] != "Aging" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
- }
-
- gen_warn_text = "Please enter Recombination - New Mutation Rate. ";
- if ((data_Vue.active_edge['Breeding Type'] == "Recombination" & !data_Vue.active_edge['New Mutation Rate']) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
- data_Vue.warnings.push(gen_warn_text);
- } else if((data_Vue.active_edge['Breeding Type'] == "Recombination" & data_Vue.active_edge['New Mutation Rate'] != "") & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
- } else if(data_Vue.active_edge['Breeding Type'] != "Recombination" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
- }
-
+
+ nodes = data_Vue.nodes.get();
+ nodes = Array.from(nodes);
+ edges = data_Vue.edges.get();
+ edges = Array.from(edges);
- gen_warn_text = "Please enter Recombination - New Remutation Rate. ";
- if ((data_Vue.active_edge['Breeding Type'] == "Recombination" & !data_Vue.active_edge['New Remutation Rate']) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
- data_Vue.warnings.push(gen_warn_text);
- } else if((data_Vue.active_edge['Breeding Type'] == "Recombination" & data_Vue.active_edge['New Remutation Rate'] != "") & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
- } else if(data_Vue.active_edge['Breeding Type'] != "Recombination" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ if(edges.length > 0){
+ edge_from = [];
+ edge_to = [];
+ edge_nrfrom = [];
+ edge_nrto = [];
+ edge_type = [];
+ node_name = [];
+ node_founder = [];
+
+ for(let i=0; i < nodes.length; i++){
+ node_name.push(nodes[i]['id'])
+ node_founder.push(nodes[i]['Founder'])
+ }
+
+ for(let i=0; i < edges.length; i++){
+ edge_to.push(edges[i]['to']);
+ edge_from.push(edges[i]['from']);
+ edge_type.push(edges[i]['Breeding Type']);
+ for(let j=0; j < nodes.length; j++){
+ if(edge_from[i]==node_name[j]){
+ edge_nrfrom.push(j);
+ }
+ if(edge_to[i]==node_name[j]){
+ edge_nrto.push(j);
+ }
+ }
+ gen_warn_text = "No Breeding Type selected for Edge between " + edges[i]['from'] + " and " + edges[i]['to'];
+ if (edges[i]['Breeding Type']=="" & data_Vue.warnings5.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings5.push(gen_warn_text);
+ }
+ }
+
+
+ for(let i=0; i < edges.length; i++){
+ if(edge_type[i] =="Selection" || edge_type[i] == "Aging" || edge_type[i] == "Split"){
+ size1 = parseFloat(nodes[edge_nrfrom[i]]['Number of Individuals']);
+ size2 = parseFloat(nodes[edge_nrto[i]]['Number of Individuals']);
+ if(size10 && combine_count != size2){
+ gen_warn_text = "Individual number for Combining nodes to "+ node_name[i] +" do not add up";
+ data_Vue.warnings5.push(gen_warn_text);
+ }
+ if(split_count>0 && split_count != size2){
+ gen_warn_text = "Individual numbers for Splitting node "+ node_name[i] +" do not add up";
+ data_Vue.warnings5.push(gen_warn_text);
+ }
+ }
+ }
+
+
}
+
+
- gen_warn_text = "Please enter Recombination - Number of Recombination per M. ";
- if ((data_Vue.active_edge['Breeding Type'] == "Recombination" & !data_Vue.active_edge['Number of Rec per M']) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
- data_Vue.warnings.push(gen_warn_text);
- }else if((data_Vue.active_edge['Breeding Type'] == "Recombination" & data_Vue.active_edge['Number of Rec per M'] !="") & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
- } else if(data_Vue.active_edge['Breeding Type'] != "Recombination" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
- data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
- }
-
+ data_Vue.warnings = data_Vue.warnings1.concat(data_Vue.warnings2, data_Vue.warnings3, data_Vue.warnings4, data_Vue.warnings5);
+ data_Vue.warnings = data_Vue.warnings.filter(Boolean);
}
+
data_Vue.project_saved = false;
}
diff --git a/public/javascript/Check_Services_old.js b/public/javascript/Check_Services_old.js
new file mode 100644
index 0000000..dd4ede7
--- /dev/null
+++ b/public/javascript/Check_Services_old.js
@@ -0,0 +1,781 @@
+// this function will always be called when the body is focused on,
+// it will check all possibly inconsistencies if anything of the following components are changed:
+function checkEverything(id){
+ console.log(id);
+ if(id == "General_Info"){
+
+ gen_warn_text = "Please specify a Project Name.";
+ if(!data_Vue.geninfo['Project Name'] & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ }else if(data_Vue.geninfo['Project Name'] != "" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Please specify a Species.";
+ if(!data_Vue.geninfo['Species'] & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ }else if(data_Vue.geninfo['Species'] != "" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Please specify Time Unit.";
+ if(!data_Vue.geninfo['Time Unit'] & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ }else if(data_Vue.geninfo['Time Unit'] != "" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_textEns = "Please specify an Ensembl Dataset.";
+ if ((data_Vue.genetic_data == "Ens" & !data_Vue.geninfo['Ensembl Dataset'] & data_Vue.warnings.indexOf(gen_warn_textEns) == -1)){
+ data_Vue.warnings.push(gen_warn_textEns);
+ }else if(data_Vue.genetic_data == "Ens" & data_Vue.geninfo['Ensembl Dataset'] != "" & data_Vue.warnings.indexOf(gen_warn_textEns) > -1) {
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_textEns),1);
+ }
+ else if (data_Vue.genetic_data != "Ens" & data_Vue.warnings.indexOf(gen_warn_textEns) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_textEns),1);
+ }
+
+ gen_warn_textSNP = "Please specify Max.Number of SNPs. SNPs are in positive integer";
+ checkPosSNP = isPositiveInt(data_Vue.geninfo['Max Number of SNPs']);
+ if (data_Vue.genetic_data == "Ens" & (isNaN(data_Vue.geninfo['Max Number of SNPs']) || data_Vue.geninfo['Max Number of SNPs'] < 0 || (data_Vue.geninfo['Max Number of SNPs'] != "" & checkPosSNP == false )) & data_Vue.warnings.indexOf(gen_warn_textSNP) == -1){
+ data_Vue.warnings.push(gen_warn_textSNP);
+ }else if((data_Vue.geninfo['Max Number of SNPs'] == "" || (data_Vue.geninfo['Max Number of SNPs'] >=0 & checkPosSNP == true)) & data_Vue.warnings.indexOf(gen_warn_textSNP) > -1) {
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_textSNP),1);
+ }
+ else if (data_Vue.genetic_data != "Ens" & data_Vue.warnings.indexOf(gen_warn_textSNP) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_textSNP),1);
+ }
+
+ gen_warn_text = "Please upload Own Map.";
+ if ((data_Vue.genetic_data == "Own" & !data_Vue.geninfo['Own Map Path']) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ }else if(data_Vue.geninfo['Own Map Path'] != "Own" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Please enter number of Chromosomes. Chromosomes are in positive integer.";
+ checkCus = isPositiveInteger(data_Vue.geninfo['Number of Chromosomes']) ? "true" : "false";
+ checkNumeric = isNumeric(data_Vue.geninfo['Number of Chromosomes']);
+ if ((data_Vue.genetic_data == "Cus" & !data_Vue.geninfo['Number of Chromosomes'] & checkCus == "false") & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ }
+ else if ((data_Vue.genetic_data == "Cus" & (data_Vue.geninfo['Number of Chromosomes'] != "" & (checkNumeric == "false") || checkCus == "false")) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ }
+ else if ((data_Vue.genetic_data == "Cus" & data_Vue.geninfo['Number of Chromosomes'] != "" & checkCus == "true") & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+ else if (data_Vue.genetic_data != "Cus" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+
+ thisChromoLen = data_Vue.geninfo['Chromosomes of Equal Length'];
+ thisChromoNum = data_Vue.geninfo['Chromosomes Info'].length;
+
+ if (thisChromoNum > 0 ) {
+ for (i=0; i 0 ) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Chromo "+(i+1)+" : "+"Please enter Chromosomes MD and must be in number.";
+ if((!data_Vue.geninfo['Chromosomes Info'][i]['MD'] || isNaN(data_Vue.geninfo['Chromosomes Info'][i]['MD']) || data_Vue.geninfo['Chromosomes Info'][i]['MD'] < 0) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ }
+ else if((data_Vue.geninfo['Chromosomes Info'][i]['MD'] != "" & data_Vue.geninfo['Chromosomes Info'][i]['MD'] > 0) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Chromo "+(i+1)+" : "+"Please enter Chromosomes Recombination and must be in number.";
+ if((!data_Vue.geninfo['Chromosomes Info'][i]['Recombination'] || isNaN(data_Vue.geninfo['Chromosomes Info'][i]['Recombination']) || data_Vue.geninfo['Chromosomes Info'][i]['Recombination'] < 0) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ }
+ else if((data_Vue.geninfo['Chromosomes Info'][i]['Recombination'] != "" & data_Vue.geninfo['Chromosomes Info'][i]['Recombination'] > 0) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+ }
+ }
+ }
+// end general info validation
+
+
+
+ // phenotype validation
+ if(id == "Phenotype_Info_Div"){
+ var phenoLength = data_Vue.traitsinfo.length;
+
+ if (phenoLength > 0 ) {
+ for (i=0; i -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Pheno "+(i+1)+": Please enter Phenotype Mean and must be in number.";
+ if((!data_Vue.traitsinfo[i]['Trait Mean'] || isNaN(data_Vue.traitsinfo[i]['Trait Mean'])) & data_Vue.warnings.indexOf(gen_warn_text) == -1) {
+ data_Vue.warnings.push(gen_warn_text);
+ }
+ else if (data_Vue.traitsinfo[i]['Trait Mean'] != "" & isNaN(data_Vue.traitsinfo[i]['Trait Mean']) == false & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Pheno "+(i+1)+" : "+"Please enter Phenotype Standard deviation and must be a Positive number.";
+ thisStdDev = data_Vue.traitsinfo[i]['Trait Std Deviation'];
+
+ if ((!thisStdDev || isNaN(thisStdDev) || thisStdDev < 0) & data_Vue.warnings.indexOf(gen_warn_text) == -1) {
+ data_Vue.warnings.push(gen_warn_text);
+ }
+ else if ((thisStdDev != "" & thisStdDev >=0) & isNaN(thisStdDev) == false & data_Vue.warnings.indexOf(gen_warn_text) > -1) {
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Pheno"+(i+1)+" : "+"Please enter Trait Heritability and must be a number between 0 and 1. ";
+ if((!data_Vue.traitsinfo[i]['Trait Heritability'] || data_Vue.traitsinfo[i]['Trait Heritability'] < 0 || data_Vue.traitsinfo[i]['Trait Heritability'] > 1) & data_Vue.warnings.indexOf(gen_warn_text) == -1) {
+ data_Vue.warnings.push(gen_warn_text);
+ }
+ else if ((data_Vue.traitsinfo[i]['Trait Heritability'] != "" & data_Vue.traitsinfo[i]['Trait Heritability'] >= 0 & data_Vue.traitsinfo[i]['Trait Heritability'] <= 1) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ checkPoly = isPositiveInt(data_Vue.traitsinfo[i]['Trait Number of Polygenic Loci']);
+ gen_warn_text = "Pheno"+(i+1)+" : "+"Please enter polygenic loci and must be a Number.";
+ if((!data_Vue.traitsinfo[i]['Trait Number of Polygenic Loci'] || data_Vue.traitsinfo[i]['Trait Number of Polygenic Loci'] < 0 || checkPoly == false) & data_Vue.warnings.indexOf(gen_warn_text) == -1) {
+ data_Vue.warnings.push(gen_warn_text);
+ }
+ else if ((data_Vue.traitsinfo[i]['Trait Number of Polygenic Loci'] != "" & data_Vue.traitsinfo[i]['Trait Number of Polygenic Loci'] > 0 & checkPoly == true) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Pheno"+(i+1)+" : "+"Please enter Value per Unit and must be in number.";
+ if((data_Vue.traitsinfo[i]['Trait Value per Unit'] == "" & data_Vue.traitsinfo[i]['Trait Value per Unit'] != "0") & data_Vue.warnings.indexOf(gen_warn_text) == -1) {
+ data_Vue.warnings.push(gen_warn_text);
+ }
+ else if (data_Vue.traitsinfo[i]['Trait Value per Unit'] != "" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Pheno"+(i+1)+" : "+"Please enter Major QTL and must be in positive number or can be zero. ";
+ thisMajorQTL = data_Vue.traitsinfo[i]['Trait Major QTL']
+ if(thisMajorQTL < 0 & data_Vue.warnings.indexOf(gen_warn_text) ==-1){
+ data_Vue.warnings.push(gen_warn_text);
+ }
+ else if(thisMajorQTL >= 0 & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ var qtlCnt = data_Vue.traitsinfo[i]['Trait Major QTL'];
+ var qtlName = i;
+
+ if (qtlCnt > 0) {
+ qtlsforPheno(qtlName, qtlCnt);
+ }
+
+ matrix1();
+ matrix2();
+
+ }
+ }
+ } // end of phenotype validation
+
+
+ if(id == "Selectionindex_Div"){
+ selection_Index();
+ phenotyping_classes();
+ economyWarning();
+ animalHousingCost();
+ }
+
+
+ if(id == "Variables_Info"){
+ var ownVariableCnt = data_Vue.individualsVar_options.length;
+ var ownVariable = data_Vue.individualsVar_options;
+
+ for(let i=0; i < ownVariableCnt; i++){
+ thisName = ownVariable[i]['name'];
+ thisValue = ownVariable[i]['value'];
+
+ gen_warn_text = thisName+" : "+"Please enter Own variable and must be a positive number.";
+
+ if((thisValue == "" || thisValue =="0" || thisValue <0 || isNaN(thisValue)) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ }
+ else if((thisValue != "" & thisValue >0) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ }
+ }
+
+
+ if(id == "node-popUp"){
+
+ gen_warn_text = "Please enter Name of the Node. ";
+ if (!data_Vue.active_node['id'] & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ }else if(data_Vue.active_node['id'] != "" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Please enter Positive Number or select a Variable. ";
+ if (!data_Vue.active_node['Number of Individuals'] & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ }else if((data_Vue.active_node['Number of Individuals'] != "" || data_Vue.active_node['Number of Individuals'] > 0) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Please enter Proportion of genotyped individuals of the node. And must be a number between 0 and 1.";
+ if((!data_Vue.active_node['Proportion of genotyped individuals'] || data_Vue.active_node['Proportion of genotyped individuals'] < 0 || data_Vue.active_node['Proportion of genotyped individuals'] > 1) & data_Vue.warnings.indexOf(gen_warn_text) == -1) {
+ data_Vue.warnings.push(gen_warn_text);
+ }
+ else if ((data_Vue.active_node['Proportion of genotyped individuals'] != "" & data_Vue.active_node['Proportion of genotyped individuals'] >= 0 & data_Vue.active_node['Proportion of genotyped individuals'] <= 1) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Please enter Proportion of Male. And must be a number between 0 and 1.";
+ if((data_Vue.active_node['Sex'] == "Both" & (!data_Vue.active_node['Proportion of Male'] || data_Vue.active_node['Proportion of Male'] < 0 || data_Vue.active_node['Proportion of Male'] > 1)) & data_Vue.warnings.indexOf(gen_warn_text) == -1) {
+ data_Vue.warnings.push(gen_warn_text);
+ }
+ else if ((data_Vue.active_node['Sex'] == "Both" & (data_Vue.active_node['Proportion of Male'] != "" & data_Vue.active_node['Proportion of Male'] >= 0 & data_Vue.active_node['Proportion of Male'] <= 1)) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+ else if (data_Vue.active_node['Sex'] != "Both" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ }
+
+
+ if(id == "edge-popUp"){
+
+ gen_warn_text = "The parent node of a selection edge should contain at least as many individuals as the child node. ";
+ if (data_Vue.active_edge['Breeding Type'] == "Selection" & (data_Vue.nodes.get(data_Vue.active_edge.from)['Number of Individuals'] < data_Vue.nodes.get(data_Vue.active_edge.to)['Number of Individuals']) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ }else if(data_Vue.active_edge['Breeding Type'] == "Selection" & (data_Vue.nodes.get(data_Vue.active_edge.from)['Number of Individuals'] >= data_Vue.nodes.get(data_Vue.active_edge.to)['Number of Individuals']) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }else if(data_Vue.active_edge['Breeding Type'] != "Selection" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+
+ gen_warn_text = "The parent node of a Aging edge should contain at least as many individuals as the child node. ";
+ if (data_Vue.active_edge['Breeding Type'] == "Aging" & (data_Vue.nodes.get(data_Vue.active_edge.from)['Number of Individuals'] < data_Vue.nodes.get(data_Vue.active_edge.to)['Number of Individuals']) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ }else if(data_Vue.active_edge['Breeding Type'] == "Aging" & (data_Vue.nodes.get(data_Vue.active_edge.from)['Number of Individuals'] >= data_Vue.nodes.get(data_Vue.active_edge.to)['Number of Individuals']) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }else if(data_Vue.active_edge['Breeding Type'] != "Aging" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+
+ gen_warn_text = "The parent node of a repeat edge should contain the same number of individuals as the child node. ";
+ if (data_Vue.active_edge['Breeding Type'] == "Repeat" & (data_Vue.nodes.get(data_Vue.active_edge.from)['Number of Individuals'] != data_Vue.nodes.get(data_Vue.active_edge.to)['Number of Individuals']) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ }else if(data_Vue.active_edge['Breeding Type'] == "Repeat" & (data_Vue.nodes.get(data_Vue.active_edge.from)['Number of Individuals'] == data_Vue.nodes.get(data_Vue.active_edge.to)['Number of Individuals']) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }else if(data_Vue.active_edge['Breeding Type'] != "Repeat" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Please select Selection type. ";
+ if ((data_Vue.active_edge['Breeding Type'] == "Selection" & data_Vue.active_edge['Selection Type'] == "") & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ }else if((data_Vue.active_edge['Breeding Type'] == "Selection" & data_Vue.active_edge['Selection Type'] != "")& data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }else if(data_Vue.active_edge['Breeding Type'] != "Selection" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Please enter Time needed for Selection. And it must be a positive number";
+ if ((data_Vue.active_edge['Breeding Type'] == "Selection" & data_Vue.active_edge['Time Needed'] == null || data_Vue.active_edge['Time Needed'] < 0 || isNaN(data_Vue.active_edge['Time Needed'])) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ }else if(((data_Vue.active_edge['Breeding Type'] == "Selection" & data_Vue.active_edge['Time Needed'] != null) & data_Vue.active_edge['Time Needed'] >= 0) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ } else if(data_Vue.active_edge['Breeding Type'] != "Selection" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Please select Relationship Matrix for Selection type BVE. ";
+ if (((data_Vue.active_edge['Breeding Type'] == "Selection" & data_Vue.active_edge['Selection Type'] == "BVE") & !data_Vue.active_edge['Relationship Matrix']) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ }else if(((data_Vue.active_edge['Breeding Type'] == "Selection" & data_Vue.active_edge['Selection Type'] != "") & data_Vue.active_edge['Relationship Matrix'] != "") & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }else if(data_Vue.active_edge['Breeding Type'] != "Selection" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Please select BVE Method for Selection type BVE. ";
+ if (((data_Vue.active_edge['Breeding Type'] == "Selection" & data_Vue.active_edge['Selection Type'] == "BVE") & !data_Vue.active_edge['BVE Method']) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ }else if(((data_Vue.active_edge['Breeding Type'] == "Selection" & data_Vue.active_edge['Selection Type'] != "") & data_Vue.active_edge['BVE Method'] != "") & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }else if(data_Vue.active_edge['Breeding Type'] != "Selection" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Please enter Depth of Pedigree. And it is a Number ";
+ if ((data_Vue.active_edge['Breeding Type'] == "Selection" & data_Vue.active_edge['Selection Type'] == "BVE" & data_Vue.active_edge['Relationship Matrix'] == "Pedigree") & (!data_Vue.active_edge['Depth of Pedigree'] || isNaN(data_Vue.active_edge['Depth of Pedigree'])) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ }else if(((data_Vue.active_edge['Breeding Type'] == "Selection" & data_Vue.active_edge['Selection Type'] == "BVE" & data_Vue.active_edge['Relationship Matrix'] == "Pedigree") & data_Vue.active_edge['Depth of Pedigree'] != "" & data_Vue.active_edge['Depth of Pedigree'] >= 0 ) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }else if(((data_Vue.active_edge['Breeding Type'] == "Selection" & data_Vue.active_edge['Selection Type'] == "BVE" & data_Vue.active_edge['Relationship Matrix'] != "Pedigree") || (data_Vue.active_edge['Depth of Pedigree'] == "" || data_Vue.active_edge['Depth of Pedigree'] != "" || data_Vue.active_edge['Depth of Pedigree'] >= 0 )) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }else if((data_Vue.active_edge['Breeding Type'] != "Selection" & data_Vue.active_edge['Selection Type'] == "BVE" & data_Vue.active_edge['Relationship Matrix'] == "Pedigree") & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Please enter Depth of Pedigree for Single Step. And it is a Number ";
+ if ((data_Vue.active_edge['Breeding Type'] == "Selection" & data_Vue.active_edge['Selection Type'] == "BVE" & data_Vue.active_edge['Relationship Matrix'] == "Single Step") & (!data_Vue.active_edge['Depth of Pedigree'] || isNaN(data_Vue.active_edge['Depth of Pedigree'])) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ }else if(((data_Vue.active_edge['Breeding Type'] == "Selection" & data_Vue.active_edge['Selection Type'] == "BVE" & data_Vue.active_edge['Relationship Matrix'] == "Single Step") & data_Vue.active_edge['Depth of Pedigree'] != "" & data_Vue.active_edge['Depth of Pedigree'] >= 0 ) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }else if((data_Vue.active_edge['Breeding Type'] != "Selection" & data_Vue.active_edge['Selection Type'] != "BVE" || data_Vue.active_edge['Relationship Matrix'] == "Single Step" || data_Vue.active_edge['Relationship Matrix'] != "Single Step") & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+
+ gen_warn_text = "Please select Cohorts Used in BVE for Selection type BVE. ";
+ if (((data_Vue.active_edge['Breeding Type'] == "Selection" & data_Vue.active_edge['Selection Type'] == "BVE") & !data_Vue.active_edge['Cohorts used in BVE']) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ }else if(((data_Vue.active_edge['Breeding Type'] == "Selection" & data_Vue.active_edge['Selection Type'] == "BVE") & data_Vue.active_edge['Cohorts used in BVE'] != "") & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }else if(data_Vue.active_edge['Breeding Type'] != "Selection" & data_Vue.active_edge['Selection Type'] == "BVE" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Please enter Time needed for Reproduction. It must be a positive number";
+ if (data_Vue.active_edge['Breeding Type'] == "Reproduction" & ( data_Vue.active_edge['Time Needed'] == null || data_Vue.active_edge['Time Needed'] <0 || isNaN(data_Vue.active_edge['Time Needed'])) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ }else if((data_Vue.active_edge['Breeding Type'] == "Reproduction" & data_Vue.active_edge['Time Needed'] !=null & data_Vue.active_edge['Time Needed'] >=0) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ } else if(data_Vue.active_edge['Breeding Type'] != "Reproduction" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Please select id for Reproduction. ";
+ if (data_Vue.active_edge['Breeding Type'] == "Reproduction" & (data_Vue.active_edge['id'] == "" || data_Vue.active_edge['id'] <0) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ }else if((data_Vue.active_edge['Breeding Type'] == "Reproduction" & data_Vue.active_edge['id'] !="" & data_Vue.active_edge['Time Needed'] >=0) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ } else if(data_Vue.active_edge['Breeding Type'] != "Reproduction" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Please enter number of repeat for breeding type Repeat. It must be a positive number ";
+ if (data_Vue.active_edge['Breeding Type'] == "Repeat" & (!data_Vue.active_edge['Number of Repeat'] || data_Vue.active_edge['Number of Repeat'] < 0 || isNaN(data_Vue.active_edge['Time Needed'])) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ }else if((data_Vue.active_edge['Breeding Type'] == "Repeat" & data_Vue.active_edge['Number of Repeat'] != "" & data_Vue.active_edge['Number of Repeat'] >=0) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }else if(data_Vue.active_edge['Breeding Type'] != "Repeat" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Please enter Time needed for Cloning. And it must be a positive number";
+ if (data_Vue.active_edge['Breeding Type'] == "Cloning" & (data_Vue.active_edge['Time Needed'] == null || data_Vue.active_edge['Time Needed'] <0 || isNaN(data_Vue.active_edge['Time Needed'])) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ }else if((data_Vue.active_edge['Breeding Type'] == "Cloning" & data_Vue.active_edge['Time Needed'] != null & data_Vue.active_edge['Time Needed'] >=0) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ } else if(data_Vue.active_edge['Breeding Type'] != "Cloning" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Please enter Time needed for Split. And it must be a positive number";
+ if (data_Vue.active_edge['Breeding Type'] == "Split" & (data_Vue.active_edge['Time Needed'] == null || data_Vue.active_edge['Time Needed'] <0 || isNaN(data_Vue.active_edge['Time Needed'])) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ }else if((data_Vue.active_edge['Breeding Type'] == "Split" & data_Vue.active_edge['Time Needed'] != null & data_Vue.active_edge['Time Needed'] >=0) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ } else if(data_Vue.active_edge['Breeding Type'] != "Split" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Please enter Time needed for Selfing. And it must be a positive number";
+ if (data_Vue.active_edge['Breeding Type'] == "Selfing" & (data_Vue.active_edge['Time Needed'] == null || data_Vue.active_edge['Time Needed'] <0 || isNaN(data_Vue.active_edge['Time Needed'])) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ }else if((data_Vue.active_edge['Breeding Type'] == "Selfing" & data_Vue.active_edge['Time Needed'] != null & data_Vue.active_edge['Time Needed'] >=0) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ } else if(data_Vue.active_edge['Breeding Type'] != "Selfing" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Please enter Time needed for Combine. It must be a positive number number";
+ if (data_Vue.active_edge['Breeding Type'] == "Combine" & (data_Vue.active_edge['Time Needed'] == null || data_Vue.active_edge['Time Needed'] <0 || isNaN(data_Vue.active_edge['Time Needed'])) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ }else if((data_Vue.active_edge['Breeding Type'] == "Combine" & data_Vue.active_edge['Time Needed'] != null & data_Vue.active_edge['Time Needed'] >=0) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ } else if(data_Vue.active_edge['Breeding Type'] != "Combine" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Please enter Time needed for DH-Production. And it must be a positive number";
+ if (data_Vue.active_edge['Breeding Type'] == "DH-Production" & (data_Vue.active_edge['Time Needed'] == null || data_Vue.active_edge['Time Needed'] <0 || isNaN(data_Vue.active_edge['Time Needed'])) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ }else if((data_Vue.active_edge['Breeding Type'] == "DH-Production" & data_Vue.active_edge['Time Needed'] != null & data_Vue.active_edge['Time Needed'] >=0) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ } else if(data_Vue.active_edge['Breeding Type'] != "DH-Production" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Please enter Time needed for Aging. And it must be a positive number";
+ if (data_Vue.active_edge['Breeding Type'] == "Aging" & (data_Vue.active_edge['Time Needed'] == null || data_Vue.active_edge['Time Needed'] <0 || isNaN(data_Vue.active_edge['Time Needed'])) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ }else if((data_Vue.active_edge['Breeding Type'] == "Aging" & data_Vue.active_edge['Time Needed'] != null & data_Vue.active_edge['Time Needed'] >=0) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ } else if(data_Vue.active_edge['Breeding Type'] != "Aging" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Please enter Recombination - New Mutation Rate. ";
+ if ((data_Vue.active_edge['Breeding Type'] == "Recombination" & !data_Vue.active_edge['New Mutation Rate']) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ } else if((data_Vue.active_edge['Breeding Type'] == "Recombination" & data_Vue.active_edge['New Mutation Rate'] != "") & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ } else if(data_Vue.active_edge['Breeding Type'] != "Recombination" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+
+ gen_warn_text = "Please enter Recombination - New Remutation Rate. ";
+ if ((data_Vue.active_edge['Breeding Type'] == "Recombination" & !data_Vue.active_edge['New Remutation Rate']) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ } else if((data_Vue.active_edge['Breeding Type'] == "Recombination" & data_Vue.active_edge['New Remutation Rate'] != "") & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ } else if(data_Vue.active_edge['Breeding Type'] != "Recombination" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+
+ gen_warn_text = "Please enter Recombination - Number of Recombination per M. ";
+ if ((data_Vue.active_edge['Breeding Type'] == "Recombination" & !data_Vue.active_edge['Number of Rec per M']) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ }else if((data_Vue.active_edge['Breeding Type'] == "Recombination" & data_Vue.active_edge['Number of Rec per M'] !="") & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ } else if(data_Vue.active_edge['Breeding Type'] != "Recombination" & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Please choose ID of 2.Parent for the Reproduction edge. Please consider that in case of an animal reproduction one parent should be a female and the other parent should be a male.";
+ if (data_Vue.active_edge['Breeding Type'] == "Reproduction" & (data_Vue.geninfo['Species'] == "Chicken" || data_Vue.geninfo['Species'] == "Cattle" || data_Vue.geninfo['Species'] == "Sheep" || data_Vue.geninfo['Species'] == "Pig" || data_Vue.geninfo['Species'] == "Horse" || data_Vue.geninfo['Species'] == "Goat" || data_Vue.geninfo['Species'] == "Human") & document.getElementById("parents_input") == null & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ } else if (data_Vue.active_edge['Breeding Type'] == "Reproduction" & data_Vue.geninfo['Species'] == ("Chicken" || "Cattle" || "Sheep" || "Pig" || "Horse" || "Goat" || "Human" ) & document.getElementById("parents_input") != null & data_Vue.warnings.indexOf(gen_warn_text) > -1) {
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ } else if (data_Vue.active_edge['Breeding Type'] == "Reproduction" & data_Vue.warnings.indexOf(gen_warn_text) > -1) {
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ } else if (data_Vue.active_edge['Breeding Type'] != "Reproduction"& data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+ }
+
+ data_Vue.project_saved = false;
+}
+
+
+ function isNumeric(val) {
+ return !isNaN(parseFloat(val)) && isFinite(val);
+ }
+
+ function isPositiveInteger(val) {
+ var isNumber = Math.floor(Number(val));
+ var thisNumber = (String(isNumber) == val && isNumber >= 0);
+ return thisNumber;
+ }
+
+
+ function isPositiveInt(val) {
+ return val >>> 0 === parseFloat(val);
+ }
+
+
+ function qtlsforPheno(qtlName, qtlCnt) {
+
+ var thisQTL = data_Vue.traitsinfo[qtlName]["Trait QTL Info"];
+ var thisTrait = data_Vue.traitsinfo[qtlName]["Trait Name"];
+
+ for (k=0; k 0 & checkBP == true) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = thisTrait+"-Chromo "+(k+1)+":"+"Please enter chromosomes and must be a Positive Number.";
+ checkchromo = isPositiveInt(thisQTL[k]['QTL Chromosome']);
+ if ((!thisQTL[k]['QTL Chromosome'] || thisQTL[k]['QTL Chromosome'] <= 0 || checkchromo == false) & data_Vue.warnings.indexOf(gen_warn_text) == -1) {
+ data_Vue.warnings.push(gen_warn_text);
+ }
+ else if ((thisQTL[k]['QTL Chromosome'] != "" & thisQTL[k]['QTL Chromosome'] > 0 & checkchromo ==true) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ checkAANumeric = isNumeric(thisQTL[k]['QTL Effect AA']);
+ gen_warn_text = thisTrait+"-EffectAA"+(k+1)+":"+"Please enter Effect AA and must be a Number.";
+ if ((!thisQTL[k]['QTL Effect AA'] || checkAANumeric == false ) & data_Vue.warnings.indexOf(gen_warn_text) == -1) {
+ data_Vue.warnings.push(gen_warn_text);
+ }
+ else if (thisQTL[k]['QTL Effect AA'] != "" & checkAANumeric == true & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ checkABNumeric = isNumeric(thisQTL[k]['QTL Effect AB']);
+ gen_warn_textAB = thisTrait+"-EffectAB"+(k+1)+":"+"Please enter Effect AB and must be a Number.";
+ if ((!thisQTL[k]['QTL Effect AB'] || checkABNumeric == false) & data_Vue.warnings.indexOf(gen_warn_textAB) == -1) {
+ data_Vue.warnings.push(gen_warn_textAB);
+ }
+ else if ((thisQTL[k]['QTL Effect AB'] != "" ) & checkABNumeric == true & data_Vue.warnings.indexOf(gen_warn_textAB) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_textAB),1);
+ }
+
+
+ checkBBNumeric = isNumeric(thisQTL[k]['QTL Effect BB']);
+ gen_warn_textBB = thisTrait+"-EffectBB"+(k+1)+":"+"Please enter Effect BB and must be a Number.";
+ if ((!thisQTL[k]['QTL Effect BB'] || checkBBNumeric == false) & data_Vue.warnings.indexOf(gen_warn_textBB) == -1) {
+ data_Vue.warnings.push(gen_warn_textBB);
+ }
+ else if ((thisQTL[k]['QTL Effect BB'] != "") & checkBBNumeric == true & data_Vue.warnings.indexOf(gen_warn_textBB) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_textBB),1);
+ }
+
+ checkAllele = isNumeric(thisQTL[k]['QTL Allele Frequency']);
+ gen_warn_text = thisTrait+"-Allele Freq "+(k+1)+":"+"Please enter Allele Freq and it must be between 0 and 1.";
+ if ((!thisQTL[k]['QTL Allele Frequency'] || thisQTL[k]['QTL Allele Frequency'] <0 || thisQTL[k]['QTL Allele Frequency'] >1 ) & data_Vue.warnings.indexOf(gen_warn_text) == -1) {
+ data_Vue.warnings.push(gen_warn_text);
+ }
+ else if ((thisQTL[k]['QTL Allele Frequency'] != "" & thisQTL[k]['QTL Allele Frequency'] >=0 & thisQTL[k]['QTL Allele Frequency'] <=1) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ }
+ }
+
+ function matrix1() {
+ var traitsCnt = data_Vue.traitsinfo.length;
+ for(let i=0; i < traitsCnt; i++){
+ for(let j=0; j < data_Vue.matrix[i].row.length; j++){
+ curMatVal = data_Vue.matrix[i].row[j].val;
+
+ gen_warn_text = data_Vue.traitsinfo[i]['Trait Name']+"-"+data_Vue.traitsinfo[j]['Trait Name']+":Please enter Phenotypic Correlation and must be a number between -1 and 1 ";
+
+ if (((!curMatVal & curMatVal == "" & curMatVal !="0") || curMatVal <-1 || curMatVal > 1 || isNaN(curMatVal)) & data_Vue.warnings.indexOf(gen_warn_text) == -1) {
+ data_Vue.warnings.push(gen_warn_text);
+ }
+ else if ((curMatVal != "" & curMatVal >=-1 & curMatVal <=1 & isNaN(curMatVal) == false ) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ }
+ }
+ }
+
+
+ function matrix2() {
+ var traitsCnt = data_Vue.traitsinfo.length;
+ for(let i=0; i < traitsCnt; i++){
+ for(let j=0; j < data_Vue.matrix2[i].row.length; j++){
+ curMatVal2 = data_Vue.matrix2[i].row[j].val;
+
+ gen_warn_text = data_Vue.traitsinfo[i]['Trait Name']+"-"+data_Vue.traitsinfo[j]['Trait Name']+":Please enter Genetic Correlation and must be a number between -1 and 1 ";
+
+ if (((!curMatVal2 & curMatVal2 == "" & curMatVal2 !="0") || curMatVal2 <-1 || curMatVal2 > 1 || isNaN(curMatVal2)) & data_Vue.warnings.indexOf(gen_warn_text) == -1) {
+ data_Vue.warnings.push(gen_warn_text);
+ }
+ else if ((curMatVal2 != "" & curMatVal2 >=-1 & curMatVal2 <=1 & isNaN(curMatVal2) == false ) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ }
+ }
+ }
+
+
+
+ function selection_Index() {
+
+ var traitsCnt = data_Vue.traitsinfo.length;
+ var siCnt = data_Vue.selection_index.length
+
+ if (siCnt > 0) {
+ for(let i=0; i -1) {
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ }
+ }
+ }
+ }
+
+
+
+
+ function phenotyping_classes() {
+ var traitsCnt = data_Vue.traitsinfo.length;
+ var piCnt = data_Vue.phenotyping_class.length
+
+ if (piCnt > 0) {
+ for(let i=0; i=0) & data_Vue.warnings.indexOf(gen_warn_text) > -1) {
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = pName+(i+1)+":Pheno"+(j+1)+": Please enter phenotyping classes and it must be a positive number or zero.";
+ if ((pVar == null || isNaN(pVar) || pVar < 0 || checkpVar == false || checkPospVar == false) & data_Vue.warnings.indexOf(gen_warn_text) == -1) {
+ data_Vue.warnings.push(gen_warn_text);
+ }
+ else if ((pVar != null & pVar >= 0 & checkpVar == true & checkPospVar == true) & data_Vue.warnings.indexOf(gen_warn_text) > -1) {
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+ }
+ }
+ }
+ }
+
+
+
+ function economyWarning() {
+
+ gen_warn_text = "Please enter Fixed Cost must be a number between 0 and 100.";
+
+ curFixedCost = data_Vue.economy['Fixed Cost'];
+
+ if(((!curFixedCost & curFixedCost !=0) || curFixedCost < 0 || curFixedCost > 100 || isNaN(curFixedCost)) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ }
+ else if((curFixedCost != "" & curFixedCost >= 0 & curFixedCost <= 100) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Please enter Interest Rate must be a number.";
+ curInt = data_Vue.economy['Interest Rate'];
+
+ if(((!curInt & curInt !=0) || curInt < 0 || curInt > 100 || isNaN(curInt)) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ }
+ else if((curInt != "" & curInt >= 0 & curInt <= 100) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Please enter Genotyping Cost must be a number. Cost must be less than 100 euros";
+ curGenoType = data_Vue.economy['Genotyping Cost'];
+
+ if(((!curGenoType & curGenoType !=0) || curGenoType < 0 || curGenoType > 100 || isNaN(curGenoType)) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ }
+ else if((curGenoType != "" & curGenoType >= 0 & curGenoType <= 100) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ }
+
+
+function animalHousingCost() {
+
+ var animal_housing_costCnt = data_Vue.economy['Animal Housing Costs'].length;
+ var thisAnimalHousingCosts = data_Vue.economy['Animal Housing Costs'];
+
+ for(let i=0; i < animal_housing_costCnt; i++){
+ thisCost = thisAnimalHousingCosts[i]['Cost'];
+ nameOfCost = thisAnimalHousingCosts[i]['Name'];
+
+ gen_warn_text = nameOfCost+" : "+"Please enter Animal Housing Cost and must be a number.";
+
+ if(((thisCost =="" & thisCost !=0) || thisCost <0 || isNaN(thisCost)) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ }
+ else if(thisCost != "" & thisCost >=0 & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ }
+}
+
+
+function check_eigen(){
+
+}
+
+// this funtion will always be called after an edge has been created,
+// you can use this function to add further services, e.g add the secong parent automatically if Breeding Type == Reproduction etc.
+function addServices(){
+ if(data_Vue.active_edge['Breeding Type'] == "Reproduction"){
+ var val = document.getElementById("parents_input").value ;
+ if(val =='') return;
+ if(data_Vue.nodes.get(val) == null){ // create new node by copying:
+ var p1_node = data_Vue.nodes.get(data_Vue.active_edge.from);
+ p1_node.Sex = p1_node.Sex == "Male" ? "Female" : "Male" ;
+ p1_node.id = val;
+ p1_node.x = p1_node.x+50;
+ addNode_extern(p1_node);
+ }
+ var child_node = data_Vue.nodes.get(data_Vue.active_edge.to);
+ var new_edge = new myEdge(val, child_node.id);
+ new_edge['Breeding Type'] = "Reproduction";
+ new_edge['Time Needed'] = document.getElementById("time_n").value;
+ for(let i=0; i < data_Vue.active_edge.useVar.length; i++){
+ new_edge['useVar'].push(data_Vue.active_edge.useVar[i]);
+ }
+
+ addEdge_extern(new_edge);
+ }
+ if(data_Vue.active_edge['Breeding Type'] == "Split"){
+ var val = document.getElementById("split_input").value ;
+ if(val =='') return;
+ if(data_Vue.nodes.get(val) == null){ // create new node by copying:
+ var p1_node = data_Vue.nodes.get(data_Vue.active_edge.to);
+ p1_node.id = val;
+ p1_node.x = p1_node.x+50;
+ p1_node['Number of Individuals'] = data_Vue.nodes.get(data_Vue.active_edge.from)['Number of Individuals'] - p1_node['Number of Individuals'];
+ p1_node.individualsVar ='';
+ addNode_extern(p1_node);
+ }
+ var parent_node = data_Vue.nodes.get(data_Vue.active_edge.from);
+ var new_edge = new myEdge(parent_node.id, val);
+ new_edge['Breeding Type'] = "Split";
+
+ addEdge_extern(new_edge);
+ }
+}
diff --git a/Rmodule.js b/public/javascript/Rmodule_A.js
similarity index 86%
rename from Rmodule.js
rename to public/javascript/Rmodule_A.js
index 2e722d0..69150fa 100644
--- a/Rmodule.js
+++ b/public/javascript/Rmodule_A.js
@@ -1,1041 +1,1177 @@
-//*************************************************************************************************//
-//*********** Functions for running R Simulation ***********************************//
-function checkRunTime(){
- var nodes = data_Vue.nodes.get();
-
- var nInd = 0;
- var nF = 0;
- for(let i=0;i < nodes.length; i++){
- if(nodes[i].Founder == 'Yes'){
- nF = nF + parseInt(nodes[i]['Number of Individuals']);
- }
- nInd = nInd + parseInt(nodes[i]['Number of Individuals']);
- }
-
- if(data_Vue.geninfo['Chromosomes Info'].length > 0){
- var nsnp = data_Vue.geninfo['Chromosomes Info'][0].Length * data_Vue.geninfo['Chromosomes Info'][0].MD;
- var Morgan = data_Vue.geninfo['Chromosomes Info'][0].Length * data_Vue.geninfo['Chromosomes Info'][0].Recombination /100;
- }else{
- var nsnp = data_Vue.geninfo['Max Number of SNPs'];
- var Morgan = 5;
- }
-
- var edges = data_Vue.edges.get();
- var nRep = 0;
- var nZucht = 0;
- for(let i=0;i < edges.length; i++){
- if(edges[i]['Breeding Type'] == 'Repeat'){
- nRep = edges[i]['Number of Repeat'];
- }
- if(edges[i]['Breeding Type'] == 'Selection' & edges[i]['Selection Type'] == 'BVE'){
- nZucht++;
- }
- }
- console.log(nF);
- console.log(nsnp);
- console.log(nInd);
- var comptime = nF*nsnp/1000000 + 0.0002*nInd*Morgan;
- return comptime;
-}
-
-function runningR(){
-
-
- clearResult();
- data_Vue.plottingData = new myPlottingData();
- var jsondata = JSON.stringify(exportNetwork());
- //console.log(jsondata);
- //alert("Approx. simulation running time: " + Math.round(checkRunTime()/60*2.6*100)/100 + "minutes.");
-
- $.ajax
- ({
- type: "POST",
- url: './Rsim',
- data: {jsondata : jsondata},
- beforeSend: function() {
- document.getElementById("runningDogTitle").innerHTML = 'MoBPS is running .... please wait';
- document.getElementById("runningDog").style.visibility = 'visible';
- //alert("Now Sending!");
- },
- success: function (data, msg) {
- //console.log(data);
- alert("Simulation Finished!");
- data_Vue.runned = true;
- document.getElementById("Rout_Div").innerHTML = data;
- document.getElementById("Rout_Div").innerHTML = document.getElementById("Rout_Div").innerHTML.replace(/Error/g, "Error");
- document.getElementById("Rout_Div").innerHTML = document.getElementById("Rout_Div").innerHTML.replace(/\n/g, " ");
- writeSum();
- },
- error: function(obj, msg, err)
- {
- alert(err);
- },
- complete: function(obj, msg){
- document.getElementById("runningDog").style.visibility = 'hidden';
- //document.getElementById("runningDog").innerHTML = '';
- //alert(msg);
- //console.log(obj);
- },
- dataType: "text",
- });
-}
-
-
-//Running R with streaming
-function runningR1(){
-
- clearResult();
- data_Vue.plottingData = new myPlottingData();
- var jsondata = JSON.stringify(exportNetwork());
- //console.log(jsondata);
- //alert("Approx. simulation running time: " + Math.round(checkRunTime()/60*2.6*100)/100 + "minutes.");
-
- savedNodes = data_Vue.nodes.get();
- var savedNodesLen = savedNodes.length;
- var isFounder = "";
- for(let i=0; i < savedNodesLen; i++){
- var checkFounder = savedNodes[i].Founder;
- if (checkFounder == "Yes") {
- isFounder = "Found";
- }
- }
-
- if(isFounder == ""){
- alert("There is no Founder in the Project. Please add a Founder!");
- }
-
-
- $.ajax
- ({
- type: "POST",
- url: './Rsim1',
- data: {jsondata : jsondata},
- beforeSend: function() {
- document.getElementById("runningDogTitle").innerHTML = 'MoBPS is running .... please wait';
- document.getElementById("runningDog").style.visibility = 'visible';
- if(data_Vue.socket == ''){
- data_Vue.socket = io();
- data_Vue.socket.on(data_Vue.user, function(d){
- document.getElementById("runningDogLog").innerHTML += d + " ";
- })
- }
- //alert("Now Sending!");
- },
- success: function (data, msg) {
- //console.log(data);
- alert("Simulation Finished!");
- data_Vue.runned = true;
- document.getElementById("Rout_Div").innerHTML = data;
- document.getElementById("Rout_Div").innerHTML = document.getElementById("Rout_Div").innerHTML.replace(/Error/g, "Error");
- document.getElementById("Rout_Div").innerHTML = document.getElementById("Rout_Div").innerHTML.replace(/\n/g, " ");
- writeSum();
- },
- error: function(obj, msg, err)
- {
- alert(err);
- },
- complete: function(obj, msg){
- document.getElementById("runningDog").style.visibility = 'hidden';
- document.getElementById("runningDogLog").innerHTML = '';
- //alert(msg);
- //console.log(obj);
- },
- dataType: "text",
- });
-}
-
-function ReloadSim(){
- var filename = data_Vue.geninfo["Project Name"];
- //var cohorts = data_Vue.plottingPar.ResgMean_cohorts;
-
- $.ajax
- ({
- type: "POST",
- url: './RsimResult',
- data: {
- filename : filename,
- script: "ReloadSim"
- },
- beforeSend: function() {
- document.getElementById("runningDogTitle").innerHTML = 'Getting Old Results...';
- document.getElementById("runningDog").style.visibility = 'visible';
- //alert("Now Sending!");
- },
- success: function (data, msg) {
- data_Vue.runned = true;
- console.log(data);
- document.getElementById("Rout_Div").innerHTML = data;
- document.getElementById("Rout_Div").innerHTML = document.getElementById("Rout_Div").innerHTML.replace(/Error/g, "Error");
- document.getElementById("Rout_Div").innerHTML = document.getElementById("Rout_Div").innerHTML.replace(/\n/g, " ");
- writeSum();
- },
- failure: function(msg)
- {
- alert("Failed to plot KS. Please run the Simulation first!");
- },
- complete: function(obj, msg){
- document.getElementById("runningDog").style.visibility = 'hidden';
- //document.getElementById("runningDog").innerHTML = '';
- //alert(msg);
- //console.log(obj);
- },
- dataType: "text",
- });
-}
-
-$(document).ready(function(){
- $("#ResultUpload").on('change',function(){
- UploadSim();
- });
-});
-
-function UploadSim(){
- var filename = document.getElementById('ResultFile').files[0].name
- //var cohorts = data_Vue.plottingPar.ResgMean_cohorts;
- console.log(filename);
- data_Vue.geninfo['Project Name'] = filename;
-
- $.ajax
- ({
- type: "POST",
- url: './RsimResult',
- data: {
- filename : filename,
- script: "ReloadSim"
- },
- beforeSend: function() {
- document.getElementById("runningDogTitle").innerHTML = 'Getting Old Results...';
- document.getElementById("runningDog").style.visibility = 'visible';
- //alert("Now Sending!");
- },
- success: function (data, msg) {
- data_Vue.runned = true;
- //console.log(data);
- document.getElementById("Rout_Div").innerHTML = data;
- document.getElementById("Rout_Div").innerHTML = document.getElementById("Rout_Div").innerHTML.replace(/Error/g, "Error");
- document.getElementById("Rout_Div").innerHTML = document.getElementById("Rout_Div").innerHTML.replace(/\n/g, " ");
- writeSum();
- },
- failure: function(msg)
- {
- alert("Failed to plot KS. Please run the Simulation first!");
- },
- complete: function(obj, msg){
- document.getElementById("runningDog").style.visibility = 'hidden';
- //document.getElementById("runningDog").innerHTML = '';
- //alert(msg);
- //console.log(obj);
- },
- dataType: "text",
- });
-}
-
-function stopR(){
- var r = confirm("The R process will be stopped and data in R will be lost. Do you want to proceed?");
- if(r){
- $.ajax
- ({
- type: "POST",
- url: './StopR',
- success: function (msg) {
- document.getElementById("runningDog").style.visibility = 'hidden';
- document.getElementById("runningDogLog").innerHTML = '';
- },
- error: function(obj, msg, err)
- {
- alert(err);
- },
- dataType: "text",
- });
- }
-}
-
-function writeSum(){
- var file = data_Vue['geninfo']['Project Name'] + 'Summary';
-
- $.ajax
- ({
- type: "POST",
- url: './JSON',
- data: {file : file},
- success: function (data, msg) {
- //console.log(data);
- data_Vue.plottingData.Summary = JSON.parse(data);
- data = data_Vue.plottingData.Summary;
- data_Vue.Summary = Object.keys(data_Vue.plottingData.Summary).map(function(x){return({id: x, label: x+" ("+(data_Vue.plottingData.Summary[x].trep -1)+" Repeats)"})});
- var el = document.getElementById("Result_Summary");
- el.innerHTML = "==> " + "Project " + data_Vue.geninfo["Project Name"]+ " successfully processed in R." + " ";
- el.innerHTML += " Founders: " + " ";
- for(let key in data){
- console.log(key);
- if(data[key].tfounder[0]){
- el.innerHTML += "==> Cohort " + key + " with " + (data[key].trep[0] - 1) + " repetitions. ";
- }
- }
- el.innerHTML += " Non-founders: " + " ";
- for(let key in data){
- if(!data[key].tfounder[0]){
- el.innerHTML += "==> Cohort " + key + " with " + (data[key].trep[0] - 1) + " repetitions. ";
- }
- }
-
- },
- error: function(obj, msg, err)
- {
- alert(err);
- },
- dataType: "text",
- });
-}
-
-//*************************************************************************************************//
-//*********** Functions for plotting results after R Simulation ***********************************//
-// ---- Plotting observed Phenotypes Mean:
-function plottingResultpMean(){
- var data = data_Vue.plottingData.RespMean;
- var coh = data_Vue.plottingPar.RespMean_cohorts;
- var pType = data_Vue.plottingPar.RespMean_pType;
-
- var data1 = [];
- for(let i=0; i< data_Vue.traitsinfo.length; i++){
- data1.push([]);
- }
-
- if(pType=="By Repeats"){
- // each cohort
- for(let i=0; i < coh.length; i++){
- // each trait:
- for(let j=0; j< data_Vue.traitsinfo.length; j++){
- data1[j].push({
- y : Object.values(data[coh[i]]).map(function(x){return(math.mean(x.tval[j]))}),
- x : Object.keys(data[coh[i]]),
- mode : 'scatter',
- name : coh[i]
- });
- }
- }
- var xtitle = 'Repeats';
- }
- if(pType=="By Cohorts"){
- // each cohort
- for(let i=0; i < coh.length; i++){
- var red = ((Math.floor(i/3)+1)*85)%255;
- var green = ((Math.floor(i/6)+1)*85)%255;
- var blue = ((i+1)*85)%255;
- // each rep:
- var ttimes = Object.keys(data[coh[i]]);
- for(let k=0; k < ttimes.length; k++){
- // eacht trait
- for(let j=0; j< data_Vue.traitsinfo.length; j++){
- data1[j].push({
- y : data[coh[i]][ttimes[k]].tval[j],
- name : coh[i]+'_'+ttimes[k],
- marker : {color: "rgb("+red+","+green+","+blue+")"},
- type: 'box',
- boxpoints : 'Outliers',
- boxmean : true
- });
- }
- }
- }
- var xtitle = 'Cohorts (trailing numbers denote repeated cohorts)';
- }
- if(pType=="By Time"){
- // each cohort
- for(let i=0; i < coh.length; i++){
- // each trait:
- for(let j=0; j< data_Vue.traitsinfo.length; j++){
- data1[j].push({
- y : Object.values(data[coh[i]]).map(function(x){return(math.mean(x.tval[j]))}),
- x : Object.values(data[coh[i]]).map(function(x){return(math.mean(x.ttime[0]))}),
- mode : 'scatter',
- name : coh[i]
- });
- }
- }
- var xtitle = 'Time in '+data_Vue.geninfo['Time Unit'];
- }
-
- //console.log(data);
- var titles = data_Vue.traitsinfo.map(function(x){return(x['Trait Name'])});
- for(let i=0; i < data_Vue.traitsinfo.length; i++){
- var layout = {
- title : titles[i],
- showlegend: pType != 'By Cohorts',
- plot_bgcolor: '#FFFFFF',
- xaxis: {
- title: xtitle,
- zeroline: false,
- automargin: true
- },
- };
- var config = {
- scrollZoom: true,
- toImageButtonOptions: {
- format: 'png', // one of png, svg, jpeg, webp
- filename: 'custom_image',
- height: 750,
- width: 1500,
- scale: 0.8 // Multiply title/legend/axis/canvas sizes by this factor
- }
- };
- Plotly.newPlot('RespMean_Div'+(i+1), data1[i], layout, config);
- }
-}
-
-function RunResultpMean(){
- var filename = data_Vue.geninfo["Project Name"];
- //var cohorts = data_Vue.plottingPar.ResgMean_cohorts;
-
- $.ajax
- ({
- type: "POST",
- url: './RsimResult',
- data: {
- filename : filename,
- script: "pMean"
- },
- beforeSend: function() {
- document.getElementById("runningDogTitle").innerHTML = 'Calculating Results for observed Phenotypes...';
- document.getElementById("runningDog").style.visibility = 'visible';
- //alert("Now Sending!");
- },
- success: function (data, msg) {
- if(data != ''){
- //console.log(data);
- data_Vue.plottingData.RespMean = JSON.parse(data);
- //plottingResultgMean(JSON.parse(data));
- }else{
- alert("Failed to plot KS. Please run the Simulation first! here");
- }
- },
- failure: function(msg)
- {
- alert("Failed to plot KS. Please run the Simulation first!");
- },
- complete: function(obj, msg){
- document.getElementById("runningDog").style.visibility = 'hidden';
- //document.getElementById("runningDog").innerHTML = '';
- //alert(msg);
- //console.log(obj);
- },
- dataType: "text",
- });
-}
-
-// ---- Plotting genotypic Mean:
-function plottingResultgMean(){
- var data = data_Vue.plottingData.ResgMean;
- var coh = data_Vue.plottingPar.ResgMean_cohorts;
- var pType = data_Vue.plottingPar.ResgMean_pType;
-
- var data1 = [];
- for(let i=0; i< data_Vue.traitsinfo.length; i++){
- data1.push([]);
- }
-
- if(pType=="By Repeats"){
- // each cohort
- for(let i=0; i < coh.length; i++){
- // each trait:
- for(let j=0; j< data_Vue.traitsinfo.length; j++){
- data1[j].push({
- y : Object.values(data[coh[i]]).map(function(x){return(math.mean(x.tval[j]))}),
- x : Object.keys(data[coh[i]]),
- mode : 'scatter',
- name : coh[i]
- });
- }
- }
- var xtitle = 'Repeats';
- }
- if(pType=="By Cohorts"){
- // each cohort
- for(let i=0; i < coh.length; i++){
- var red = ((Math.floor(i/3)+1)*85)%255;
- var green = ((Math.floor(i/6)+1)*85)%255;
- var blue = ((i+1)*85)%255;
- // each rep:
- var ttimes = Object.keys(data[coh[i]]);
- for(let k=0; k < ttimes.length; k++){
- // eacht trait
- for(let j=0; j< data_Vue.traitsinfo.length; j++){
- data1[j].push({
- y : data[coh[i]][ttimes[k]].tval[j],
- name : coh[i]+'_'+ttimes[k],
- marker : {color: "rgb("+red+","+green+","+blue+")"},
- type: 'box',
- boxpoints : 'Outliers',
- boxmean : true
- });
- }
- }
- }
- var xtitle = 'Cohorts (trailing numbers denote repeated cohorts)';
- }
- if(pType=="By Time"){
- // each cohort
- for(let i=0; i < coh.length; i++){
- // each trait:
- for(let j=0; j< data_Vue.traitsinfo.length; j++){
- data1[j].push({
- y : Object.values(data[coh[i]]).map(function(x){return(math.mean(x.tval[j]))}),
- x : Object.values(data[coh[i]]).map(function(x){return(math.mean(x.ttime[0]))}),
- mode : 'scatter',
- name : coh[i]
- });
- }
- }
- var xtitle = 'Time in '+data_Vue.geninfo['Time Unit'];
- }
-
- var titles = data_Vue.traitsinfo.map(function(x){return(x['Trait Name'])});
- for(let i=0; i < data_Vue.traitsinfo.length; i++){
- var layout = {
- title : titles[i],
- showlegend: pType != 'By Cohorts',
- plot_bgcolor: '#FFFFFF',
- xaxis: {
- title: xtitle,
- zeroline: false,
- automargin: true
- },
- };
- var config = {
- scrollZoom: true,
- toImageButtonOptions: {
- format: 'png', // one of png, svg, jpeg, webp
- filename: 'custom_image',
- height: 750,
- width: 1500,
- scale: 0.8 // Multiply title/legend/axis/canvas sizes by this factor
- }
- };
- Plotly.newPlot('ResgMean_Div'+(i+1), data1[i], layout, config);
- }
-}
-
-function RunResultgMean(){
- var filename = data_Vue.geninfo["Project Name"];
- //var cohorts = data_Vue.plottingPar.ResgMean_cohorts;
-
- $.ajax
- ({
- type: "POST",
- url: './RsimResult',
- data: {
- filename : filename,
- script: "gMean"
- },
- beforeSend: function() {
- document.getElementById("runningDogTitle").innerHTML = 'Calculating Results for genomic breeding values...';
- document.getElementById("runningDog").style.visibility = 'visible';
- //alert("Now Sending!");
- },
- success: function (data, msg) {
- if(data != ''){
- //console.log(data);
- data_Vue.plottingData.ResgMean = JSON.parse(data);
- //plottingResultgMean(JSON.parse(data));
- }else{
- alert("Failed to plot KS. Please run the Simulation first!");
- }
- },
- failure: function(msg)
- {
- alert("Failed to plot KS. Please run the Simulation first!");
- },
- complete: function(obj, msg){
- document.getElementById("runningDog").style.visibility = 'hidden';
- //document.getElementById("runningDog").innerHTML = '';
- //alert(msg);
- //console.log(obj);
- },
- dataType: "text",
- });
-}
-
-
-// ---- Plotting Relationship:
-function plottingResultRel(){
- var data = data_Vue.plottingData.ResRel;
- var coh = data_Vue.plottingPar.ResRel_cohorts;
- var pType = data_Vue.plottingPar.ResRel_pType;
- var data1 = [[],[]];// Relationship and Inbreeding
-
- if(pType=="By Repeats"){
- // each cohort
- for(let i=0; i < coh.length; i++){
- // each value:
- for(let j=0; j< data1.length; j++){
- data1[j].push({
- y : data[coh[i]][3+j],
- x : data[coh[i]][1],
- mode : 'scatter',
- name : coh[i]
- });
- }
- }
- var xtitle = 'Repeats';
- }
- if(pType=="By Cohorts"){
- var data1 = [[{}],[{}]];// Relationship and Inbreeding
- // each cohort
- for(let j=0; j< data1.length; j++){
- data1[j][0].y = [];
- data1[j][0].x = [];
- data1[j][0].type = "bar";
- for(let i=0; i < coh.length; i++){
- var red = ((Math.floor(i/3)+1)*85)%255;
- var green = ((Math.floor(i/6)+1)*85)%255;
- var blue = ((i+1)*85)%255;
- // each value
- var ttimes = data[coh[i]][1];
- for(let k=0; k< ttimes.length; k++){
- data1[j][0].y.push(Number(data[coh[i]][3+j][k]));
- data1[j][0].x.push(coh[i] +'_'+ ttimes[k]);
- }
-
- }
- }
- //console.log(data1);
- var xtitle = 'Cohorts (trailing numbers denote repeated cohorts)';
- }
- if(pType=="By Time"){
- // each cohort
- for(let i=0; i < coh.length; i++){
- // each value:
- for(let j=0; j< data1.length; j++){
- data1[j].push({
- y : data[coh[i]][3+j],
- x : data[coh[i]][2],
- mode : 'scatter',
- name : coh[i]
- });
- }
- }
- var xtitle = 'Time in '+data_Vue.geninfo['Time Unit'];
- }
-
- var titles = ["Average Relationship within Cohorts", "Average Inbreeding within Cohorts"];
- for(let i=0; i < data1.length; i++){
- var layout = {
- title : titles[i],
- showlegend: pType != 'By Cohorts',
- plot_bgcolor: '#FFFFFF',
- xaxis: {
- title: xtitle,
- zeroline: false,
- automargin: true
- },
- };
- var config = {
- scrollZoom: true,
- toImageButtonOptions: {
- format: 'png', // one of png, svg, jpeg, webp
- filename: 'custom_image',
- height: 750,
- width: 1500,
- scale: 0.8 // Multiply title/legend/axis/canvas sizes by this factor
- }
- };
- Plotly.newPlot('ResRel_Div'+(i+1), data1[i], layout, config);
- }
-}
-
-function RunResultRel(){
- var filename = data_Vue.geninfo["Project Name"];
- //var cohorts = data_Vue.plottingPar.ResgMean_cohorts;
-
- $.ajax
- ({
- type: "POST",
- url: './RsimResult',
- data: {
- filename : filename,
- script: "Rel"
- },
- beforeSend: function() {
- document.getElementById("runningDogTitle").innerHTML = 'Calculating Results for Relationship within Cohorts...';
- document.getElementById("runningDog").style.visibility = 'visible';
- //alert("Now Sending!");
- },
- success: function (data, msg) {
- if(data != ''){
- //console.log(data);
- data_Vue.plottingData.ResRel = JSON.parse(data);
- //plottingResultgMean(JSON.parse(data));
- }else{
- alert("Failed to plot KS. Please run the Simulation first!");
- }
- },
- failure: function(msg)
- {
- alert("Failed to plot KS. Please run the Simulation first!");
- },
- complete: function(obj, msg){
- document.getElementById("runningDog").style.visibility = 'hidden';
- //document.getElementById("runningDog").innerHTML = '';
- //alert(msg);
- //console.log(obj);
- },
- dataType: "text",
- });
-}
-
-// ---- Plotting Relationship between Cohorts:
-function plottingResultRelbetweenC(){
- var data = data_Vue.plottingData.ResRelbetweenC;
- var coh1 = data_Vue.plottingPar.ResRelbetweenC_cohort1;
- var coh2 = data_Vue.plottingPar.ResRelbetweenC_cohort2;
-
- // average relationship between cohorts:
- var data1 = [{
- y: data[coh1] ? data[coh1][coh2] : data[coh2][coh1],
- mode : 'scatter',
- }];
- if(data1[0].y == undefined){
- data1[0].y = data[coh2][coh1];
- }
- data1[0].x = data1[0].y.map(function(x, index){return(index)});
- var layout = {
- title : 'Relationship between '+ coh1 +' and '+coh2,
- showlegend: false,
- plot_bgcolor: '#FFFFFF',
- xaxis: {
- title: 'Repeats',
- zeroline: false,
- automargin: true
- },
- };
- var config = {
- scrollZoom: true,
- toImageButtonOptions: {
- format: 'png', // one of png, svg, jpeg, webp
- filename: 'custom_image',
- height: 750,
- width: 1500,
- scale: 0.8 // Multiply title/legend/axis/canvas sizes by this factor
- }
- };
- Plotly.newPlot('ResRelbetweenC_Div1', data1, layout, config);
-}
-
-function RunResultRelbetweenC(){
- var filename = data_Vue.geninfo["Project Name"];
- //var cohorts = data_Vue.plottingPar.ResgMean_cohorts;
-
- $.ajax
- ({
- type: "POST",
- url: './RsimResult',
- data: {
- filename : filename,
- script: "RelbetweenC"
- },
- beforeSend: function() {
- document.getElementById("runningDogTitle").innerHTML = 'Calculating Results for Relationship between Cohorts...';
- document.getElementById("runningDog").style.visibility = 'visible';
- //alert("Now Sending!");
- },
- success: function (data, msg) {
- if(data != ''){
- //console.log(data);
- data_Vue.plottingData.ResRelbetweenC = JSON.parse(data);
- //plottingResultgMean(JSON.parse(data));
- }else{
- alert("Failed to plot KS. Please run the Simulation first!");
- }
- },
- failure: function(msg)
- {
- alert("Failed to plot KS. Please run the Simulation first!");
- },
- complete: function(obj, msg){
- document.getElementById("runningDog").style.visibility = 'hidden';
- //document.getElementById("runningDog").innerHTML = '';
- //alert(msg);
- //console.log(obj);
- },
- dataType: "text",
- });
-}
-
-// ---- Plotting QTL:
-function plottingResultQTL(){
- var data1 = [[],[],[]];
- var trait = data_Vue.plottingPar.ResQTL_trait-1;
- var qtl = data_Vue.plottingPar.ResQTL_qtl;
- var coh = data_Vue.plottingPar.ResQTL_cohorts;
-
- var data = data_Vue.plottingData.ResQTL[data_Vue.traitsinfo[trait]['Trait Name']][qtl];
-
- for(let i=0; i < coh.length; i++){
- // allele frequency:
- data1[0].push({
- y : data[coh[i]][2],
- x : data[coh[i]][1],
- mode : 'scatter',
- name : coh[i]
- });
- // observed He:
- data1[1].push({
- y : data[coh[i]][3],
- x : data[coh[i]][1],
- mode : 'scatter',
- name : coh[i]
- });
- // expected He:
- data1[2].push({
- y : data[coh[i]][4],
- x : data[coh[i]][1],
- mode : 'scatter',
- name : coh[i]
- });
- }
-
- var titles = ["Allele Frequency (A)", "Observed Heterozygosity", "Expected Heterozygosity"];
- for(let i=0; i < 3; i++){
- var layout = {
- title : titles[i],
- showlegend: true,
- plot_bgcolor: '#FFFFFF',
- xaxis: {
- title: 'Repeats',
- zeroline: false,
- automargin: true
- },
- };
- var config = {
- scrollZoom: true,
- toImageButtonOptions: {
- format: 'png', // one of png, svg, jpeg, webp
- filename: 'custom_image',
- height: 750,
- width: 1500,
- scale: 0.8 // Multiply title/legend/axis/canvas sizes by this factor
- }
- };
- Plotly.newPlot('ResQTL_Div'+(i+1), data1[i], layout, config);
- }
-}
-
-function RunResultQTL(){
- var filename = data_Vue.geninfo["Project Name"];
- var qtl = 0;
- for(let i=0; i< data_Vue.traitsinfo.length; i++){
- qtl += data_Vue.traitsinfo[i]["Trait Major QTL"];
- }
- if(qtl == 0){
- alert("There is no QTL to calculate results for.");
- return;
- }
-
- $.ajax
- ({
- type: "POST",
- url: './RsimQTL',
- data: {
- filename : filename,
- traitsinfo : data_Vue.traitsinfo
- },
- beforeSend: function() {
- document.getElementById("runningDogTitle").innerHTML = 'Calculating Results for QTLs';
- document.getElementById("runningDog").style.visibility = 'visible';
- //alert("Now Sending!");
- },
- success: function (data, msg) {
- if(data != ''){
- //console.log(data);
- data_Vue.plottingData.ResQTL = JSON.parse(data);
- //plottingResultQTL(JSON.parse(data));
- }else{
- alert("Failed to plot KS. Please run the Simulation first!");
- }
- },
- failure: function(msg)
- {
- alert("Failed to plot KS. Please run the Simulation first!");
- },
- complete: function(obj, msg){
- document.getElementById("runningDog").style.visibility = 'hidden';
- //document.getElementById("runningDog").innerHTML = '';
- //alert(msg);
- //console.log(obj);
- },
- dataType: "text",
- });
-}
-
-// ---- Plotting Accuracy of Breeding Value Estimation:
-function plottingResultAccBVE(){
- var data = data_Vue.plottingData.ResAccBVE;
- var coh = data_Vue.plottingPar.ResAccBVE_cohorts;
- var pType = data_Vue.plottingPar.ResAccBVE_pType;
- var sindex = data_Vue.selection_index;
- var data1 = [];
- for(let i=0;i < sindex.length; i++){
- data1.push([]);
- }
-
- if(pType=="By Repeats"){
- // each cohort
- for(let i=0; i < coh.length; i++){
- // each value:
- for(let j=0; j< data1.length; j++){
- data1[j].push({
- y : Object.values(data[coh[i]]).map(function(x){return(Number(x.tval[j]))}),
- x : Object.keys(data[coh[i]]),
- mode : 'scatter',
- name : coh[i]
- });
- }
- }
- var xtitle = 'Repeats';
- }
- if(pType=="By Cohorts"){
- var data1 = [];
- for(let i=0;i < sindex.length; i++){
- data1.push([{}]);
- } // Relationship and Inbreeding
- // each cohort
- for(let j=0; j< data1.length; j++){
- data1[j][0].y = [];
- data1[j][0].x = [];
- data1[j][0].type = "bar";
- for(let i=0; i < coh.length; i++){
- // each value
- var ttimes = Object.keys(data[coh[i]]);
- for(let k=0; k< ttimes.length; k++){
- data1[j][0].y.push(Number(Object.values(data[coh[i]])[k].tval[j]));
- data1[j][0].x.push(coh[i] + "_"+ ttimes[k]);
- }
-
- }
- }
- //console.log(data1);
- var xtitle = 'Cohorts (trailing numbers denote repeated cohorts)';
- }
- if(pType=="By Time"){
- // each cohort
- for(let i=0; i < coh.length; i++){
- // each value:
- for(let j=0; j< data1.length; j++){
- data1[j].push({
- y : Object.values(data[coh[i]]).map(function(x){return(Number(x.tval[j]))}),
- x : Object.values(data[coh[i]]).map(function(x){return(x.ttime[0])}),
- mode : 'scatter',
- name : coh[i]
- });
- }
- }
- var xtitle = 'Time in '+data_Vue.geninfo['Time Unit'];
- }
-
- var titles = sindex.map(function(x){return(x['Name'])});
- for(let i=0; i < data1.length; i++){
- var layout = {
- title : titles[i],
- showlegend: pType != 'By Cohorts',
- plot_bgcolor: '#FFFFFF',
- xaxis: {
- title: xtitle,
- zeroline: false,
- automargin: true
- },
- yaxis: {
- title: "Correlation of True BV and EBV/Phenotype",
- zeroline: false,
- automargin: true
- },
- };
- var config = {
- scrollZoom: true,
- toImageButtonOptions: {
- format: 'png', // one of png, svg, jpeg, webp
- filename: 'custom_image',
- height: 750,
- width: 1500,
- scale: 0.8 // Multiply title/legend/axis/canvas sizes by this factor
- }
- };
- Plotly.newPlot('ResAccBVE_Div'+(i+1), data1[i], layout, config);
- }
-}
-
-
-function RunResultAccBVE(){
- var filename = data_Vue.geninfo["Project Name"];
- var sindex = data_Vue.selection_index;
-
- $.ajax
- ({
- type: "POST",
- url: './RsimAccBVE',
- data: {
- filename : filename,
- sindex : sindex
- },
- beforeSend: function() {
- document.getElementById("runningDogTitle").innerHTML = 'Calculating Results for Accuracy of Breeding Value Estimations...';
- document.getElementById("runningDog").style.visibility = 'visible';
- //alert("Now Sending!");
- },
- success: function (data, msg) {
- if(data != ''){
- //console.log(data);
- data_Vue.plottingData.ResAccBVE = JSON.parse(data);
- data_Vue.Summary_AccBVE = data_Vue.Summary.filter(function(x){
- return(data_Vue.plottingData.ResAccBVE[x.id][0].tval != "NA");
- });
- //plottingResultQTL(JSON.parse(data));
- }else{
- alert("Failed to plot KS. Please run the Simulation first!");
- }
- },
- failure: function(msg)
- {
- alert("Failed to plot KS. Please run the Simulation first!");
- },
- complete: function(obj, msg){
- document.getElementById("runningDog").style.visibility = 'hidden';
- //document.getElementById("runningDog").innerHTML = '';
- //alert(msg);
- //console.log(obj);
- },
- dataType: "text",
- });
-}
-
-
-function clearResult(){
- document.getElementById("Rout_Div").innerHTML = '';
- document.getElementById("Result_Summary").innerHTML = '';
- data_Vue.plottingData = new myPlottingData();
- for(let i=0; i< data_Vue.traitsinfo.length; i++){
- Plotly.purge('ResgMean_Div'+(i+1));
- }
- for(let i=0; i< data_Vue.traitsinfo.length; i++){
- Plotly.purge('RespMean_Div'+(i+1));
- }
- for(let i=0; i< data_Vue.selection_index.length; i++){
- Plotly.purge('ResAccBVE_Div'+(i+1));
- }
- for(let i=0; i< 2; i++){
- Plotly.purge('ResRel_Div'+(i+1));
- }
- for(let i=0; i< 1; i++){
- Plotly.purge('ResRelbetweenC_Div'+(i+1));
- }
- for(let i=0; i< 3; i++){
- Plotly.purge('ResQTL_Div'+(i+1));
- }
- data_Vue.runned=false;
-}
-
-
-
-var A = [[1,0,0],[0,1,0], [0,0,1]];
-//console.log(numeric.eig(A).lambda.x);
-
-
+//*************************************************************************************************//
+//*********** Functions for running R Simulation ***********************************//
+function checkRunTime(){
+ var nodes = data_Vue.nodes.get();
+
+ var nInd = 0;
+ var nF = 0;
+ for(let i=0;i < nodes.length; i++){
+ if(nodes[i].Founder == 'Yes'){
+ nF = nF + parseInt(nodes[i]['Number of Individuals']);
+ }
+ nInd = nInd + parseInt(nodes[i]['Number of Individuals']);
+ }
+
+ if(data_Vue.geninfo['Chromosomes Info'].length > 0){
+ var nsnp = data_Vue.geninfo['Chromosomes Info'][0].Length * data_Vue.geninfo['Chromosomes Info'][0].MD;
+ var Morgan = data_Vue.geninfo['Chromosomes Info'][0].Length * data_Vue.geninfo['Chromosomes Info'][0].Recombination /100;
+ }else{
+ var nsnp = data_Vue.geninfo['Max Number of SNPs'];
+ var Morgan = 5;
+ }
+
+ var edges = data_Vue.edges.get();
+ var nRep = 0;
+ var nZucht = 0;
+ for(let i=0;i < edges.length; i++){
+ if(edges[i]['Breeding Type'] == 'Repeat'){
+ nRep = edges[i]['Number of Repeat'];
+ }
+ if(edges[i]['Breeding Type'] == 'Selection' & edges[i]['Selection Type'] == 'BVE'){
+ nZucht++;
+ }
+ }
+ console.log(nF);
+ console.log(nsnp);
+ console.log(nInd);
+ var comptime = nF*nsnp/1000000 + 0.0002*nInd*Morgan;
+ return comptime;
+}
+
+function runningR(){
+
+
+ clearResult();
+ data_Vue.plottingData = new myPlottingData();
+ var jsondata = JSON.stringify(exportNetwork());
+ //console.log(jsondata);
+ //alert("Approx. simulation running time: " + Math.round(checkRunTime()/60*2.6*100)/100 + "minutes.");
+
+ $.ajax
+ ({
+ type: "POST",
+ url: './Rsim',
+ data: {jsondata : jsondata},
+ beforeSend: function() {
+ document.getElementById("runningDogTitle").innerHTML = 'MoBPS is running .... please wait';
+ document.getElementById("runningDog").style.visibility = 'visible';
+ //alert("Now Sending!");
+ },
+ success: function (data, msg) {
+ //console.log(data);
+ alert("Simulation Finished!");
+ data_Vue.runned = true;
+ document.getElementById("Rout_Div").innerHTML = data;
+ document.getElementById("Rout_Div").innerHTML = document.getElementById("Rout_Div").innerHTML.replace(/Error/g, "Error");
+ document.getElementById("Rout_Div").innerHTML = document.getElementById("Rout_Div").innerHTML.replace(/\n/g, " ");
+ writeSum();
+ },
+ error: function(obj, msg, err)
+ {
+ alert(err);
+ },
+ complete: function(obj, msg){
+ document.getElementById("runningDog").style.visibility = 'hidden';
+ //document.getElementById("runningDog").innerHTML = '';
+ //alert(msg);
+ //console.log(obj);
+ },
+ dataType: "text",
+ });
+}
+
+
+//Running R with streaming
+function runningR1(){
+
+ clearResult();
+ data_Vue.plottingData = new myPlottingData();
+ var jsondata = JSON.stringify(exportNetwork());
+ //console.log(jsondata);
+ //alert("Approx. simulation running time: " + Math.round(checkRunTime()/60*2.6*100)/100 + "minutes.");
+
+ savedNodes = data_Vue.nodes.get();
+ var savedNodesLen = savedNodes.length;
+ var isFounder = "";
+ for(let i=0; i < savedNodesLen; i++){
+ var checkFounder = savedNodes[i].Founder;
+ if (checkFounder == "Yes") {
+ isFounder = "Found";
+ }
+ }
+
+ if(isFounder == ""){
+ alert("There is no Founder in the Project. Please add a Founder!");
+ }
+
+ // check combine edge new rule -- All parent node of a child should contain the same number of individuals as the child node.
+ combineEdgePop();
+ // check split edge new rule -- All child nodes of a split edge should contain the same number of individuals as the parent node.
+ splitEdgePop();
+ // check all nodes -- Any non-founder node should have at least one incoming edge that is no repeat edge.
+ checkallNodes();
+
+
+ $.ajax
+ ({
+ type: "POST",
+ url: './Rsim1',
+ data: {jsondata : jsondata},
+ beforeSend: function() {
+ document.getElementById("runningDogTitle").innerHTML = 'MoBPS is running .... please wait';
+ document.getElementById("runningDog").style.visibility = 'visible';
+ if(data_Vue.socket == ''){
+ data_Vue.socket = io();
+ data_Vue.socket.on(data_Vue.user, function(d){
+ document.getElementById("runningDogLog").innerHTML += d + " ";
+ })
+ }
+ //alert("Now Sending!");
+ },
+ success: function (data, msg) {
+ //console.log(data);
+
+ document.getElementById("Rout_Div").innerHTML = data;
+
+ where = document.getElementById("Rout_Div").innerHTML.indexOf("Execution");
+ where2 = document.getElementById("Rout_Div").innerHTML.indexOf("EAAPguest");
+
+ document.getElementById("Rout_Div").innerHTML = document.getElementById("Rout_Div").innerHTML.replace(/Error/g, "Error");
+ document.getElementById("Rout_Div").innerHTML = document.getElementById("Rout_Div").innerHTML.replace(/\n/g, " ");
+
+
+
+ if(where == -1){
+ alert("Simulation Finished successfully!");
+
+ } else if(where2 > (-1)){
+ alert("EAAPguest is not allowed to run simulations. Please contact Torsten Pook if you need/want more rights.")
+ } else{
+ alert("Your Simulation failed! Check your inputs and potential warnings!");
+ }
+ data_Vue.runned = true;
+
+
+ writeSum();
+ },
+ error: function(obj, msg, err)
+ {
+ alert("Simulation failed!");
+ alert(err);
+ },
+ complete: function(obj, msg){
+ document.getElementById("runningDog").style.visibility = 'hidden';
+ document.getElementById("runningDogLog").innerHTML = '';
+ //alert(msg);
+ //console.log(obj);
+ },
+ dataType: "text",
+ });
+}
+
+function combineEdgePop() {
+ savedEdges = data_Vue.edges.get();
+ var savedEdgesLen = savedEdges.length;
+ var edgesList = [];
+ var parentEdge1 = "";
+ for(let i=0; i < savedEdgesLen; i++){
+ var bType = savedEdges[i]['Breeding Type'];
+ if (bType == "Combine") {
+ var parentEdge2 = savedEdges[i].to;
+ }
+
+ if ((parentEdge1 !== parentEdge2) & (bType == "Combine")) {
+ edgesList.push(parentEdge2);
+ }
+ parentEdge1 = parentEdge2;
+ }
+ checkCombineEdgeParentInd(edgesList);
+}
+
+function checkCombineEdgeParentInd(edgesList) {
+ savedEdges = data_Vue.edges.get();
+ var savedEdgesLen = savedEdges.length;
+
+ for(let a=0; a < edgesList.length; a++){
+ var childEdgeInd = 0;
+ var parentEdgeInd = data_Vue.nodes.get(edgesList[a])['Number of Individuals'];
+ var parentName = data_Vue.nodes.get(edgesList[a])['id'];
+ for(let b=0; b < savedEdgesLen; b++){
+ if ((savedEdges[b]['Breeding Type'] == "Combine") & (parentName == savedEdges[b].to)) {
+ var childEdgeIndd = data_Vue.nodes.get(savedEdges[b].from)['Number of Individuals'];
+ var childEdgeInd = parseInt(childEdgeInd) + parseInt(childEdgeIndd);
+ }
+ }
+
+ if (childEdgeInd != parentEdgeInd) {
+ alert("All parent node of a combine edge should contain the same number of individuals as the child node." );
+ }
+
+ childEdgeInd = 0;
+ }
+}
+
+function splitEdgePop() {
+ savedEdges = data_Vue.edges.get();
+ var savedEdgesLen = savedEdges.length;
+ var edgesSplitList = [];
+ var parentSplitEdge1 = "";
+
+ for(let i=0; i < savedEdgesLen; i++){
+ var bType = savedEdges[i]['Breeding Type'];
+ if (bType == "Split") {
+ var parentSplitEdge2 = savedEdges[i].from;
+ }
+ if ((parentSplitEdge1 !== parentSplitEdge2) & (bType == "Split")) {
+ edgesSplitList.push(parentSplitEdge2);
+ }
+ parentSplitEdge1 = parentSplitEdge2;
+ }
+ checkSplitParentInd(edgesSplitList);
+}
+
+function checkSplitParentInd(edgesList) {
+ savedEdges = data_Vue.edges.get();
+ var savedEdgesLen = savedEdges.length;
+ var childSplitEdgeInd = 0;
+
+ for(let c=0; c < edgesList.length; c++){
+ var parentSplitEdgeInd = data_Vue.nodes.get(edgesList[c])['Number of Individuals'];
+ var parentName = data_Vue.nodes.get(edgesList[c])['id'];
+ for(let d=0; d < savedEdgesLen; d++){
+ if ((savedEdges[d]['Breeding Type'] == "Split") & (parentName == savedEdges[d].from)) {
+ var childSplitEdgeIndd = data_Vue.nodes.get(savedEdges[d].to)['Number of Individuals'];
+ var childSplitEdgeInd = parseInt(childSplitEdgeInd) + parseInt(childSplitEdgeIndd);
+ }
+ }
+
+ if (childSplitEdgeInd != parentSplitEdgeInd) {
+ alert("All child nodes of a split edge should contain the same number of individuals as the parent node." );
+ }
+ childSplitEdgeInd = 0;
+ }
+}
+
+
+
+function checkallNodes() {
+ savedNodes = data_Vue.nodes.get();
+ var savedNodesLen = savedNodes.length;
+
+ savedEdges = data_Vue.edges.get();
+ var savedEdgesLen = savedEdges.length;
+ var isToId = "";
+
+ for(let i=0; i < savedNodesLen; i++){
+ var checkFound = savedNodes[i].Founder;
+ var checkId = savedNodes[i].id;
+
+ var cnt = 0;
+ for(let j=0; j < savedEdgesLen; j++){
+ if (savedEdges[j]['to'] == checkId) {
+ if (savedEdges[j]['Breeding Type'] != "Repeat") { var cnt = cnt + 1; }
+ }
+ }
+
+ if ((checkFound != "Yes") & (cnt == 0)) {
+ alert(checkId+" Any non-founder node should have at least one incoming edge that is no repeat edge." );
+ }
+ }
+}
+
+
+function ReloadSim(){
+ var filename = data_Vue.geninfo["Project Name"];
+ //var cohorts = data_Vue.plottingPar.ResgMean_cohorts;
+
+ $.ajax
+ ({
+ type: "POST",
+ url: './RsimResult',
+ data: {
+ filename : filename,
+ script: "ReloadSim"
+ },
+ beforeSend: function() {
+ document.getElementById("runningDogTitle").innerHTML = 'Getting Old Results...';
+ document.getElementById("runningDog").style.visibility = 'visible';
+ //alert("Now Sending!");
+ },
+ success: function (data, msg) {
+ data_Vue.runned = true;
+ console.log(data);
+ document.getElementById("Rout_Div").innerHTML = data;
+ document.getElementById("Rout_Div").innerHTML = document.getElementById("Rout_Div").innerHTML.replace(/Error/g, "Error");
+ document.getElementById("Rout_Div").innerHTML = document.getElementById("Rout_Div").innerHTML.replace(/\n/g, " ");
+ writeSum();
+ },
+ failure: function(msg)
+ {
+ alert("Failed to plot KS. Please run the Simulation first!");
+ },
+ complete: function(obj, msg){
+ document.getElementById("runningDog").style.visibility = 'hidden';
+ //document.getElementById("runningDog").innerHTML = '';
+ //alert(msg);
+ //console.log(obj);
+ },
+ dataType: "text",
+ });
+}
+
+$(document).ready(function(){
+ $("#ResultUpload").on('change',function(){
+ UploadSim();
+ });
+});
+
+function UploadSim(){
+ var filename = document.getElementById('ResultFile').files[0].name
+ //var cohorts = data_Vue.plottingPar.ResgMean_cohorts;
+ //console.log(filename);
+ data_Vue.geninfo['Project Name'] = filename;
+
+ $.ajax
+ ({
+ type: "POST",
+ url: './RsimResult',
+ data: {
+ filename : filename,
+ script: "ReloadSim"
+ },
+ beforeSend: function() {
+ document.getElementById("runningDogTitle").innerHTML = 'Getting Old Results...';
+ document.getElementById("runningDog").style.visibility = 'visible';
+ //alert("Now Sending!");
+ },
+ success: function (data, msg) {
+ data_Vue.runned = true;
+ //console.log(data);
+ document.getElementById("Rout_Div").innerHTML = data;
+ document.getElementById("Rout_Div").innerHTML = document.getElementById("Rout_Div").innerHTML.replace(/Error/g, "Error");
+ document.getElementById("Rout_Div").innerHTML = document.getElementById("Rout_Div").innerHTML.replace(/\n/g, " ");
+ writeSum();
+ },
+ failure: function(msg)
+ {
+ alert("Failed to plot KS. Please run the Simulation first!");
+ },
+ complete: function(obj, msg){
+ document.getElementById("runningDog").style.visibility = 'hidden';
+ //document.getElementById("runningDog").innerHTML = '';
+ //alert(msg);
+ //console.log(obj);
+ },
+ dataType: "text",
+ });
+}
+
+function stopR(){
+ var r = confirm("The R process will be stopped and data in R will be lost. Do you want to proceed?");
+ if(r){
+ $.ajax
+ ({
+ type: "POST",
+ url: './StopR',
+ success: function (msg) {
+ document.getElementById("runningDog").style.visibility = 'hidden';
+ document.getElementById("runningDogLog").innerHTML = '';
+ },
+ error: function(obj, msg, err)
+ {
+ alert(err);
+ },
+ dataType: "text",
+ });
+ }
+}
+
+function writeSum(){
+ var file = data_Vue['geninfo']['Project Name'] + 'Summary';
+
+ $.ajax
+ ({
+ type: "POST",
+ url: './JSON',
+ data: {file : file},
+ success: function (data, msg) {
+ //console.log(data);
+ data_Vue.plottingData.Summary = JSON.parse(data);
+ data = data_Vue.plottingData.Summary;
+ data_Vue.Summary = Object.keys(data_Vue.plottingData.Summary).map(function(x){return({id: x, label: x+" ("+(data_Vue.plottingData.Summary[x].trep -1)+" Repeats)"})});
+ var el = document.getElementById("Result_Summary");
+ el.innerHTML = "==> " + "Project " + data_Vue.geninfo["Project Name"]+ " successfully processed in R." + " ";
+ el.innerHTML += " Founders: " + " ";
+ for(let key in data){
+ console.log(key);
+ if(data[key].tfounder[0]){
+ el.innerHTML += "==> Cohort " + key + " with " + (data[key].trep[0] - 1) + " repetitions. ";
+ }
+ }
+ el.innerHTML += " Non-founders: " + " ";
+ for(let key in data){
+ if(!data[key].tfounder[0]){
+ el.innerHTML += "==> Cohort " + key + " with " + (data[key].trep[0] - 1) + " repetitions. ";
+ }
+ }
+
+ },
+ error: function(obj, msg, err)
+ {
+ alert(err);
+ },
+ dataType: "text",
+ });
+}
+
+//*************************************************************************************************//
+//*********** Functions for plotting results after R Simulation ***********************************//
+// ---- Plotting observed Phenotypes Mean:
+function plottingResultpMean(){
+ var data = data_Vue.plottingData.RespMean;
+ var coh = data_Vue.plottingPar.RespMean_cohorts;
+ var pType = data_Vue.plottingPar.RespMean_pType;
+
+ var data1 = [];
+ for(let i=0; i< data_Vue.traitsinfo.length; i++){
+ data1.push([]);
+ }
+
+ if(pType=="By Repeats"){
+ // each cohort
+ for(let i=0; i < coh.length; i++){
+ // each trait:
+ for(let j=0; j< data_Vue.traitsinfo.length; j++){
+ data1[j].push({
+ y : Object.values(data[coh[i]]).map(function(x){return(math.mean(x.tval[j]))}),
+ x : Object.keys(data[coh[i]]),
+ mode : 'scatter',
+ name : coh[i]
+ });
+ }
+ }
+ var xtitle = 'Repeats';
+ }
+ if(pType=="By Cohorts"){
+ // each cohort
+ for(let i=0; i < coh.length; i++){
+ var red = ((Math.floor(i/3)+1)*85)%255;
+ var green = ((Math.floor(i/6)+1)*85)%255;
+ var blue = ((i+1)*85)%255;
+ // each rep:
+ var ttimes = Object.keys(data[coh[i]]);
+ for(let k=0; k < ttimes.length; k++){
+ // eacht trait
+ for(let j=0; j< data_Vue.traitsinfo.length; j++){
+ data1[j].push({
+ y : data[coh[i]][ttimes[k]].tval[j],
+ name : coh[i]+'_'+ttimes[k],
+ marker : {color: "rgb("+red+","+green+","+blue+")"},
+ type: 'box',
+ boxpoints : 'Outliers',
+ boxmean : true
+ });
+ }
+ }
+ }
+ var xtitle = 'Cohorts (trailing numbers denote repeated cohorts)';
+ }
+ if(pType=="By Time"){
+ // each cohort
+ for(let i=0; i < coh.length; i++){
+ // each trait:
+ for(let j=0; j< data_Vue.traitsinfo.length; j++){
+ data1[j].push({
+ y : Object.values(data[coh[i]]).map(function(x){return(math.mean(x.tval[j]))}),
+ x : Object.values(data[coh[i]]).map(function(x){return(math.mean(x.ttime[0]))}),
+ mode : 'scatter',
+ name : coh[i]
+ });
+ }
+ }
+ var xtitle = 'Time in '+data_Vue.geninfo['Time Unit'];
+ }
+
+ //console.log(data);
+ var titles = data_Vue.traitsinfo.map(function(x){return(x['Trait Name'])});
+ for(let i=0; i < data_Vue.traitsinfo.length; i++){
+ var layout = {
+ title : titles[i],
+ showlegend: pType != 'By Cohorts',
+ plot_bgcolor: '#FFFFFF',
+ xaxis: {
+ title: xtitle,
+ zeroline: false,
+ automargin: true
+ },
+ };
+ var config = {
+ scrollZoom: true,
+ toImageButtonOptions: {
+ format: 'png', // one of png, svg, jpeg, webp
+ filename: 'custom_image',
+ height: 750,
+ width: 1500,
+ scale: 0.8 // Multiply title/legend/axis/canvas sizes by this factor
+ }
+ };
+ Plotly.newPlot('RespMean_Div'+(i+1), data1[i], layout, config);
+ }
+}
+
+function RunResultpMean(){
+ var filename = data_Vue.geninfo["Project Name"];
+ //var cohorts = data_Vue.plottingPar.ResgMean_cohorts;
+
+ $.ajax
+ ({
+ type: "POST",
+ url: './RsimResult',
+ data: {
+ filename : filename,
+ script: "pMean"
+ },
+ beforeSend: function() {
+ document.getElementById("runningDogTitle").innerHTML = 'Calculating Results for observed Phenotypes...';
+ document.getElementById("runningDog").style.visibility = 'visible';
+ //alert("Now Sending!");
+ },
+ success: function (data, msg) {
+ if(data != ''){
+ //console.log(data);
+ data_Vue.plottingData.RespMean = JSON.parse(data);
+ //plottingResultgMean(JSON.parse(data));
+ }else{
+ alert("Failed to plot KS. Please run the Simulation first! here");
+ }
+ },
+ failure: function(msg)
+ {
+ alert("Failed to plot KS. Please run the Simulation first!");
+ },
+ complete: function(obj, msg){
+ document.getElementById("runningDog").style.visibility = 'hidden';
+ //document.getElementById("runningDog").innerHTML = '';
+ //alert(msg);
+ //console.log(obj);
+ },
+ dataType: "text",
+ });
+}
+
+// ---- Plotting genotypic Mean:
+function plottingResultgMean(){
+ var data = data_Vue.plottingData.ResgMean;
+ var coh = data_Vue.plottingPar.ResgMean_cohorts;
+ var pType = data_Vue.plottingPar.ResgMean_pType;
+
+ var data1 = [];
+ for(let i=0; i< data_Vue.traitsinfo.length; i++){
+ data1.push([]);
+ }
+
+ if(pType=="By Repeats"){
+ // each cohort
+ for(let i=0; i < coh.length; i++){
+ // each trait:
+ for(let j=0; j< data_Vue.traitsinfo.length; j++){
+ data1[j].push({
+ y : Object.values(data[coh[i]]).map(function(x){return(math.mean(x.tval[j]))}),
+ x : Object.keys(data[coh[i]]),
+ mode : 'scatter',
+ name : coh[i]
+ });
+ }
+ }
+ var xtitle = 'Repeats';
+ }
+ if(pType=="By Cohorts"){
+ // each cohort
+ for(let i=0; i < coh.length; i++){
+ var red = ((Math.floor(i/3)+1)*85)%255;
+ var green = ((Math.floor(i/6)+1)*85)%255;
+ var blue = ((i+1)*85)%255;
+ // each rep:
+ var ttimes = Object.keys(data[coh[i]]);
+ for(let k=0; k < ttimes.length; k++){
+ // eacht trait
+ for(let j=0; j< data_Vue.traitsinfo.length; j++){
+ data1[j].push({
+ y : data[coh[i]][ttimes[k]].tval[j],
+ name : coh[i]+'_'+ttimes[k],
+ marker : {color: "rgb("+red+","+green+","+blue+")"},
+ type: 'box',
+ boxpoints : 'Outliers',
+ boxmean : true
+ });
+ }
+ }
+ }
+ var xtitle = 'Cohorts (trailing numbers denote repeated cohorts)';
+ }
+ if(pType=="By Time"){
+ // each cohort
+ for(let i=0; i < coh.length; i++){
+ // each trait:
+ for(let j=0; j< data_Vue.traitsinfo.length; j++){
+ data1[j].push({
+ y : Object.values(data[coh[i]]).map(function(x){return(math.mean(x.tval[j]))}),
+ x : Object.values(data[coh[i]]).map(function(x){return(math.mean(x.ttime[0]))}),
+ mode : 'scatter',
+ name : coh[i]
+ });
+ }
+ }
+ var xtitle = 'Time in '+data_Vue.geninfo['Time Unit'];
+ }
+
+ var titles = data_Vue.traitsinfo.map(function(x){return(x['Trait Name'])});
+ for(let i=0; i < data_Vue.traitsinfo.length; i++){
+ var layout = {
+ title : titles[i],
+ showlegend: pType != 'By Cohorts',
+ plot_bgcolor: '#FFFFFF',
+ xaxis: {
+ title: xtitle,
+ zeroline: false,
+ automargin: true
+ },
+ };
+ var config = {
+ scrollZoom: true,
+ toImageButtonOptions: {
+ format: 'png', // one of png, svg, jpeg, webp
+ filename: 'custom_image',
+ height: 750,
+ width: 1500,
+ scale: 0.8 // Multiply title/legend/axis/canvas sizes by this factor
+ }
+ };
+ Plotly.newPlot('ResgMean_Div'+(i+1), data1[i], layout, config);
+ }
+}
+
+function RunResultgMean(){
+ var filename = data_Vue.geninfo["Project Name"];
+ //var cohorts = data_Vue.plottingPar.ResgMean_cohorts;
+
+ $.ajax
+ ({
+ type: "POST",
+ url: './RsimResult',
+ data: {
+ filename : filename,
+ script: "gMean"
+ },
+ beforeSend: function() {
+ document.getElementById("runningDogTitle").innerHTML = 'Calculating Results for genomic breeding values...';
+ document.getElementById("runningDog").style.visibility = 'visible';
+ //alert("Now Sending!");
+ },
+ success: function (data, msg) {
+ if(data != ''){
+ //console.log(data);
+ data_Vue.plottingData.ResgMean = JSON.parse(data);
+ //plottingResultgMean(JSON.parse(data));
+ }else{
+ alert("Failed to plot KS. Please run the Simulation first!");
+ }
+ },
+ failure: function(msg)
+ {
+ alert("Failed to plot KS. Please run the Simulation first!");
+ },
+ complete: function(obj, msg){
+ document.getElementById("runningDog").style.visibility = 'hidden';
+ //document.getElementById("runningDog").innerHTML = '';
+ //alert(msg);
+ //console.log(obj);
+ },
+ dataType: "text",
+ });
+}
+
+
+// ---- Plotting Relationship:
+function plottingResultRel(){
+ var data = data_Vue.plottingData.ResRel;
+ var coh = data_Vue.plottingPar.ResRel_cohorts;
+ var pType = data_Vue.plottingPar.ResRel_pType;
+ var data1 = [[],[]];// Relationship and Inbreeding
+
+ if(pType=="By Repeats"){
+ // each cohort
+ for(let i=0; i < coh.length; i++){
+ // each value:
+ for(let j=0; j< data1.length; j++){
+ data1[j].push({
+ y : data[coh[i]][3+j],
+ x : data[coh[i]][1],
+ mode : 'scatter',
+ name : coh[i]
+ });
+ }
+ }
+ var xtitle = 'Repeats';
+ }
+ if(pType=="By Cohorts"){
+ var data1 = [[{}],[{}]];// Relationship and Inbreeding
+ // each cohort
+ for(let j=0; j< data1.length; j++){
+ data1[j][0].y = [];
+ data1[j][0].x = [];
+ data1[j][0].type = "bar";
+ for(let i=0; i < coh.length; i++){
+ var red = ((Math.floor(i/3)+1)*85)%255;
+ var green = ((Math.floor(i/6)+1)*85)%255;
+ var blue = ((i+1)*85)%255;
+ // each value
+ var ttimes = data[coh[i]][1];
+ for(let k=0; k< ttimes.length; k++){
+ data1[j][0].y.push(Number(data[coh[i]][3+j][k]));
+ data1[j][0].x.push(coh[i] +'_'+ ttimes[k]);
+ }
+
+ }
+ }
+ //console.log(data1);
+ var xtitle = 'Cohorts (trailing numbers denote repeated cohorts)';
+ }
+ if(pType=="By Time"){
+ // each cohort
+ for(let i=0; i < coh.length; i++){
+ // each value:
+ for(let j=0; j< data1.length; j++){
+ data1[j].push({
+ y : data[coh[i]][3+j],
+ x : data[coh[i]][2],
+ mode : 'scatter',
+ name : coh[i]
+ });
+ }
+ }
+ var xtitle = 'Time in '+data_Vue.geninfo['Time Unit'];
+ }
+
+ var titles = ["Average Relationship within Cohorts", "Average Inbreeding within Cohorts"];
+ for(let i=0; i < data1.length; i++){
+ var layout = {
+ title : titles[i],
+ showlegend: pType != 'By Cohorts',
+ plot_bgcolor: '#FFFFFF',
+ xaxis: {
+ title: xtitle,
+ zeroline: false,
+ automargin: true
+ },
+ };
+ var config = {
+ scrollZoom: true,
+ toImageButtonOptions: {
+ format: 'png', // one of png, svg, jpeg, webp
+ filename: 'custom_image',
+ height: 750,
+ width: 1500,
+ scale: 0.8 // Multiply title/legend/axis/canvas sizes by this factor
+ }
+ };
+ Plotly.newPlot('ResRel_Div'+(i+1), data1[i], layout, config);
+ }
+}
+
+function RunResultRel(){
+ var filename = data_Vue.geninfo["Project Name"];
+ //var cohorts = data_Vue.plottingPar.ResgMean_cohorts;
+
+ $.ajax
+ ({
+ type: "POST",
+ url: './RsimResult',
+ data: {
+ filename : filename,
+ script: "Rel"
+ },
+ beforeSend: function() {
+ document.getElementById("runningDogTitle").innerHTML = 'Calculating Results for Relationship within Cohorts...';
+ document.getElementById("runningDog").style.visibility = 'visible';
+ //alert("Now Sending!");
+ },
+ success: function (data, msg) {
+ if(data != ''){
+ //console.log(data);
+ data_Vue.plottingData.ResRel = JSON.parse(data);
+ //plottingResultgMean(JSON.parse(data));
+ }else{
+ alert("Failed to plot KS. Please run the Simulation first!");
+ }
+ },
+ failure: function(msg)
+ {
+ alert("Failed to plot KS. Please run the Simulation first!");
+ },
+ complete: function(obj, msg){
+ document.getElementById("runningDog").style.visibility = 'hidden';
+ //document.getElementById("runningDog").innerHTML = '';
+ //alert(msg);
+ //console.log(obj);
+ },
+ dataType: "text",
+ });
+}
+
+// ---- Plotting Relationship between Cohorts:
+function plottingResultRelbetweenC(){
+ var data = data_Vue.plottingData.ResRelbetweenC;
+ var coh1 = data_Vue.plottingPar.ResRelbetweenC_cohort1;
+ var coh2 = data_Vue.plottingPar.ResRelbetweenC_cohort2;
+
+ // average relationship between cohorts:
+ var data1 = [{
+ y: data[coh1] ? data[coh1][coh2] : data[coh2][coh1],
+ mode : 'scatter',
+ }];
+ if(data1[0].y == undefined){
+ data1[0].y = data[coh2][coh1];
+ }
+ data1[0].x = data1[0].y.map(function(x, index){return(index)});
+ var layout = {
+ title : 'Relationship between '+ coh1 +' and '+coh2,
+ showlegend: false,
+ plot_bgcolor: '#FFFFFF',
+ xaxis: {
+ title: 'Repeats',
+ zeroline: false,
+ automargin: true
+ },
+ };
+ var config = {
+ scrollZoom: true,
+ toImageButtonOptions: {
+ format: 'png', // one of png, svg, jpeg, webp
+ filename: 'custom_image',
+ height: 750,
+ width: 1500,
+ scale: 0.8 // Multiply title/legend/axis/canvas sizes by this factor
+ }
+ };
+ Plotly.newPlot('ResRelbetweenC_Div1', data1, layout, config);
+}
+
+function RunResultRelbetweenC(){
+ var filename = data_Vue.geninfo["Project Name"];
+ //var cohorts = data_Vue.plottingPar.ResgMean_cohorts;
+
+ $.ajax
+ ({
+ type: "POST",
+ url: './RsimResult',
+ data: {
+ filename : filename,
+ script: "RelbetweenC"
+ },
+ beforeSend: function() {
+ document.getElementById("runningDogTitle").innerHTML = 'Calculating Results for Relationship between Cohorts...';
+ document.getElementById("runningDog").style.visibility = 'visible';
+ //alert("Now Sending!");
+ },
+ success: function (data, msg) {
+ if(data != ''){
+ //console.log(data);
+ data_Vue.plottingData.ResRelbetweenC = JSON.parse(data);
+ //plottingResultgMean(JSON.parse(data));
+ }else{
+ alert("Failed to plot KS. Please run the Simulation first!");
+ }
+ },
+ failure: function(msg)
+ {
+ alert("Failed to plot KS. Please run the Simulation first!");
+ },
+ complete: function(obj, msg){
+ document.getElementById("runningDog").style.visibility = 'hidden';
+ //document.getElementById("runningDog").innerHTML = '';
+ //alert(msg);
+ //console.log(obj);
+ },
+ dataType: "text",
+ });
+}
+
+// ---- Plotting QTL:
+function plottingResultQTL(){
+ var data1 = [[],[],[]];
+ var trait = data_Vue.plottingPar.ResQTL_trait-1;
+ var qtl = data_Vue.plottingPar.ResQTL_qtl;
+ var coh = data_Vue.plottingPar.ResQTL_cohorts;
+
+ var data = data_Vue.plottingData.ResQTL[data_Vue.traitsinfo[trait]['Trait Name']][qtl];
+
+ for(let i=0; i < coh.length; i++){
+ // allele frequency:
+ data1[0].push({
+ y : data[coh[i]][2],
+ x : data[coh[i]][1],
+ mode : 'scatter',
+ name : coh[i]
+ });
+ // observed He:
+ data1[1].push({
+ y : data[coh[i]][3],
+ x : data[coh[i]][1],
+ mode : 'scatter',
+ name : coh[i]
+ });
+ // expected He:
+ data1[2].push({
+ y : data[coh[i]][4],
+ x : data[coh[i]][1],
+ mode : 'scatter',
+ name : coh[i]
+ });
+ }
+
+ var titles = ["Allele Frequency (A)", "Observed Heterozygosity", "Expected Heterozygosity"];
+ for(let i=0; i < 3; i++){
+ var layout = {
+ title : titles[i],
+ showlegend: true,
+ plot_bgcolor: '#FFFFFF',
+ xaxis: {
+ title: 'Repeats',
+ zeroline: false,
+ automargin: true
+ },
+ };
+ var config = {
+ scrollZoom: true,
+ toImageButtonOptions: {
+ format: 'png', // one of png, svg, jpeg, webp
+ filename: 'custom_image',
+ height: 750,
+ width: 1500,
+ scale: 0.8 // Multiply title/legend/axis/canvas sizes by this factor
+ }
+ };
+ Plotly.newPlot('ResQTL_Div'+(i+1), data1[i], layout, config);
+ }
+}
+
+function RunResultQTL(){
+ var filename = data_Vue.geninfo["Project Name"];
+ var qtl = 0;
+ for(let i=0; i< data_Vue.traitsinfo.length; i++){
+ qtl += data_Vue.traitsinfo[i]["Trait Major QTL"];
+ }
+ if(qtl == 0){
+ alert("There is no QTL to calculate results for.");
+ return;
+ }
+
+ $.ajax
+ ({
+ type: "POST",
+ url: './RsimQTL',
+ data: {
+ filename : filename,
+ traitsinfo : data_Vue.traitsinfo
+ },
+ beforeSend: function() {
+ document.getElementById("runningDogTitle").innerHTML = 'Calculating Results for QTLs';
+ document.getElementById("runningDog").style.visibility = 'visible';
+ //alert("Now Sending!");
+ },
+ success: function (data, msg) {
+ if(data != ''){
+ //console.log(data);
+ data_Vue.plottingData.ResQTL = JSON.parse(data);
+ //plottingResultQTL(JSON.parse(data));
+ }else{
+ alert("Failed to plot KS. Please run the Simulation first!");
+ }
+ },
+ failure: function(msg)
+ {
+ alert("Failed to plot KS. Please run the Simulation first!");
+ },
+ complete: function(obj, msg){
+ document.getElementById("runningDog").style.visibility = 'hidden';
+ //document.getElementById("runningDog").innerHTML = '';
+ //alert(msg);
+ //console.log(obj);
+ },
+ dataType: "text",
+ });
+}
+
+// ---- Plotting Accuracy of Breeding Value Estimation:
+function plottingResultAccBVE(){
+ var data = data_Vue.plottingData.ResAccBVE;
+ var coh = data_Vue.plottingPar.ResAccBVE_cohorts;
+ var pType = data_Vue.plottingPar.ResAccBVE_pType;
+ var sindex = data_Vue.selection_index;
+ var data1 = [];
+ for(let i=0;i < sindex.length; i++){
+ data1.push([]);
+ }
+
+ if(pType=="By Repeats"){
+ // each cohort
+ for(let i=0; i < coh.length; i++){
+ // each value:
+ for(let j=0; j< data1.length; j++){
+ data1[j].push({
+ y : Object.values(data[coh[i]]).map(function(x){return(Number(x.tval[j]))}),
+ x : Object.keys(data[coh[i]]),
+ mode : 'scatter',
+ name : coh[i]
+ });
+ }
+ }
+ var xtitle = 'Repeats';
+ }
+ if(pType=="By Cohorts"){
+ var data1 = [];
+ for(let i=0;i < sindex.length; i++){
+ data1.push([{}]);
+ } // Relationship and Inbreeding
+ // each cohort
+ for(let j=0; j< data1.length; j++){
+ data1[j][0].y = [];
+ data1[j][0].x = [];
+ data1[j][0].type = "bar";
+ for(let i=0; i < coh.length; i++){
+ // each value
+ var ttimes = Object.keys(data[coh[i]]);
+ for(let k=0; k< ttimes.length; k++){
+ data1[j][0].y.push(Number(Object.values(data[coh[i]])[k].tval[j]));
+ data1[j][0].x.push(coh[i] + "_"+ ttimes[k]);
+ }
+
+ }
+ }
+ //console.log(data1);
+ var xtitle = 'Cohorts (trailing numbers denote repeated cohorts)';
+ }
+ if(pType=="By Time"){
+ // each cohort
+ for(let i=0; i < coh.length; i++){
+ // each value:
+ for(let j=0; j< data1.length; j++){
+ data1[j].push({
+ y : Object.values(data[coh[i]]).map(function(x){return(Number(x.tval[j]))}),
+ x : Object.values(data[coh[i]]).map(function(x){return(x.ttime[0])}),
+ mode : 'scatter',
+ name : coh[i]
+ });
+ }
+ }
+ var xtitle = 'Time in '+data_Vue.geninfo['Time Unit'];
+ }
+
+ var titles = sindex.map(function(x){return(x['Name'])});
+ for(let i=0; i < data1.length; i++){
+ var layout = {
+ title : titles[i],
+ showlegend: pType != 'By Cohorts',
+ plot_bgcolor: '#FFFFFF',
+ xaxis: {
+ title: xtitle,
+ zeroline: false,
+ automargin: true
+ },
+ yaxis: {
+ title: "Correlation of True BV and EBV/Phenotype",
+ zeroline: false,
+ automargin: true
+ },
+ };
+ var config = {
+ scrollZoom: true,
+ toImageButtonOptions: {
+ format: 'png', // one of png, svg, jpeg, webp
+ filename: 'custom_image',
+ height: 750,
+ width: 1500,
+ scale: 0.8 // Multiply title/legend/axis/canvas sizes by this factor
+ }
+ };
+ Plotly.newPlot('ResAccBVE_Div'+(i+1), data1[i], layout, config);
+ }
+}
+
+
+function RunResultAccBVE(){
+ var filename = data_Vue.geninfo["Project Name"];
+ var sindex = data_Vue.selection_index;
+
+ $.ajax
+ ({
+ type: "POST",
+ url: './RsimAccBVE',
+ data: {
+ filename : filename,
+ sindex : sindex
+ },
+ beforeSend: function() {
+ document.getElementById("runningDogTitle").innerHTML = 'Calculating Results for Accuracy of Breeding Value Estimations...';
+ document.getElementById("runningDog").style.visibility = 'visible';
+ //alert("Now Sending!");
+ },
+ success: function (data, msg) {
+ if(data != ''){
+ //console.log(data);
+ data_Vue.plottingData.ResAccBVE = JSON.parse(data);
+ data_Vue.Summary_AccBVE = data_Vue.Summary.filter(function(x){
+ return(data_Vue.plottingData.ResAccBVE[x.id][0].tval != "NA");
+ });
+ //plottingResultQTL(JSON.parse(data));
+ }else{
+ alert("Failed to plot KS. Please run the Simulation first!");
+ }
+ },
+ failure: function(msg)
+ {
+ alert("Failed to plot KS. Please run the Simulation first!");
+ },
+ complete: function(obj, msg){
+ document.getElementById("runningDog").style.visibility = 'hidden';
+ //document.getElementById("runningDog").innerHTML = '';
+ //alert(msg);
+ //console.log(obj);
+ },
+ dataType: "text",
+ });
+}
+
+
+function clearResult(){
+ document.getElementById("Rout_Div").innerHTML = '';
+ document.getElementById("Result_Summary").innerHTML = '';
+ data_Vue.plottingData = new myPlottingData();
+ for(let i=0; i< data_Vue.traitsinfo.length; i++){
+ Plotly.purge('ResgMean_Div'+(i+1));
+ }
+ for(let i=0; i< data_Vue.traitsinfo.length; i++){
+ Plotly.purge('RespMean_Div'+(i+1));
+ }
+ for(let i=0; i< data_Vue.selection_index.length; i++){
+ Plotly.purge('ResAccBVE_Div'+(i+1));
+ }
+ for(let i=0; i< 2; i++){
+ Plotly.purge('ResRel_Div'+(i+1));
+ }
+ for(let i=0; i< 1; i++){
+ Plotly.purge('ResRelbetweenC_Div'+(i+1));
+ }
+ for(let i=0; i< 3; i++){
+ Plotly.purge('ResQTL_Div'+(i+1));
+ }
+ data_Vue.runned=false;
+}
+
+
+
+var A = [[1,0,0],[0,1,0], [0,0,1]];
+//console.log(numeric.eig(A).lambda.x);
+
+
diff --git a/public/javascript/Rmodule_old.js b/public/javascript/Rmodule_old.js
new file mode 100644
index 0000000..25259d5
--- /dev/null
+++ b/public/javascript/Rmodule_old.js
@@ -0,0 +1,771 @@
+//*************************************************************************************************//
+//*********** Functions for running R Simulation ***********************************//
+function checkRunTime(){
+ var nodes = data_Vue.nodes.get();
+
+ var nInd = 0;
+ var nF = 0;
+ for(let i=0;i < nodes.length; i++){
+ if(nodes[i].Founder == 'Yes'){
+ nF = nF + parseInt(nodes[i]['Number of Individuals']);
+ }
+ nInd = nInd + parseInt(nodes[i]['Number of Individuals']);
+ }
+
+ if(data_Vue.geninfo['Chromosomes Info'].length > 0){
+ var nsnp = data_Vue.geninfo['Chromosomes Info'][0].Length * data_Vue.geninfo['Chromosomes Info'][0].MD;
+ var Morgan = data_Vue.geninfo['Chromosomes Info'][0].Length * data_Vue.geninfo['Chromosomes Info'][0].Recombination /100;
+ }else{
+ var nsnp = data_Vue.geninfo['Max Number of SNPs'];
+ var Morgan = 5;
+ }
+
+ var edges = data_Vue.edges.get();
+ var nRep = 0;
+ var nZucht = 0;
+ for(let i=0;i < edges.length; i++){
+ if(edges[i]['Breeding Type'] == 'Repeat'){
+ nRep = edges[i]['Number of Repeat'];
+ }
+ if(edges[i]['Breeding Type'] == 'Selection' & edges[i]['Selection Type'] == 'BVE'){
+ nZucht++;
+ }
+ }
+ console.log(nF);
+ console.log(nsnp);
+ console.log(nInd);
+ var comptime = nF*nsnp/1000000 + 0.0002*nInd*Morgan;
+ return comptime;
+}
+
+function runningR(){
+ data_Vue.plottingData = new myPlottingData();
+ var jsondata = JSON.stringify(exportNetwork());
+ //console.log(jsondata);
+ alert("Approx. simulation running time: " + Math.round(checkRunTime()/60*2.6*100)/100 + "minutes.");
+
+ $.ajax
+ ({
+ type: "POST",
+ url: './Rsim',
+ data: {jsondata : jsondata},
+ beforeSend: function() {
+ document.getElementById("runningDog").innerHTML = 'MoBPS is running .... please wait';
+ document.getElementById("runningDog").style.visibility = 'visible';
+ //alert("Now Sending!");
+ },
+ success: function (data, msg) {
+ //console.log(data);
+ alert("Simulation Finished!");
+ data_Vue.runned = true;
+ document.getElementById("Rout_Div").innerHTML = data;
+ writeSum();
+ },
+ error: function(obj, msg, err)
+ {
+ alert(err);
+ },
+ complete: function(obj, msg){
+ document.getElementById("runningDog").style.visibility = 'hidden';
+ document.getElementById("runningDog").innerHTML = '';
+ //alert(msg);
+ //console.log(obj);
+ },
+ dataType: "text",
+ });
+}
+
+function writeSum(){
+ var file = data_Vue['geninfo']['Project Name'] + 'Summary'
+
+ $.ajax
+ ({
+ type: "POST",
+ url: './JSON',
+ data: {file : file},
+ success: function (data, msg) {
+ //console.log(data);
+ data_Vue.plottingData.Summary = JSON.parse(data);
+ data = data_Vue.plottingData.Summary;
+ var el = document.getElementById("Result_Summary");
+ el.innerHTML = "==> " + "Project " + data_Vue.geninfo["Project Name"]+ " successfully processed in R." + " ";
+ el.innerHTML += " Founders: " + " ";
+ for(let i =0; i Cohort " + Object.keys(data)[i] + " with " + (Object.values(data)[i].trep[0] - 1) + " repetitions. ";
+ }
+ }
+ el.innerHTML += " Non-founders: " + " ";
+ for(let i =0; i Cohort " + Object.keys(data)[i] + " with " + (Object.values(data)[i].trep[0] - 1) + " repetitions. ";
+ }
+ }
+
+ },
+ error: function(obj, msg, err)
+ {
+ alert(err);
+ },
+ dataType: "text",
+ });
+}
+
+//*************************************************************************************************//
+//*********** Functions for plotting results after R Simulation ***********************************//
+function boxdata(y, name){
+ this.y = y;
+ this.name = name;
+ this.marker = {color: 'rgba(79, 90, 117, 0.5)'};
+ this.type = 'box';
+ this.boxpoints = 'Outliers';
+ this.boxmean = true;
+}
+
+// BVE
+function plottingBVE(flag){
+ var file = data_Vue['geninfo']['Project Name'] + 'BV';
+
+ $.ajax
+ ({
+ type: "POST",
+ url: './JSON',
+ data: {file : file},
+ success: function (data, msg) {
+ //console.log(data);
+ if(data != ''){
+ var plottype = document.getElementById("plottingType").value;
+ if(plottype == "By Cohorts"){
+ plottingBVE_cohorts(JSON.parse(data).val, flag);
+ }
+ if(plottype == "By Time"){
+ plottingBVE_time(JSON.parse(data), flag);
+ }
+ }else{
+ alert("Failed to plot BVE. Please run the Simulation first!");
+ }
+ },
+ failure: function(msg)
+ {
+ alert("Failed to plot BVE. Please run the Simulation first!");
+ },
+ dataType: "text",
+ });
+}
+
+function plottingBVE_time(data, flag){
+
+ var traces = [];
+ var keys = Object.keys(data.val);
+
+ if(flag =="newWin"){
+ var newW = window.open('about:blank', 'popoutWindow', '');
+ newW.document.write("");
+ for(let j=0; j ");
+ }
+ newW.document.write("");
+ }
+
+ // color:
+ var colors = {};
+ for(let i=0; i < keys.length; i++){
+ if(colors[data.ttnames[i]] == undefined){
+ console.log(data.ttnames[i]);
+ var red = ((Math.floor(i/3)+1)*85)%255;
+ var green = ((Math.floor(i/6)+1)*85)%255;
+ var blue = ((i+1)*85)%255;
+ colors[data.ttnames[i]] = {color: "rgb("+red+","+green+","+blue+")"};
+ }
+ }
+
+ console.log(data);
+ for(let j=0; j ");
+ for(let j=0; j ");
+ }
+ newW.document.write("");
+ }
+
+ for(let j=0; j = si.length) {
+ var k = to - si.length + 1;
+ while (k--) {
+ si.push(undefined);
+ }
+ }
+ si.splice(to, 0, si.splice(from, 1)[0]);
+ return si;
+};
+
+
// if we use Variables for the # individuals, we need to update node.individuals:
function updateIndividuals(ivar){
var item = data_Vue.individualsVar_options.filter(function(vv){ return(vv.name == ivar)})[0];
@@ -871,37 +952,116 @@ function updateSpeciesData(value){
// function to export Data into OutputArea:
function exportNetwork() {
- exportArea = document.getElementById('OutputArea');
- exportArea.value = "";
-
- if(data_Vue.geninfo['Chromosomes of Equal Length'] == 'Yes'){
- data_Vue.geninfo["Chromosomes Info"] = data_Vue.chromo_display.slice(0,1);
- }else{
- data_Vue.geninfo["Chromosomes Info"] = data_Vue.chromo_display;
+ exportArea = document.getElementById('OutputArea');
+ exportArea.value = "";
+
+ if(data_Vue.geninfo['Chromosomes of Equal Length'] == 'Yes'){
+ data_Vue.geninfo["Chromosomes Info"] = data_Vue.chromo_display.slice(0,1);
+ }else{
+ data_Vue.geninfo["Chromosomes Info"] = data_Vue.chromo_display;
+ }
+
+ var mat1 = [];
+ var mat2 = [];
+ var row1;
+ var row2;
+
+ // getting array list
+ var listArray5 = [];
+ for(let a=0; a < data_Vue.traitsinfo.length; a++){
+ listArray5.push(data_Vue.traitsinfo[a]['Trait Name']);
+ }
+
+ if(data_Vue['Upload_CorrFile'] == 'Yes') {
+ var mat1 = data_Vue.mymatrix1;
+ var mat2 = data_Vue.mymatrix2;
+ }
+ else if (typeof localStorage.getItem("movetrait") !== "undefined" & localStorage.getItem("movetrait") === "yes") {
+ var arrayLength = listArray5.length;
+
+ for(let i=0; i < arrayLength; i++){
+ row1 = [];
+ row2 = [];
+ var am = listArray5[i];
+
+ for(let j=0; j <= i; j++){
+ var thisvar = (am+'_'+data_Vue.traitsinfo[j]['Trait Name']);
+ var thisvar2 = (am+'_'+data_Vue.traitsinfo[j]['Trait Name']);
+
+ if (thisvar === null) {
+ var thisvar = (data_Vue.traitsinfo[j]['Trait Name']+'_'+am);
+ }
+ if (thisvar2 === null) {
+ var thisvar2 = (data_Vue.traitsinfo[j]['Trait Name']+'_'+am);
+ }
+
+ if (i == j) {
+ row1.push("1");
+ row2.push("1");
+ }
+ else {
+ row1.push(JSON.parse(localStorage.getItem(thisvar)));
+ row2.push(JSON.parse(sessionStorage.getItem(thisvar2)));
+ }
+ }
+
+ mat1.push(row1);
+ mat2.push(row2);
+ }
+ }
+ else {
+ for(let i=0; i < data_Vue.traitsinfo.length; i++){
+ row1 = [];
+ row2 = [];
+ for(let j=0; j <= i; j++){
+ row1.push(data_Vue.matrix[i].row[j].val);
+ row2.push(data_Vue.matrix2[i].row[j].val);
+ }
+ mat1.push(row1);
+ mat2.push(row2);
+ }
+ }
+
+
+ // getting SI values after dragging
+ if (typeof localStorage.getItem("movetrait") !== "undefined" & localStorage.getItem("movetrait") === "yes") {
+ var siKeys = Object.keys(data_Vue.selection_index[0]);
+ siKeys.shift(); //remove "Name" from the array
+ newSIKey = trait_move(siKeys, data_Vue.geninfo['Traits moveFrom'], data_Vue.geninfo['Traits moveTo']);
+ var siArray = [];
+ for(let u=0; u < data_Vue.selection_index.length; u++){
+ var siObject = {};
+ var getSIName = data_Vue.selection_index[u]['Name'];
+ siObject['Name'] = localStorage.getItem(getSIName+'_'+'Name');
+ for(let v=0; v < newSIKey.length; v++){
+ siObject[newSIKey[v]] = localStorage.getItem(getSIName+'_'+newSIKey[v]);
+ }
+ siArray.push(siObject);
+ }
+ data_Vue.selection_index = siArray;
}
- var mat1 = [];
- var mat2 = [];
- var row1;
- var row2;
-
- if(data_Vue['Upload_CorrFile'] == 'Yes') {
- var mat1 = data_Vue.mymatrix1;
- var mat2 = data_Vue.mymatrix2;
- }
- else {
- for(let i=0; i < data_Vue.traitsinfo.length; i++){
- row1 = [];
- row2 = [];
- for(let j=0; j <= i; j++){
- row1.push(data_Vue.matrix[i].row[j].val);
- row2.push(data_Vue.matrix2[i].row[j].val);
- }
- mat1.push(row1);
- mat2.push(row2);
- }
+ // getting PC values after dragging
+ if (typeof localStorage.getItem("movetrait") !== "undefined" & localStorage.getItem("movetrait") === "yes") {
+ var pcKeys = Object.keys(data_Vue.phenotyping_class[0]);
+ pcKeys.shift(); //remove "Name" from the array
+ pcKeys.shift(); // remove Phenotyping Cost from the array
+ newPCKey = trait_move(pcKeys, data_Vue.geninfo['Traits moveFrom'], data_Vue.geninfo['Traits moveTo']);
+ var pcArray = [];
+ for(let p=0; p < data_Vue.phenotyping_class.length; p++){
+ var pcObject = {};
+ var getPCName = data_Vue.phenotyping_class[p]['Name'];
+ pcObject['Name'] = localStorage.getItem(getPCName+'_'+'Name');
+ pcObject['Cost of phenotyping'] = localStorage.getItem(getPCName+'_'+'Cost of phenotyping');
+ for(let q=0; q < newPCKey.length; q++){
+ pcObject[newPCKey[q]] = localStorage.getItem(getPCName+'_'+newPCKey[q]);
+ }
+ pcArray.push(pcObject);
+ }
+ data_Vue.phenotyping_class = pcArray;
}
+
var Intern = {
show_matrix_element : data_Vue.show_matrix_element,
counter_pheno : data_Vue.counter_pheno,
@@ -1439,6 +1599,35 @@ function updateUser(){
function loadData(ind){
+ localStorage.clear();
+ sessionStorage.clear();
+ document.getElementById("excelToArray").value = "";
+ if(ind != "Create_New_123456YYYY"){
+ $.ajax
+ ({
+ type: "POST",
+ url: '/loadproject',
+ data: {name : ind},
+ success: function (data, msg) {
+ if(data != ''){
+ data_Vue.filename = data[0].name;
+ importNetwork_intern(data[0].json);
+ if(data[0].versions.length > 0){
+ data_Vue.versions = data[0].versions.reverse();
+ }
+ document.getElementById("Version").value = "recent";
+ data_Vue.project_saved = true;
+ }else{
+ alert("Loading Data failed. Contact administrator.");
+ }
+ },
+ });
+ }else{
+ location.reload();
+ }
+}
+
+function loadData_old(ind){
// console.log(ind);
if(ind != "Create_New_123456YYYY"){
$.ajax
@@ -1526,15 +1715,5 @@ function importexcelToArray(evt) {
excelToArray.parseExcel(selectedFile[0]);
}
-function saveMatrixToProject(name) {
- if(!name){
- var name = data_Vue.geninfo['Project Name'];
- }else{
- data_Vue.geninfo['Project Name'] = name;
- }
- saveProject(name);
- loadData(name);
-}
-
// excel to Array end
diff --git a/public/javascript/network_A.js b/public/javascript/network_A.js
new file mode 100644
index 0000000..c255c9f
--- /dev/null
+++ b/public/javascript/network_A.js
@@ -0,0 +1,1731 @@
+Vue.component('treeselect', VueTreeselect.Treeselect);
+//Vue.component('slider', VueSlider.Slider);
+//**************** Network Script **********************************//
+//*********************************************************************//
+// define the classe myNode and myEdge with default values
+function myNode (id, x, y) {
+ this['id'] = id;
+ this['Number of Individuals'] = "";
+ this['x'] = x;
+ this['y'] = y;
+ this['individualsVar'] = "";
+ this['Founder'] = "No";
+ this['Path'] = "";
+ this['Proportion of Male'] = "1";
+ this['BV Plot'] = 'Yes';
+ this['Sex'] = "Male";
+ this['Phenotyping Class'] = "Default PhenoC";
+ this['Housing Cost Class'] = "Default Housing Cost";
+ this['Proportion of genotyped individuals'] = 1;
+ this['Genotype generation'] = "Random-sampling";
+ this['Genotype generation subpopulation'] = "Population 1";
+ }
+
+function myEdge (fr, to) {
+ this['from'] = fr;
+ this['to'] = to;
+ this['Breeding Type'] = "";
+ this['Selection Type'] = "Random";
+ this['Number of Repeat'] = "";
+ //this['Selection Proportion'] = ""; -> we do not save it, always calculate from Number of Individuals
+ this['Relationship Matrix'] = "";
+ this['BVE Method'] = "";
+ //this['New Mutation Rate'] = "";
+ //this['New Remutation Rate'] = "";
+ //this['Number of Rec per M'] = "";
+ this['Use Offspring for BVE'] = "";
+ this['Time Needed'] = 0;
+ this['id'] = fr + '_'+ to;
+ // in order to save the parameters that are using variables, should match indivdualsVar_options
+ this['useVar'] =[];
+ this['Selection Index']="Default Index";
+ this['Cohorts used in BVE'] = "";
+ this['Manuel selected cohorts'] = [];
+ this['OGC'] = "No";
+ this['Depth of Pedigree'] = "";
+ this['Max Offspring'] = "Inf";
+}
+
+// define the classe myGeneral with default values for General information:
+function myGeneral () {
+ this['Project Name'] = '';
+ this['Species'] = '';
+ this['Use Ensembl Map'] = "Yes";
+ this['Ensembl Dataset'] = "";
+ this['Max Number of SNPs'] = 5000;
+// this['Ensembl Filter'] = "";
+// this['Ensembl Filter Values'] = "";
+ this['Number of Chromosomes'] = '';
+ this['Chromosomes of Equal Length'] = 'Yes';
+ this['Time Unit'] = 'Weeks';
+ this['Use Own Map'] = 'Yes';
+ this['Own Map Path'] = '';
+ // this['chromo will be filled with myChromo elements later=
+ this['Chromosomes Info'] = [];
+ this['Upload_CorrFile'] = 'No';
+ this['curUserGroup'] = '';
+}
+
+function myTrait (ind){
+ this['Trait Name'] = "Pheno " + ind,
+ this['Trait Unit'] = "",
+ this['Trait Mean'] = Math.round(Math.random()*100) +1,
+ this['Trait Std Deviation'] = Math.round(Math.random()*10) +1,
+ this['Trait Heritability'] = Math.round(Math.random()*100)/100,
+ this['Trait Number of Polygenic Loci'] = Math.round(Math.random()*10000),
+ this['Trait Major QTL'] = 0,
+ this['Trait Value per Unit'] = 0,
+ this['Trait QTL Info'] = []
+}
+
+function mySNP (ind){
+ this['QTL SNP Number'] = ind,
+ this['QTL ID'] = 'QTL'+ind,
+ this['QTL BP'] = Math.round(Math.random()*1000000),
+ this['QTL Chromosome'] = 1,
+ this['QTL Effect AA'] = Math.round(Math.random()*10) +1,
+ this['QTL Effect AB'] = Math.round(Math.random()*10) +1,
+ this['QTL Effect BB'] = Math.round(Math.random()*10) +1,
+ this['QTL Allele Frequency'] = Math.round(Math.random()*100)/100,
+ this['QTL Optional Info'] = ''
+}
+
+function mySNPsub (ind){
+ this['QTL SNP Number'] = ind,
+ this['QTL ID'] = 'QTL'+ind,
+ this['QTL BP'] = Math.round(Math.random()*1000000),
+ this['QTL Chromosome'] = 1,
+ this['QTL Allele Frequency'] = Math.round(Math.random()*100)/100,
+ this['QTL Optional Info'] = ''
+}
+
+function myEconomy (){
+ this['Fixed Cost'] = 0,
+ this['Interest Rate'] = 0,
+ this['Genotyping Cost'] = 50,
+ this['Animal Housing Costs'] = [{Name: "Default Housing Cost", Cost: 0}, {Name: 'Male individuals', Cost: 2000}, {Name: 'Female individuals', Cost: 3000}]
+}
+
+function myCulling (){
+ this['culling_reasons'] = []
+}
+
+function myPopulation (){
+ this['subpopulation_list'] = [{Name: "Population 1", beta1 : 1, beta2: 1, share0: 0, share1: 0, fixed_freq: 0, 'QTL Info': []}]
+}
+
+function mySelectionScaling (selection_index){
+ var len = selection_index.length;
+ var scaling_var = [];
+ for(let i=0; i 0){
+ for(let i=0; i= 1 ){
+ alert("Animal Housing Costs class is still in used by "+items.length+ " nodes. Removing not possible!");
+ return;
+ }
+ this.economy['Animal Housing Costs'].splice(ind,1);
+
+ },
+
+ removeCulling: function(si, ind){
+
+ this.culling['culling_reasons'].splice(ind,1);
+
+ },
+ removeSub: function(si, ind){
+
+ this.subpopulation['subpopulation_list'].splice(ind,1);
+
+ },
+
+ // add a new selection index:
+ addSI: function(name){
+ if(name){
+ var val = name;
+ }else{
+ var val = document.getElementById("newSI").value;
+ }
+ for(let i=0; i= 1 ){
+ alert("Selection index is still in used by "+items.length+ " edges. Removing not possible!");
+ return;
+ }
+
+ this.selection_index.splice(ind,1);
+ this.selection_index_scaling.splice(ind,1);
+
+ },
+ removePC: function(si, ind){
+
+ var items = this.nodes.getIds({
+ filter: function (item) {
+ return item['Phenotyping Class'] == si.Name;
+ }
+ });
+
+ if(items.length >= 1 ){
+ alert("Phenotyping Class is still in used by "+items.length+ " nodes. Removing not possible!");
+ return;
+ }
+ this.phenotyping_class.splice(ind,1);
+
+ },
+ // create/remove new Chromosomes on change of the # Chromosomes, depending on
+ // whether new number is greater or smaller --> remove from bottom
+ createChrom: function(){
+ if(this.geninfo['Chromosomes of Equal Length'] == 'No'){
+ this.geninfo['Number of Chromosomes'] = Math.round(Number(this.geninfo['Number of Chromosomes']));
+ var val = this.geninfo['Number of Chromosomes'];
+
+ }else{
+ var val = 1;
+ }
+ var len = this.geninfo['Chromosomes Info'].length;
+ var diff = val - len;
+
+ if(diff < 0){
+ this.geninfo['Chromosomes Info'].splice(diff);
+ }else if (diff > 0){
+ while (len < val){
+ var newChromo = new myChromo(100,500,1);
+ this.geninfo['Chromosomes Info'].push(newChromo);
+ len++;
+ }
+ }
+ },
+ // create/remove new QTL on change of the # QTls, depending on
+ // whether new number is greater or smaller --> remove from bottom
+ createQTL: function(ind){
+ this.traitsinfo[ind]['Trait Major QTL'] = Math.round(Number(this.traitsinfo[ind]['Trait Major QTL']));
+ var val = this.traitsinfo[ind]['Trait Major QTL'];
+ var len = this.traitsinfo[ind]['Trait QTL Info'].length;
+ var diff = val - len;
+
+ if(diff < 0){
+ this.traitsinfo[ind]['Trait QTL Info'].splice(diff);
+ }else if (diff > 0){
+ while (len < val){
+ this.counter_qtl++;
+ var newSNP = new mySNP(this.counter_qtl);
+ this.traitsinfo[ind]['Trait QTL Info'].push(newSNP);
+ len++;
+ }
+ }
+
+ },
+ createQTLsub: function(ind){
+ this.subpopulation['subpopulation_list'][ind]['fixed_freq'] = Math.round(Number(this.subpopulation['subpopulation_list'][ind]['fixed_freq']));
+ var val = this.subpopulation['subpopulation_list'][ind]['fixed_freq'];
+ var len = this.subpopulation['subpopulation_list'][ind]['QTL Info'].length;
+ var diff = val - len;
+
+ if(diff < 0){
+ this.subpopulation['subpopulation_list'][ind]['QTL Info'].splice(diff);
+ }else if (diff > 0){
+ while (len < val){
+ this.counter_qtl_sub++;
+ var newSNPsub = new mySNPsub(this.counter_qtl_sub);
+ this.subpopulation['subpopulation_list'][ind]['QTL Info'].push(newSNPsub);
+ len++;
+ }
+ }
+
+ },
+ // remove clicked QTL
+ removeQTL: function(trait, snp){
+ var indT = this.traitsinfo.indexOf(trait);
+ var indS = this.traitsinfo[indT]['Trait QTL Info'].indexOf(snp);
+ this.traitsinfo[indT]['Trait QTL Info'].splice(indS,1);
+ this.traitsinfo[indT]['Trait Major QTL']--;
+
+ },
+
+ removeQTLsub: function(subpop, trait, snp){
+ var indA = this.subpopulation.indexOf(subpop)
+ var indT = this.subpopulation[indA].indexOf(trait);
+ var indS = this.subpopulation[indA][indT]['QTL Info'].indexOf(snp);
+
+ this.subpopulation[indA][indT]['QTL Info'].splice(indS,1);
+ this.subpopulation[indA][indT]['fixed_freq']--;
+
+ },
+
+
+ // add a new Phenotype, then also add correlation matrices:
+ addPheno: function(){
+ this.counter_pheno++;
+ var len = this.traitsinfo.length;
+ var new_trait = new myTrait(this.counter_pheno);
+ this.traitsinfo.push(new_trait);
+
+ this.matrix.push({row: new myArray(len+1)});
+ this.matrix2.push({row: new myArray(len+1)});
+ this.show_matrix_element.push({show:true});
+
+ },
+ // remove clicked Phenotype
+ removePheno: function(ind){
+ var len = this.traitsinfo.length;
+ this.traitsinfo.splice(ind,1);
+
+ // remove also correlation matrix elements
+ // associated with this phenotype
+ if(len > 1){
+ for(let i=ind+1; i< len; i++){
+ this.matrix[i].row.splice(ind,1);
+ this.matrix2[i].row.splice(ind,1);
+ }
+ this.matrix.splice(ind,1);
+ this.matrix2.splice(ind,1);
+ }else{
+ this.matrix = [];
+ this.matrix2 = [];
+ }
+ this.show_matrix_element.splice(ind, 1);
+
+ // remove also selection index, phenotyping classes
+ // associated with this phenotype
+ for(let i=0; i= 1){
+ for(ii=0; ii < items.length; ii++){
+ this.nodes.update({id: items[ii], 'Number of Individuals': wert, title: items[ii]+':'+wert+' Ind'});
+ }
+ //network.setData({nodes: this.nodes, edges: this.edges});
+ }
+ },
+ // will updates all edges in case of Variable' value is changing:
+ updateEdgesVar: function(vv){
+ var wert = vv.value;
+ var ind = this.individualsVar_options.indexOf(vv);
+
+ var items = this.edges.get({
+ filter: function (item) {
+ return item.useVar[ind] != '';
+ }
+ });
+ if(items.length >= 1){
+ for(ii=0; ii < items.length; ii++){
+ var new_E = {id: items[ii].id};
+ new_E[items[ii].useVar[ind]] = wert;
+ new_E.title = items[ii].Breedingtype
+ //console.log(new_E);
+ this.edges.update(new_E);
+ }
+ //network.setData({nodes: this.nodes, edges: this.edges});
+ }
+
+ },
+ // remove Variable if no Nodes are using it:
+ removeVariable: function(vv){
+ var wert = vv.value;
+ var ind = this.individualsVar_options.indexOf(vv);
+
+ var items = this.nodes.getIds({
+ filter: function (item) {
+ return item.individualsVar == vv.name;
+ }
+ });
+
+ var items2 = this.edges.getIds({
+ filter: function (item) {
+ return item.useVar[ind] != '';
+ }
+ });
+
+ if(items.length >= 1 | items2.length >= 1){
+ alert("Variable ist still in used by "+items.length+ " nodes and "+items2.length+" edges. Removing not possible!");
+ return;
+ }
+ this.individualsVar_options.splice(ind,1);
+
+ // prepare edges for the use of variables:
+ var items = this.edges.get();
+ for(let i=0; i< items.length; i++){
+ items[i].useVar.splice(ind, 1);
+ }
+ this.edges.update(items);
+ },
+ }
+})
+
+//******************************************************************************************//
+//**************** own functions required to manually update data_Vue or DOM ***************//
+
+
+function getMatrix() {
+ data_Vue['Upload_CorrFile'] == 'No';
+ localStorage.setItem("movetrait", "yes");
+
+ for(let i=0; i < data_Vue.traitsinfo.length; i++){
+ for(let j=0; j <= i; j++){
+
+ var matrixval1 = data_Vue.matrix[i].row[j].val;
+ var matrixval2 = data_Vue.matrix2[i].row[j].val;
+
+ localStorage.setItem(data_Vue.traitsinfo[i]['Trait Name']+'_'+data_Vue.traitsinfo[j]['Trait Name'], JSON.stringify(matrixval1));
+ localStorage.setItem(data_Vue.traitsinfo[j]['Trait Name']+'_'+data_Vue.traitsinfo[i]['Trait Name'], JSON.stringify(matrixval1));
+
+ sessionStorage.setItem(data_Vue.traitsinfo[i]['Trait Name']+'_'+data_Vue.traitsinfo[j]['Trait Name'], JSON.stringify(matrixval2));
+ sessionStorage.setItem(data_Vue.traitsinfo[j]['Trait Name']+'_'+data_Vue.traitsinfo[i]['Trait Name'], JSON.stringify(matrixval2));
+ }
+ }
+
+}
+
+
+function getSI() {
+ for(let u=0; u < data_Vue.selection_index.length; u++){
+ var thisSIName = data_Vue.selection_index[u]['Name'];
+ for(var key in data_Vue.selection_index[u]) {
+ var thisSIVar = key;
+ var thisSIVal = data_Vue.selection_index[u][key];
+ localStorage.setItem(thisSIName+'_'+thisSIVar, thisSIVal);
+ }
+ }
+}
+
+function getPC() {
+ for(let x=0; x < data_Vue.phenotyping_class.length; x++){
+ var thisPCName = data_Vue.phenotyping_class[x]['Name'];
+ for(var key in data_Vue.phenotyping_class[x]) {
+ var thisPCVar = key;
+ var thisPCVal = data_Vue.phenotyping_class[x][key];
+ localStorage.setItem(thisPCName+'_'+thisPCVar, thisPCVal);
+ }
+ }
+}
+
+function trait_move(si, from, to) {
+ if (to >= si.length) {
+ var k = to - si.length + 1;
+ while (k--) {
+ si.push(undefined);
+ }
+ }
+ si.splice(to, 0, si.splice(from, 1)[0]);
+ return si;
+};
+
+
+// if we use Variables for the # individuals, we need to update node.individuals:
+function updateIndividuals(ivar){
+ var item = data_Vue.individualsVar_options.filter(function(vv){ return(vv.name == ivar)})[0];
+ if(item != undefined){
+ data_Vue.active_node['Number of Individuals'] = item.value;
+ }else{
+ data_Vue.active_node['Number of Individuals'] = ivar;
+ }
+}
+
+// if we use Variables for the Edges, we need to update their data according to the variables' value:
+function updateVar(param, ivar){
+ var ind_old = data_Vue.active_edge.useVar.indexOf(param);
+ //console.log(ind_old);
+ data_Vue.active_edge.useVar[ind_old] = '';
+
+ var item = data_Vue.individualsVar_options.filter(function(vv){ return(vv.name == ivar)})[0];
+ if(item != undefined){
+ data_Vue.active_edge[param] = item.value;
+ data_Vue.active_edge.useVar[data_Vue.individualsVar_options.indexOf(item)] = param;
+ }else{
+ data_Vue.active_edge[param] = ivar;
+ }
+}
+
+// if we change Species on Selection, we need to change the default Values:
+function updateSpeciesData(value){
+ Object.assign(data_Vue.geninfo, genome_default_data[value]);
+ //data_Vue.chromo = data_Vue.geninfo['Chromosomes Info'];
+ data_Vue.traitsinfo = data_Vue.geninfo['Default Traits'];
+ data_Vue.counter_pheno = data_Vue.traitsinfo.length;
+ data_Vue.matrix = data_Vue.geninfo['Phenotypic Correlation'];
+ data_Vue.matrix2 = data_Vue.geninfo['Genetic Correlation'];
+
+ for(let i =0; i< data_Vue.traitsinfo.length; i++){
+ data_Vue.show_matrix_element.push({show:true});
+ }
+
+ //if(data_Vue.traitsinfo.length > 0){
+ // data_Vue.addSI('Default Index');
+ // data_Vue.addPC('Default PhenoC');
+ //}
+
+ // update Ensembl data
+ data_Vue.geninfo['Ensembl Dataset'] = data_Vue.ensembl_options[value].Dataset;
+ data_Vue.geninfo['Ensembl Filter'] = data_Vue.ensembl_options[value].Filter;
+ data_Vue.geninfo['Ensembl Filter Values'] = data_Vue.ensembl_options[value].Value;
+
+ // delete unnessary redundant data:
+ delete data_Vue.geninfo['Phenotypic Correlation'];
+ delete data_Vue.geninfo['Genetic Correlation'];
+ delete data_Vue.geninfo['Default Traits'];
+}
+
+// function to export Data into OutputArea:
+
+function exportNetwork() {
+ exportArea = document.getElementById('OutputArea');
+ exportArea.value = "";
+
+ if(data_Vue.geninfo['Chromosomes of Equal Length'] == 'Yes'){
+ data_Vue.geninfo["Chromosomes Info"] = data_Vue.chromo_display.slice(0,1);
+ }else{
+ data_Vue.geninfo["Chromosomes Info"] = data_Vue.chromo_display;
+ }
+
+ var mat1 = [];
+ var mat2 = [];
+ var row1;
+ var row2;
+
+ // getting array list
+ var listArray5 = [];
+ for(let a=0; a < data_Vue.traitsinfo.length; a++){
+ listArray5.push(data_Vue.traitsinfo[a]['Trait Name']);
+ }
+
+ if(data_Vue['Upload_CorrFile'] == 'Yes') {
+ var mat1 = data_Vue.mymatrix1;
+ var mat2 = data_Vue.mymatrix2;
+ }
+ else if (typeof localStorage.getItem("movetrait") !== "undefined" & localStorage.getItem("movetrait") === "yes") {
+ var arrayLength = listArray5.length;
+
+ for(let i=0; i < arrayLength; i++){
+ row1 = [];
+ row2 = [];
+ var am = listArray5[i];
+
+ for(let j=0; j <= i; j++){
+ var thisvar = (am+'_'+data_Vue.traitsinfo[j]['Trait Name']);
+ var thisvar2 = (am+'_'+data_Vue.traitsinfo[j]['Trait Name']);
+
+ if (thisvar === null) {
+ var thisvar = (data_Vue.traitsinfo[j]['Trait Name']+'_'+am);
+ }
+ if (thisvar2 === null) {
+ var thisvar2 = (data_Vue.traitsinfo[j]['Trait Name']+'_'+am);
+ }
+
+ if (i == j) {
+ row1.push("1");
+ row2.push("1");
+ }
+ else {
+ row1.push(JSON.parse(localStorage.getItem(thisvar)));
+ row2.push(JSON.parse(sessionStorage.getItem(thisvar2)));
+ }
+ }
+
+ mat1.push(row1);
+ mat2.push(row2);
+ }
+ }
+ else {
+ for(let i=0; i < data_Vue.traitsinfo.length; i++){
+ row1 = [];
+ row2 = [];
+ for(let j=0; j <= i; j++){
+ row1.push(data_Vue.matrix[i].row[j].val);
+ row2.push(data_Vue.matrix2[i].row[j].val);
+ }
+ mat1.push(row1);
+ mat2.push(row2);
+ }
+ }
+
+
+ // getting SI values after dragging
+ if (typeof localStorage.getItem("movetrait") !== "undefined" & localStorage.getItem("movetrait") === "yes") {
+ var siKeys = Object.keys(data_Vue.selection_index[0]);
+ siKeys.shift(); //remove "Name" from the array
+ newSIKey = trait_move(siKeys, data_Vue.geninfo['Traits moveFrom'], data_Vue.geninfo['Traits moveTo']);
+ var siArray = [];
+ for(let u=0; u < data_Vue.selection_index.length; u++){
+ var siObject = {};
+ var getSIName = data_Vue.selection_index[u]['Name'];
+ //siObject['Name'] = JSON.parse(localStorage.getItem(getSIName+'_'+'Name'));
+ siObject['Name'] = localStorage.getItem(getSIName+'_'+'Name');
+ for(let v=0; v < newSIKey.length; v++){
+ //siObject[newSIKey[v]] = JSON.parse(localStorage.getItem(getSIName+'_'+newSIKey[v]));
+ siObject[newSIKey[v]] = localStorage.getItem(getSIName+'_'+newSIKey[v]);
+ }
+
+ siArray.push(siObject);
+ }
+ data_Vue.selection_index = siArray;
+ }
+
+ // getting PC values after dragging
+ if (typeof localStorage.getItem("movetrait") !== "undefined" & localStorage.getItem("movetrait") === "yes") {
+ var pcKeys = Object.keys(data_Vue.phenotyping_class[0]);
+ pcKeys.shift(); //remove "Name" from the array
+ pcKeys.shift(); // remove Phenotyping Cost from the array
+ newPCKey = trait_move(pcKeys, data_Vue.geninfo['Traits moveFrom'], data_Vue.geninfo['Traits moveTo']);
+ var pcArray = [];
+ for(let p=0; p < data_Vue.phenotyping_class.length; p++){
+ var pcObject = {};
+ var getPCName = data_Vue.phenotyping_class[p]['Name'];
+ pcObject['Name'] = localStorage.getItem(getPCName+'_'+'Name');
+ pcObject['Cost of phenotyping'] = localStorage.getItem(getPCName+'_'+'Cost of phenotyping');
+ for(let q=0; q < newPCKey.length; q++){
+ pcObject[newPCKey[q]] = localStorage.getItem(getPCName+'_'+newPCKey[q]);
+ }
+ pcArray.push(pcObject);
+ }
+ data_Vue.phenotyping_class = pcArray;
+ }
+
+
+ var Intern = {
+ show_matrix_element : data_Vue.show_matrix_element,
+ counter_pheno : data_Vue.counter_pheno,
+ counter_qtl : data_Vue.counter_qtl,
+ counter_qtl_sub : data_Vue.counter_qtl_sub,
+ individualsVar_options : data_Vue.individualsVar_options,
+ genetic_data : data_Vue.genetic_data,
+ runned : data_Vue.runned,
+ };
+
+ var data_to_export = {
+ 'Nodes': data_Vue.nodes.get(),
+ 'Edges': data_Vue.edges.get(),
+ 'Genomic Info': data_Vue.geninfo,
+ 'Trait Info': data_Vue.traitsinfo,
+ 'Selection Index': data_Vue.selection_index,
+ 'Selection Index Scaling': data_Vue.selection_index_scaling,
+ 'Phenotyping Info': data_Vue.phenotyping_class,
+ 'Economy': data_Vue.economy,
+ 'Culling': data_Vue.culling,
+ 'Subpopulation': data_Vue.subpopulation,
+ 'Phenotypic Correlation': mat1,
+ 'PhenotypicResidual': data_Vue.use_phenotypic_cor,
+ 'Genetic Correlation': mat2,
+ 'Intern': Intern,
+ };
+ var exportValue = JSON.stringify(data_to_export, undefined, 2);
+
+ exportArea.value = exportValue;
+
+ resizeExportArea();
+
+ //delete data_Vue.geninfo["Chromosomes Info"];
+ return data_to_export;
+
+}
+
+// function to download network:
+function downloadNetwork(){
+ var jsondata = JSON.stringify(exportNetwork(), undefined, 2);
+ var filename = data_Vue.geninfo['Project Name'] ? data_Vue.geninfo['Project Name'] : "File";
+ var element = document.createElement('a');
+ element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(jsondata));
+ element.setAttribute('download', filename+'.json');
+
+ element.style.display = 'none';
+ document.body.appendChild(element);
+
+ element.click();
+
+ document.body.removeChild(element);
+}
+
+
+
+// function to import Data from OutputArea:
+
+function importNetwork() {
+ var exportArea = document.getElementById('OutputArea');
+ var inputValue = exportArea.value;
+ if(inputValue == ''){
+ alert("Nothing to import. Please paste the JSON file into the text area.");
+ return;
+ }
+ var inputData = JSON.parse(inputValue);
+
+ importNetwork_intern(inputData);
+ data_Vue.project_saved = false;
+
+}
+
+function importNetwork_intern(inputData1) {
+ data_Vue.active_edge = new myEdge();
+ if(data_Vue.runned){
+ clearResult();
+ }
+ var inputData = JSON.parse(JSON.stringify(inputData1));
+ data_Vue.nodes = new vis.DataSet(inputData['Nodes']);
+ data_Vue.edges = new vis.DataSet(inputData['Edges']);
+ data_Vue.geninfo = inputData['Genomic Info'] ? inputData['Genomic Info'] : new myGeneral();
+ data_Vue.traitsinfo = inputData['Trait Info'] ? inputData['Trait Info'] : [];
+ data_Vue.selection_index = inputData['Selection Index'];
+ if(inputData['PhenotypicResidual']){
+ data_Vue.use_phenotypic_cor = inputData['PhenotypicResidual'];
+ } else{
+ data_Vue.use_phenotypic_cor = false;
+ }
+
+ if(inputData['Selection Index Scaling']){
+ data_Vue.selection_index_scaling = inputData['Selection Index Scaling'];
+ } else{
+ data_Vue.selection_index_scaling = new mySelectionScaling(data_Vue.selection_index);
+ }
+
+ if(inputData['Economy']){
+ data_Vue.economy = inputData['Economy'];
+ }else{
+ data_Vue.economy = new myEconomy();
+ }
+ if(inputData['Culling']){
+ data_Vue.culling = inputData['Culling'];
+ }else{
+ data_Vue.culling = new myCulling();
+ }
+ if(inputData['Subpopulation']){
+ data_Vue.subpopulation = inputData['Subpopulation'];
+ }else{
+ data_Vue.subpopulation = new myPopulation();
+ }
+
+ if(inputData['Phenotyping Info']){
+ data_Vue.phenotyping_class = inputData['Phenotyping Info'];
+ }else{
+ // an older Version of JSON file, maually add phenoC
+ data_Vue.phenotyping_class = [{Name: "Default PhenoC"}];
+ for(let i=0; i 0){
+ var matrix = [];
+ var matrix2 = [];
+ var row1;
+ var row2;
+ for(let i=0; i < data_Vue.traitsinfo.length; i++){
+ row1 = [];
+ row2 = [];
+ for(let j=0; j <= i; j++){
+ row1.push({val : mat1[i][j]});
+ row2.push({val : mat2[i][j]});
+ }
+ matrix.push({row : row1});
+ matrix2.push({row : row2});
+ }
+
+ data_Vue.matrix = matrix;
+ data_Vue.matrix2 = matrix2;
+ }else{
+ data_Vue.matrix = [];
+ data_Vue.matrix2 = [];
+ }
+
+ draw();
+ console.log("Loading Data successful.");
+ data_Vue.project_saved = true;
+
+}
+
+function resizeExportArea() {
+ exportArea.style.height = (1 + exportArea.scrollHeight) + "px";
+}
+
+// function to save data to database:
+
+function postProject(name, url, jsondata){
+ $.ajax
+ ({
+ type: "POST",
+ url: url,
+ data: {
+ name: name,
+ jsondata : jsondata,
+ versions: JSON.stringify(data_Vue.versions.reverse()),
+ },
+ success: function (data, msg) {
+ $.post('/database', function(dat){
+ data_Vue.database = dat;
+ //document.getElementById("Project_Name").value = name;
+ })
+ if (typeof localStorage.getItem("movetrait") === "null") {
+ alert("Saving Success!");
+ }
+ data_Vue.project_saved = true;
+ data_Vue.versions = data.reverse();
+ //document.getElementById("Project_Name").value = name; //data_Vue.geninfo['Project Name'];
+ document.getElementById("Version").value = "recent";
+ document.getElementById("SaveAs_Div").style.display = 'none';
+ },
+ failure: function(msg)
+ {
+ alert('Saving Error!');
+ },
+ });
+}
+
+function saveProject(name) {
+ if(!name){
+ var name = data_Vue.geninfo['Project Name'];
+ }else{
+ data_Vue.geninfo['Project Name'] = name;
+ }
+ var jsondata = JSON.stringify(exportNetwork());
+
+ if(data_Vue.versions.length > 10){
+ var r = confirm("Only the 10 most recent versions are saved. The oldest version will be deleted. Do you want to proceed? Alternative: Change the Project Name and save to create a new project");
+ if(!r) return;
+ }
+
+ while(data_Vue.versions.length > 10){
+ data_Vue.versions.pop();
+ }
+
+ if(data_Vue.database.filter(function(obj){ return(obj==name)}).length > 0){
+ postProject(name, "/update", jsondata);
+ }else{
+ postProject(name, "/save", jsondata);
+ }
+
+ data_Vue['Upload_CorrFile'] == 'No';
+}
+
+function deleteProject() {
+ var name = data_Vue.geninfo['Project Name'];
+
+ if(data_Vue.database.filter(function(x){return(x == name)}).length > 0){
+ var r = confirm("The whole project including all older versions will be deleted. Do you want to proceed?");
+ if(r){
+ $.ajax
+ ({
+ type: "POST",
+ url: "/delete",
+ data: {
+ name: name,
+ },
+ success: function (msg) {
+ //loadData(name);
+ console.log("Project deleted.");
+ location.reload();
+ },
+ failure: function(msg)
+ {
+ alert('Delete Error!');
+ },
+ });
+ }
+ }
+}
+
+function saveProjectAs() {
+ document.getElementById("SaveAs_Div").style.display = 'block';
+}
+
+// set the path of Own Map file, after map has been uploaded:
+function setMapPath(){
+ data_Vue.geninfo["Own Map Path"] = "UserMaps/"+data_Vue.user+"_"+document.getElementById('mapFile').files[0].name;
+}
+
+function setGenoPath(){
+ data_Vue.active_node["Path"] = "UserGenos/"+data_Vue.user+"_"+document.getElementById('genoFile').files[0].name;
+}
+//******************************************************************************************//
+//************************* Network functions **********************************************//
+
+var network_data = data_Vue;
+
+function destroy() {
+ if (network !== null) {
+ network.destroy();
+ network = null;
+ }
+}
+
+function draw() {
+ destroy();
+
+ // create a network
+ var container = document.getElementById('mynetwork');
+ var options = {
+ locale: 'en',
+ autoResize: false,
+ layout: {
+ improvedLayout: false,
+ },
+ manipulation: {
+ addNode: function (data, callback) {
+ // creating node:
+ data = new myNode("", data.x, data.y);
+ data_Vue.show_info = 'node';
+ // set default values for DOM:
+ data_Vue.active_node = data;
+ // filling in the popup DOM elements
+ data_Vue.node_operation = "Add Node";
+ editNode(data, clearNodePopUp, callback);
+ },
+ editNode: function (data, callback) {
+ // filling in the popup DOM elements
+ data_Vue.node_operation = "Edit Node";
+ editNode(data, cancelNodeEdit, callback);
+ },
+ addEdge: function (data, callback) {
+ if (typeof data.to === 'object')
+ data.to = data.to.id
+ if (typeof data.from === 'object')
+ data.from = data.from.id
+ //creating edge:
+ data = new myEdge(data.from, data.to);
+ data_Vue.show_info = 'edge';
+ // set default values for DOM:
+ data_Vue.active_edge = data;
+ // calculate Selection Proportion by using number of individuals of parent and offspring nodes:
+ data.useVar = Array(data_Vue.individualsVar_options.length).fill('');
+
+ if (data.from == data.to) {
+ alert("You cannot connect a node to itself.");
+ callback(null);
+ return;
+ }
+ data_Vue.edge_operation = "Add Edge";
+ editEdgeWithoutDrag(data, callback);
+ },
+ editEdge: {
+ editWithoutDrag: function(data, callback) {
+ data_Vue.edge_operation = "Edit Edge";
+ editEdgeWithoutDrag(data,callback);
+ }
+ }
+ },
+ physics: {enabled: false},
+ edges: {
+ arrows: {
+ to: true,
+ },
+ chosen: true,
+ smooth: {
+ type: "diagonalCross",
+ forceDirection: "none",
+ roundness: 0.2
+ },
+ width: 2,
+ },
+ nodes: {
+ shape: 'box',
+ shapeProperties: {borderRadius: 0},
+ },
+ interaction: {
+ hover: true,
+ hoverConnectedEdges: false,
+ selectConnectedEdges: true,
+ },
+ };
+ network = new vis.Network(container, network_data, options);
+
+ network.on("selectNode", function(params){
+ data_Vue.show_info = 'node';
+ data_Vue.active_node = data_Vue.nodes.get(params.nodes[0]);
+ console.log('Active Node is ' + data_Vue.active_node.id);
+ });
+ network.on("selectEdge", function(params){
+ if(params.nodes.length == 0) data_Vue.show_info = 'edge';
+ data_Vue.active_edge = data_Vue.edges.get(params.edges[0]);
+ console.log('Active Edge is ' + data_Vue.active_edge.id);
+ });
+ network.on("doubleClick", function(params){
+ var copy_node = data_Vue.nodes.get(params.nodes[0]);
+ var str = Math.round(Math.random() * 10000);
+ copy_node.id = copy_node.id + 'Copy' +str;
+ copy_node.label = copy_node.label + 'Copy' +str;
+ copy_node.x = copy_node.x + 50;
+ copy_node.y = copy_node.y + 50;
+ data_Vue.nodes.add(copy_node);
+ //console.log(document.getElementById("node-individuals").value);
+ });
+ network.on('dragEnd', function (params) {
+ //console.log(params.nodes);
+ if(params.nodes.length > 0 ){
+ data_Vue.active_node = data_Vue.nodes.get(params.nodes[0]);
+ var positions = network.getPositions(params.nodes[0]);
+ data_Vue.active_node.x = positions[params.nodes[0]].x;
+ data_Vue.active_node.y = positions[params.nodes[0]].y;
+ data_Vue.nodes.update(data_Vue.active_node);
+ }
+ });
+}
+
+function editNode(data, cancelAction, callback) {
+ // when id is changed, update alle the edges:
+ document.getElementById('node-saveButton').onclick = saveNodeData.bind(this, data, callback);
+ document.getElementById('node-cancelButton').onclick = cancelAction.bind(this, callback);
+ document.getElementById('node-popUp').style.display = 'block';
+}
+
+// Callback passed as parameter is ignored
+function clearNodePopUp() {
+ document.getElementById('node-saveButton').onclick = null;
+ document.getElementById('node-cancelButton').onclick = null;
+ document.getElementById('node-popUp').style.display = 'none';
+}
+
+function cancelNodeEdit(callback) {
+ clearNodePopUp();
+ callback(null);
+}
+
+function addNode_extern(data) {
+ data.label = data.id;
+ data.color = data_Vue.node_colors[data.Sex];
+ data.title = data_Vue.id + ':' + data['Number of Individuals'] + 'Ind';
+ if(data['Sex'] != "Both"){
+ data['Proportion of Male'] = data.Sex == 'Male' ? 1 : 0;
+ }
+ if(data_Vue.nodes.get(data.id) != null){
+ alert("Node Name already exists! Node cannot be added!")
+ return;
+ }else{
+ data_Vue.nodes.update(data);
+ }
+}
+
+function saveNodeData(data, callback) {
+ var old_id = data.id;
+ data = data_Vue.active_node;
+ //data.label = data.id;
+ var myInd = JSON.stringify(data['Number of Individuals']).replace(/\"/g, "");
+ //data.label = data.id+'\n'+myInd;
+ data.label = data.id+" ("+myInd+")";
+ data.color = data_Vue.node_color;
+ data.title = data_Vue.node_title;
+ if(data['Sex'] != "Both"){
+ data['Proportion of Male'] = data.Sex == 'Male' ? 1 : 0;
+ }
+ if(data_Vue.node_operation=='Add Node' && data_Vue.nodes.get(data.id) != null){
+ alert("Node Name already exists! Node cannot be added!")
+ cancelNodeEdit(callback);
+ }else if(data_Vue.node_operation=='Edit Node' && old_id != data.id){
+ data_Vue.nodes.add(data);
+ data_Vue.nodes.remove(old_id);
+
+ // update edges from:
+ var items = data_Vue.edges.getIds({
+ filter: function (item) {
+ return item.from == old_id;
+ }
+ });
+ // console.log(items);
+ if(items.length >= 1){
+ for(ii=0; ii < items.length; ii++){
+ data_Vue.edges.update({id: items[ii], from: data.id});
+ }
+ }
+ // update edges to:
+ var items = data_Vue.edges.getIds({
+ filter: function (item) {
+ return item.to == old_id;
+ }
+ });
+ // console.log(items);
+ if(items.length >= 1){
+ for(ii=0; ii < items.length; ii++){
+ data_Vue.edges.update({id: items[ii], to: data.id});
+ }
+ }
+ cancelNodeEdit(callback);
+ } else {
+ clearNodePopUp();
+ callback(data);
+ }
+}
+
+function editEdgeWithoutDrag(data, callback) {
+ document.getElementById('edge-saveButton').onclick = saveEdgeData.bind(this, data, callback);
+ document.getElementById('edge-cancelButton').onclick = cancelEdgeEdit.bind(this,callback);
+ document.getElementById('edge-popUp').style.display = 'block';
+}
+
+function clearEdgePopUp() {
+ document.getElementById('edge-saveButton').onclick = null;
+ document.getElementById('edge-cancelButton').onclick = null;
+ document.getElementById('edge-popUp').style.display = 'none';
+}
+
+function cancelEdgeEdit(callback) {
+ clearEdgePopUp();
+ callback(null);
+}
+
+function addEdge_extern(data) {
+ var col = data_Vue.edge_colors[data['Breeding Type']];
+ data.color = {color: col, highlight:col, hover:col};
+ data.title = data['Breeding Type'];
+ data_Vue.edges.update(data);
+}
+
+function saveEdgeData(data, callback) {
+ data = data_Vue.active_edge;
+ data.color = data_Vue.edge_color;
+ data.title = data_Vue.edge_title;
+ // delete unnecessary data:
+ if(data['Selection Type'] == "Phenotypic" | data['Selection Type'] == "Random" | data['Selection Type'] == "Aging"){
+ var keys = ['Relationship Matrix', 'BVE Method', 'Cohorts used in BVE', 'Depth of Pedigree'];
+ for(let i=0; i< keys.length; i++){
+ data[keys[i]] = "";
+ }
+ data['Manuel selected cohorts'] = [];
+ }
+ clearEdgePopUp();
+ callback(data);
+ addServices();
+}
+
+function init() {
+ draw();
+ updateUser();
+}
+
+
+//******************* If the User take data from database, then load them here **********/
+function updateUser(){
+ $.get('/user', function(dat){
+ data_Vue.user = dat.username;
+ data_Vue.curUserGroup = dat.usergroup;
+ data_Vue.geninfo['curUserGroup'] = dat.usergroup;
+ })
+
+ $.post('/database', function(dat){
+ data_Vue.database = dat;
+ })
+
+ $.post('/template_database', function(dat){
+ data_Vue.template_database = dat;
+ })
+ data_Vue.project_saved = true;
+}
+
+
+function loadData(ind){
+ localStorage.clear();
+ sessionStorage.clear();
+ document.getElementById("excelToArray").value = "";
+ if(ind != "Create_New_123456YYYY"){
+ $.ajax
+ ({
+ type: "POST",
+ url: '/loadproject',
+ data: {name : ind},
+ success: function (data, msg) {
+ if(data != ''){
+ data_Vue.filename = data[0].name;
+ importNetwork_intern(data[0].json);
+ if(data[0].versions.length > 0){
+ data_Vue.versions = data[0].versions.reverse();
+ }
+ document.getElementById("Version").value = "recent";
+ data_Vue.project_saved = true;
+ }else{
+ alert("Loading Data failed. Contact administrator.");
+ }
+ },
+ });
+ }else{
+ location.reload();
+ }
+}
+
+function loadData_old(ind){
+ // console.log(ind);
+ if(ind != "Create_New_123456YYYY"){
+ $.ajax
+ ({
+ type: "POST",
+ url: '/loadproject',
+ data: {name : ind},
+ success: function (data, msg) {
+ if(data != ''){
+ //console.log("data original");
+ console.log(data);
+ data_Vue.filename = data[0].name;
+ importNetwork_intern(data[0].json);
+ if(data[0].versions.length > 0){
+ data_Vue.versions = data[0].versions.reverse();
+ }
+ //document.getElementById("Project_Name") = ind;
+ document.getElementById("Version").value = "recent";
+ data_Vue.project_saved = true;
+ }else{
+ alert("Loading Data failed. Contact administrator.");
+ }
+ },
+ failure: function(msg)
+ {
+ alert("Loading Data failed. Contact administrator.");
+ },
+ });
+ }else{
+ location.reload();
+ }
+}
+
+function loadVersion(ind){
+ if(ind != "recent"){
+ var json = data_Vue.versions[ind].json;
+ importNetwork_intern(json);
+ }else{
+ var json = data_Vue.versions[0].json;
+ importNetwork_intern(json);
+ }
+ data_Vue.project_saved = true;
+}
+
+function loadTemplate(ind){
+ if(ind != "New"){
+ var json = data_Vue.template_database[ind].json;
+ importNetwork_intern(json);
+ }else{
+ location.reload();
+ }
+}
+
+//************* warn the user about unsaved changes, when leaving:
+window.addEventListener('beforeunload', function (e) {
+ if(data_Vue.project_saved == false){
+ // Cancel the event
+ e.preventDefault();
+ // Chrome requires returnValue to be set
+ e.returnValue = '';
+ }
+});
+
+
+
+function myFunction() {
+ document.getElementById("Icon").classList.toggle("change");
+ data_Vue.show_menu = !data_Vue.show_menu;
+}
+
+
+
+// excel to Array
+var excelToArr = document.getElementById('excelToArray');
+if(excelToArr) {
+ excelToArr.addEventListener('change', importexcelToArray, false);
+}
+
+function importexcelToArray(evt) {
+ var selectedFile = evt.target.files;
+ var excelToArray = new ExcelToArray();
+ excelToArray.parseExcel(selectedFile[0]);
+}
+
+
+function saveMatrixToProject(name) {
+if(!name){
+var name = data_Vue.geninfo['Project Name'];
+}else{
+data_Vue.geninfo['Project Name'] = name;
+}
+saveProject(name);
+//loadData(name);
+//location.reload();
+}
+
+// excel to Array end
+
diff --git a/network.js b/public/javascript/network_old.js
similarity index 82%
rename from network.js
rename to public/javascript/network_old.js
index d3d86c0..351f297 100644
--- a/network.js
+++ b/public/javascript/network_old.js
@@ -18,6 +18,7 @@ function myNode (id, x, y) {
this['Housing Cost Class'] = "Default Housing Cost";
this['Proportion of genotyped individuals'] = 1;
this['Genotype generation'] = "Random-sampling";
+ this['Genotype generation subpopulation'] = "Population 1";
}
function myEdge (fr, to) {
@@ -61,6 +62,8 @@ function myGeneral () {
this['Own Map Path'] = '';
// this['chromo will be filled with myChromo elements later=
this['Chromosomes Info'] = [];
+ this['Upload_CorrFile'] = 'No';
+ this['curUserGroup'] = '';
}
function myTrait (ind){
@@ -87,6 +90,15 @@ function mySNP (ind){
this['QTL Optional Info'] = ''
}
+function mySNPsub (ind){
+ this['QTL SNP Number'] = ind,
+ this['QTL ID'] = 'QTL'+ind,
+ this['QTL BP'] = Math.round(Math.random()*1000000),
+ this['QTL Chromosome'] = 1,
+ this['QTL Allele Frequency'] = Math.round(Math.random()*100)/100,
+ this['QTL Optional Info'] = ''
+}
+
function myEconomy (){
this['Fixed Cost'] = 0,
this['Interest Rate'] = 0,
@@ -94,6 +106,25 @@ function myEconomy (){
this['Animal Housing Costs'] = [{Name: "Default Housing Cost", Cost: 0}, {Name: 'Male individuals', Cost: 2000}, {Name: 'Female individuals', Cost: 3000}]
}
+function myCulling (){
+ this['culling_reasons'] = []
+}
+
+function myPopulation (){
+ this['subpopulation_list'] = [{Name: "Population 1", beta1 : 1, beta2: 1, share0: 0, share1: 0, fixed_freq: 0, 'QTL Info': []}]
+}
+
+function mySelectionScaling (selection_index){
+ var len = selection_index.length;
+ var scaling_var = [];
+ for(let i=0; i 0){
for(let i=0; i 0){
+ while (len < val){
+ this.counter_qtl_sub++;
+ var newSNPsub = new mySNPsub(this.counter_qtl_sub);
+ this.subpopulation['subpopulation_list'][ind]['QTL Info'].push(newSNPsub);
+ len++;
+ }
+ }
+
},
// remove clicked QTL
removeQTL: function(trait, snp){
@@ -539,6 +657,18 @@ var data_Vue = new Vue({
this.traitsinfo[indT]['Trait Major QTL']--;
},
+
+ removeQTLsub: function(subpop, trait, snp){
+ var indA = this.subpopulation.indexOf(subpop)
+ var indT = this.subpopulation[indA].indexOf(trait);
+ var indS = this.subpopulation[indA][indT]['QTL Info'].indexOf(snp);
+
+ this.subpopulation[indA][indT]['QTL Info'].splice(indS,1);
+ this.subpopulation[indA][indT]['fixed_freq']--;
+
+ },
+
+
// add a new Phenotype, then also add correlation matrices:
addPheno: function(){
this.counter_pheno++;
@@ -748,21 +878,29 @@ function exportNetwork() {
var mat2 = [];
var row1;
var row2;
- for(let i=0; i < data_Vue.traitsinfo.length; i++){
- row1 = [];
- row2 = [];
- for(let j=0; j <= i; j++){
- row1.push(data_Vue.matrix[i].row[j].val);
- row2.push(data_Vue.matrix2[i].row[j].val);
+
+ if(data_Vue['Upload_CorrFile'] == 'Yes') {
+ var mat1 = data_Vue.mymatrix1;
+ var mat2 = data_Vue.mymatrix2;
+ }
+ else {
+ for(let i=0; i < data_Vue.traitsinfo.length; i++){
+ row1 = [];
+ row2 = [];
+ for(let j=0; j <= i; j++){
+ row1.push(data_Vue.matrix[i].row[j].val);
+ row2.push(data_Vue.matrix2[i].row[j].val);
+ }
+ mat1.push(row1);
+ mat2.push(row2);
}
- mat1.push(row1);
- mat2.push(row2);
}
var Intern = {
show_matrix_element : data_Vue.show_matrix_element,
counter_pheno : data_Vue.counter_pheno,
counter_qtl : data_Vue.counter_qtl,
+ counter_qtl_sub : data_Vue.counter_qtl_sub,
individualsVar_options : data_Vue.individualsVar_options,
genetic_data : data_Vue.genetic_data,
runned : data_Vue.runned,
@@ -774,9 +912,13 @@ function exportNetwork() {
'Genomic Info': data_Vue.geninfo,
'Trait Info': data_Vue.traitsinfo,
'Selection Index': data_Vue.selection_index,
+ 'Selection Index Scaling': data_Vue.selection_index_scaling,
'Phenotyping Info': data_Vue.phenotyping_class,
'Economy': data_Vue.economy,
+ 'Culling': data_Vue.culling,
+ 'Subpopulation': data_Vue.subpopulation,
'Phenotypic Correlation': mat1,
+ 'PhenotypicResidual': data_Vue.use_phenotypic_cor,
'Genetic Correlation': mat2,
'Intern': Intern,
};
@@ -808,7 +950,6 @@ function downloadNetwork(){
}
// function to import Data from OutputArea:
-
function importNetwork() {
var exportArea = document.getElementById('OutputArea');
var inputValue = exportArea.value;
@@ -835,11 +976,33 @@ function importNetwork_intern(inputData1) {
data_Vue.geninfo = inputData['Genomic Info'] ? inputData['Genomic Info'] : new myGeneral();
data_Vue.traitsinfo = inputData['Trait Info'] ? inputData['Trait Info'] : [];
data_Vue.selection_index = inputData['Selection Index'];
+ if(inputData['PhenotypicResidual']){
+ data_Vue.use_phenotypic_cor = inputData['PhenotypicResidual'];
+ } else{
+ data_Vue.use_phenotypic_cor = false;
+ }
+
+ if(inputData['Selection Index Scaling']){
+ data_Vue.selection_index_scaling = inputData['Selection Index Scaling'];
+ } else{
+ data_Vue.selection_index_scaling = new mySelectionScaling(data_Vue.selection_index);
+ }
+
if(inputData['Economy']){
data_Vue.economy = inputData['Economy'];
}else{
data_Vue.economy = new myEconomy();
}
+ if(inputData['Culling']){
+ data_Vue.culling = inputData['Culling'];
+ }else{
+ data_Vue.culling = new myCulling();
+ }
+ if(inputData['Subpopulation']){
+ data_Vue.subpopulation = inputData['Subpopulation'];
+ }else{
+ data_Vue.subpopulation = new myPopulation();
+ }
if(inputData['Phenotyping Info']){
data_Vue.phenotyping_class = inputData['Phenotyping Info'];
@@ -854,14 +1017,14 @@ function importNetwork_intern(inputData1) {
data_Vue.show_matrix_element = inputData["Intern"].show_matrix_element;
data_Vue.counter_pheno = inputData["Intern"].counter_pheno;
data_Vue.counter_qtl = inputData["Intern"].counter_qtl;
+ data_Vue.counter_qtl_sub = inputData["Intern"].counter_qtl_sub;
data_Vue.individualsVar_options = inputData["Intern"].individualsVar_options;
data_Vue.genetic_data = inputData["Intern"].genetic_data;
//data_Vue.runned = inputData["Intern"].runned;
-
var mat1 = inputData['Phenotypic Correlation'];
var mat2 = inputData['Genetic Correlation'];
- console.log(mat1);
+ //console.log(mat1);
if(mat1.length > 0){
var matrix = [];
var matrix2 = [];
@@ -915,7 +1078,6 @@ function postProject(name, url, jsondata){
alert("Saving Success!");
data_Vue.project_saved = true;
//loadData(name);
- console.log(data);
data_Vue.versions = data.reverse();
//document.getElementById("Project_Name").value = name; //data_Vue.geninfo['Project Name'];
document.getElementById("Version").value = "recent";
@@ -1151,8 +1313,10 @@ function addNode_extern(data) {
function saveNodeData(data, callback) {
var old_id = data.id;
- data = data_Vue.active_node;
- data.label = data.id;
+ data = data_Vue.active_node;
+ var myInd = JSON.stringify(data['Number of Individuals']).replace(/\"/g, "");
+ //data.label = data.id+'\n'+myInd;
+ data.label = data.id+" ("+myInd+")";
data.color = data_Vue.node_color;
data.title = data_Vue.node_title;
if(data['Sex'] != "Both"){
@@ -1246,7 +1410,9 @@ function init() {
//******************* If the User take data from database, then load them here **********/
function updateUser(){
$.get('/user', function(dat){
- data_Vue.user = dat;
+ data_Vue.user = dat.username;
+ data_Vue.curUserGroup = dat.usergroup;
+ data_Vue.geninfo['curUserGroup'] = dat.usergroup;
})
$.post('/database', function(dat){
@@ -1262,6 +1428,7 @@ function updateUser(){
function loadData(ind){
+// console.log(ind);
if(ind != "Create_New_123456YYYY"){
$.ajax
({
@@ -1272,6 +1439,7 @@ function loadData(ind){
if(data != ''){
//console.log("data original");
//console.log(data);
+ data_Vue.filename = data[0].name;
importNetwork_intern(data[0].json);
if(data[0].versions.length > 0){
data_Vue.versions = data[0].versions.reverse();
@@ -1279,6 +1447,7 @@ function loadData(ind){
//document.getElementById("Project_Name") = ind;
document.getElementById("Version").value = "recent";
data_Vue.project_saved = true;
+ //isRSimulated(ind);
}else{
alert("Loading Data failed. Contact administrator.");
}
@@ -1293,6 +1462,25 @@ function loadData(ind){
}
}
+function isRSimulated(val) {
+ console.log(val);
+ console.log(data_Vue.user);
+
+ $.ajax
+ ({
+ type: "POST",
+ url: '/isRDataExist',
+ data: {name : val},
+ success: function (data, msg) {
+ console.log('mine'+msg);
+ },
+ failure:function(msg)
+ {
+ alert('RData is not there!');
+ }
+ });
+}
+
function loadVersion(ind){
if(ind != "recent"){
var json = data_Vue.versions[ind].json;
@@ -1333,3 +1521,30 @@ function myFunction() {
data_Vue.show_menu = !data_Vue.show_menu;
}
+
+// excel to Array
+var excelToArr = document.getElementById('excelToArray');
+if(excelToArr) {
+ excelToArr.addEventListener('change', importexcelToArray, false);
+}
+
+
+function importexcelToArray(evt) {
+ var selectedFile = evt.target.files;
+ var excelToArray = new ExcelToArray();
+ excelToArray.parseExcel(selectedFile[0]);
+ }
+
+function saveMatrixToProject(name) {
+ console.log(name);
+ if(!name){
+ var name = data_Vue.geninfo['Project Name'];
+ }else{
+ data_Vue.geninfo['Project Name'] = name;
+ }
+ saveProject(name);
+ loadData(name);
+}
+
+// excel to Array end
+
diff --git a/public/javascript/test_net.js b/public/javascript/test_net.js
new file mode 100644
index 0000000..cfb7695
--- /dev/null
+++ b/public/javascript/test_net.js
@@ -0,0 +1,1539 @@
+Vue.component('treeselect', VueTreeselect.Treeselect);
+//Vue.component('slider', VueSlider.Slider);
+//**************** Network Script **********************************//
+//*********************************************************************//
+// define the classe myNode and myEdge with default values
+function myNode (id, x, y) {
+ this['id'] = id;
+ this['Number of Individuals'] = "";
+ this['x'] = x;
+ this['y'] = y;
+ this['individualsVar'] = "";
+ this['Founder'] = "No";
+ this['Path'] = "";
+ this['Proportion of Male'] = "1";
+ this['BV Plot'] = 'Yes';
+ this['Sex'] = "Male";
+ this['Phenotyping Class'] = "Default PhenoC";
+ this['Housing Cost Class'] = "Default Housing Cost";
+ this['Proportion of genotyped individuals'] = 1;
+ this['Genotype generation'] = "Random-sampling";
+ this['Genotype generation subpopulation'] = "Population 1";
+ }
+
+function myEdge (fr, to) {
+ this['from'] = fr;
+ this['to'] = to;
+ this['Breeding Type'] = "";
+ this['Selection Type'] = "Random";
+ this['Number of Repeat'] = "";
+ //this['Selection Proportion'] = ""; -> we do not save it, always calculate from Number of Individuals
+ this['Relationship Matrix'] = "";
+ this['BVE Method'] = "";
+ //this['New Mutation Rate'] = "";
+ //this['New Remutation Rate'] = "";
+ //this['Number of Rec per M'] = "";
+ this['Use Offspring for BVE'] = "";
+ this['Time Needed'] = 0;
+ this['id'] = fr + '_'+ to;
+ // in order to save the parameters that are using variables, should match indivdualsVar_options
+ this['useVar'] =[];
+ this['Selection Index']="Default Index";
+ this['Cohorts used in BVE'] = "";
+ this['Manuel selected cohorts'] = [];
+ this['OGC'] = "No";
+ this['Depth of Pedigree'] = "";
+ this['Max Offspring'] = "Inf";
+}
+
+// define the classe myGeneral with default values for General information:
+function myGeneral () {
+ this['Project Name'] = '';
+ this['Species'] = '';
+ this['Use Ensembl Map'] = "Yes";
+ this['Ensembl Dataset'] = "";
+ this['Max Number of SNPs'] = 5000;
+// this['Ensembl Filter'] = "";
+// this['Ensembl Filter Values'] = "";
+ this['Number of Chromosomes'] = '';
+ this['Chromosomes of Equal Length'] = 'Yes';
+ this['Time Unit'] = 'Weeks';
+ this['Use Own Map'] = 'Yes';
+ this['Own Map Path'] = '';
+ // this['chromo will be filled with myChromo elements later=
+ this['Chromosomes Info'] = [];
+ this['Upload_CorrFile'] = 'No';
+ this['curUserGroup'] = '';
+}
+
+function myTrait (ind){
+ this['Trait Name'] = "Pheno " + ind,
+ this['Trait Unit'] = "",
+ this['Trait Mean'] = Math.round(Math.random()*100) +1,
+ this['Trait Std Deviation'] = Math.round(Math.random()*10) +1,
+ this['Trait Heritability'] = Math.round(Math.random()*100)/100,
+ this['Trait Number of Polygenic Loci'] = Math.round(Math.random()*10000),
+ this['Trait Major QTL'] = 0,
+ this['Trait Value per Unit'] = 0,
+ this['Trait QTL Info'] = []
+}
+
+function mySNP (ind){
+ this['QTL SNP Number'] = ind,
+ this['QTL ID'] = 'QTL'+ind,
+ this['QTL BP'] = Math.round(Math.random()*1000000),
+ this['QTL Chromosome'] = 1,
+ this['QTL Effect AA'] = Math.round(Math.random()*10) +1,
+ this['QTL Effect AB'] = Math.round(Math.random()*10) +1,
+ this['QTL Effect BB'] = Math.round(Math.random()*10) +1,
+ this['QTL Allele Frequency'] = Math.round(Math.random()*100)/100,
+ this['QTL Optional Info'] = ''
+}
+
+function mySNPsub (ind){
+ this['QTL SNP Number'] = ind,
+ this['QTL ID'] = 'QTL'+ind,
+ this['QTL BP'] = Math.round(Math.random()*1000000),
+ this['QTL Chromosome'] = 1,
+ this['QTL Allele Frequency'] = Math.round(Math.random()*100)/100,
+ this['QTL Optional Info'] = ''
+}
+
+function myEconomy (){
+ this['Fixed Cost'] = 0,
+ this['Interest Rate'] = 0,
+ this['Genotyping Cost'] = 50,
+ this['Animal Housing Costs'] = [{Name: "Default Housing Cost", Cost: 0}, {Name: 'Male individuals', Cost: 2000}, {Name: 'Female individuals', Cost: 3000}]
+}
+
+function myCulling (){
+ this['culling_reasons'] = []
+}
+
+function myPopulation (){
+ this['subpopulation_list'] = [{Name: "Population 1", beta1 : 1, beta2: 1, share0: 0, share1: 0, fixed_freq: 0, 'QTL Info': []}]
+}
+
+function mySelectionScaling (selection_index){
+ var len = selection_index.length;
+ var scaling_var = [];
+ for(let i=0; i 0){
+ for(let i=0; i= 1 ){
+ alert("Animal Housing Costs class is still in used by "+items.length+ " nodes. Removing not possible!");
+ return;
+ }
+ this.economy['Animal Housing Costs'].splice(ind,1);
+
+ },
+
+ removeCulling: function(si, ind){
+
+ this.culling['culling_reasons'].splice(ind,1);
+
+ },
+ removeSub: function(si, ind){
+
+ this.subpopulation['subpopulation_list'].splice(ind,1);
+
+ },
+
+ // add a new selection index:
+ addSI: function(name){
+ if(name){
+ var val = name;
+ }else{
+ var val = document.getElementById("newSI").value;
+ }
+ for(let i=0; i= 1 ){
+ alert("Selection index is still in used by "+items.length+ " edges. Removing not possible!");
+ return;
+ }
+
+ this.selection_index.splice(ind,1);
+ this.selection_index_scaling.splice(ind,1);
+
+ },
+ removePC: function(si, ind){
+
+ var items = this.nodes.getIds({
+ filter: function (item) {
+ return item['Phenotyping Class'] == si.Name;
+ }
+ });
+
+ if(items.length >= 1 ){
+ alert("Phenotyping Class is still in used by "+items.length+ " nodes. Removing not possible!");
+ return;
+ }
+ this.phenotyping_class.splice(ind,1);
+
+ },
+ // create/remove new Chromosomes on change of the # Chromosomes, depending on
+ // whether new number is greater or smaller --> remove from bottom
+ createChrom: function(){
+ if(this.geninfo['Chromosomes of Equal Length'] == 'No'){
+ this.geninfo['Number of Chromosomes'] = Math.round(Number(this.geninfo['Number of Chromosomes']));
+ var val = this.geninfo['Number of Chromosomes'];
+
+ }else{
+ var val = 1;
+ }
+ var len = this.geninfo['Chromosomes Info'].length;
+ var diff = val - len;
+
+ if(diff < 0){
+ this.geninfo['Chromosomes Info'].splice(diff);
+ }else if (diff > 0){
+ while (len < val){
+ var newChromo = new myChromo(100,500,1);
+ this.geninfo['Chromosomes Info'].push(newChromo);
+ len++;
+ }
+ }
+ },
+ // create/remove new QTL on change of the # QTls, depending on
+ // whether new number is greater or smaller --> remove from bottom
+ createQTL: function(ind){
+ this.traitsinfo[ind]['Trait Major QTL'] = Math.round(Number(this.traitsinfo[ind]['Trait Major QTL']));
+ var val = this.traitsinfo[ind]['Trait Major QTL'];
+ var len = this.traitsinfo[ind]['Trait QTL Info'].length;
+ var diff = val - len;
+
+ if(diff < 0){
+ this.traitsinfo[ind]['Trait QTL Info'].splice(diff);
+ }else if (diff > 0){
+ while (len < val){
+ this.counter_qtl++;
+ var newSNP = new mySNP(this.counter_qtl);
+ this.traitsinfo[ind]['Trait QTL Info'].push(newSNP);
+ len++;
+ }
+ }
+
+ },
+ createQTLsub: function(ind){
+ this.subpopulation['subpopulation_list'][ind]['fixed_freq'] = Math.round(Number(this.subpopulation['subpopulation_list'][ind]['fixed_freq']));
+ var val = this.subpopulation['subpopulation_list'][ind]['fixed_freq'];
+ var len = this.subpopulation['subpopulation_list'][ind]['QTL Info'].length;
+ var diff = val - len;
+
+ if(diff < 0){
+ this.subpopulation['subpopulation_list'][ind]['QTL Info'].splice(diff);
+ }else if (diff > 0){
+ while (len < val){
+ this.counter_qtl_sub++;
+ var newSNPsub = new mySNPsub(this.counter_qtl_sub);
+ this.subpopulation['subpopulation_list'][ind]['QTL Info'].push(newSNPsub);
+ len++;
+ }
+ }
+
+ },
+ // remove clicked QTL
+ removeQTL: function(trait, snp){
+ var indT = this.traitsinfo.indexOf(trait);
+ var indS = this.traitsinfo[indT]['Trait QTL Info'].indexOf(snp);
+ this.traitsinfo[indT]['Trait QTL Info'].splice(indS,1);
+ this.traitsinfo[indT]['Trait Major QTL']--;
+
+ },
+
+ removeQTLsub: function(subpop, trait, snp){
+ var indA = this.subpopulation.indexOf(subpop)
+ var indT = this.subpopulation[indA].indexOf(trait);
+ var indS = this.subpopulation[indA][indT]['QTL Info'].indexOf(snp);
+
+ this.subpopulation[indA][indT]['QTL Info'].splice(indS,1);
+ this.subpopulation[indA][indT]['fixed_freq']--;
+
+ },
+
+
+ // add a new Phenotype, then also add correlation matrices:
+ addPheno: function(){
+ this.counter_pheno++;
+ var len = this.traitsinfo.length;
+ var new_trait = new myTrait(this.counter_pheno);
+ this.traitsinfo.push(new_trait);
+
+ this.matrix.push({row: new myArray(len+1)});
+ this.matrix2.push({row: new myArray(len+1)});
+ this.show_matrix_element.push({show:true});
+
+ },
+ // remove clicked Phenotype
+ removePheno: function(ind){
+ var len = this.traitsinfo.length;
+ this.traitsinfo.splice(ind,1);
+
+ // remove also correlation matrix elements
+ // associated with this phenotype
+ if(len > 1){
+ for(let i=ind+1; i< len; i++){
+ this.matrix[i].row.splice(ind,1);
+ this.matrix2[i].row.splice(ind,1);
+ }
+ this.matrix.splice(ind,1);
+ this.matrix2.splice(ind,1);
+ }else{
+ this.matrix = [];
+ this.matrix2 = [];
+ }
+ this.show_matrix_element.splice(ind, 1);
+
+ // remove also selection index, phenotyping classes
+ // associated with this phenotype
+ for(let i=0; i= 1){
+ for(ii=0; ii < items.length; ii++){
+ this.nodes.update({id: items[ii], 'Number of Individuals': wert, title: items[ii]+':'+wert+' Ind'});
+ }
+ //network.setData({nodes: this.nodes, edges: this.edges});
+ }
+ },
+ // will updates all edges in case of Variable' value is changing:
+ updateEdgesVar: function(vv){
+ var wert = vv.value;
+ var ind = this.individualsVar_options.indexOf(vv);
+
+ var items = this.edges.get({
+ filter: function (item) {
+ return item.useVar[ind] != '';
+ }
+ });
+ if(items.length >= 1){
+ for(ii=0; ii < items.length; ii++){
+ var new_E = {id: items[ii].id};
+ new_E[items[ii].useVar[ind]] = wert;
+ new_E.title = items[ii].Breedingtype
+ //console.log(new_E);
+ this.edges.update(new_E);
+ }
+ //network.setData({nodes: this.nodes, edges: this.edges});
+ }
+
+ },
+ // remove Variable if no Nodes are using it:
+ removeVariable: function(vv){
+ var wert = vv.value;
+ var ind = this.individualsVar_options.indexOf(vv);
+
+ var items = this.nodes.getIds({
+ filter: function (item) {
+ return item.individualsVar == vv.name;
+ }
+ });
+
+ var items2 = this.edges.getIds({
+ filter: function (item) {
+ return item.useVar[ind] != '';
+ }
+ });
+
+ if(items.length >= 1 | items2.length >= 1){
+ alert("Variable ist still in used by "+items.length+ " nodes and "+items2.length+" edges. Removing not possible!");
+ return;
+ }
+ this.individualsVar_options.splice(ind,1);
+
+ // prepare edges for the use of variables:
+ var items = this.edges.get();
+ for(let i=0; i< items.length; i++){
+ items[i].useVar.splice(ind, 1);
+ }
+ this.edges.update(items);
+ },
+ }
+})
+
+//******************************************************************************************//
+//**************** own functions required to manually update data_Vue or DOM ***************//
+
+
+// if we use Variables for the # individuals, we need to update node.individuals:
+function updateIndividuals(ivar){
+ var item = data_Vue.individualsVar_options.filter(function(vv){ return(vv.name == ivar)})[0];
+ if(item != undefined){
+ data_Vue.active_node['Number of Individuals'] = item.value;
+ }else{
+ data_Vue.active_node['Number of Individuals'] = ivar;
+ }
+}
+
+// if we use Variables for the Edges, we need to update their data according to the variables' value:
+function updateVar(param, ivar){
+ var ind_old = data_Vue.active_edge.useVar.indexOf(param);
+ //console.log(ind_old);
+ data_Vue.active_edge.useVar[ind_old] = '';
+
+ var item = data_Vue.individualsVar_options.filter(function(vv){ return(vv.name == ivar)})[0];
+ if(item != undefined){
+ data_Vue.active_edge[param] = item.value;
+ data_Vue.active_edge.useVar[data_Vue.individualsVar_options.indexOf(item)] = param;
+ }else{
+ data_Vue.active_edge[param] = ivar;
+ }
+}
+
+// if we change Species on Selection, we need to change the default Values:
+function updateSpeciesData(value){
+ Object.assign(data_Vue.geninfo, genome_default_data[value]);
+ //data_Vue.chromo = data_Vue.geninfo['Chromosomes Info'];
+ data_Vue.traitsinfo = data_Vue.geninfo['Default Traits'];
+ data_Vue.counter_pheno = data_Vue.traitsinfo.length;
+ data_Vue.matrix = data_Vue.geninfo['Phenotypic Correlation'];
+ data_Vue.matrix2 = data_Vue.geninfo['Genetic Correlation'];
+
+ for(let i =0; i< data_Vue.traitsinfo.length; i++){
+ data_Vue.show_matrix_element.push({show:true});
+ }
+
+ //if(data_Vue.traitsinfo.length > 0){
+ // data_Vue.addSI('Default Index');
+ // data_Vue.addPC('Default PhenoC');
+ //}
+
+ // update Ensembl data
+ data_Vue.geninfo['Ensembl Dataset'] = data_Vue.ensembl_options[value].Dataset;
+ data_Vue.geninfo['Ensembl Filter'] = data_Vue.ensembl_options[value].Filter;
+ data_Vue.geninfo['Ensembl Filter Values'] = data_Vue.ensembl_options[value].Value;
+
+ // delete unnessary redundant data:
+ delete data_Vue.geninfo['Phenotypic Correlation'];
+ delete data_Vue.geninfo['Genetic Correlation'];
+ delete data_Vue.geninfo['Default Traits'];
+}
+
+// function to export Data into OutputArea:
+
+function exportNetwork() {
+ exportArea = document.getElementById('OutputArea');
+ exportArea.value = "";
+
+ if(data_Vue.geninfo['Chromosomes of Equal Length'] == 'Yes'){
+ data_Vue.geninfo["Chromosomes Info"] = data_Vue.chromo_display.slice(0,1);
+ }else{
+ data_Vue.geninfo["Chromosomes Info"] = data_Vue.chromo_display;
+ }
+
+ var mat1 = [];
+ var mat2 = [];
+ var row1;
+ var row2;
+
+ if(data_Vue['Upload_CorrFile'] == 'Yes') {
+ var mat1 = data_Vue.mymatrix1;
+ var mat2 = data_Vue.mymatrix2;
+ }
+ else {
+ for(let i=0; i < data_Vue.traitsinfo.length; i++){
+ row1 = [];
+ row2 = [];
+ for(let j=0; j <= i; j++){
+ row1.push(data_Vue.matrix[i].row[j].val);
+ row2.push(data_Vue.matrix2[i].row[j].val);
+ }
+ mat1.push(row1);
+ mat2.push(row2);
+ }
+ }
+
+ var Intern = {
+ show_matrix_element : data_Vue.show_matrix_element,
+ counter_pheno : data_Vue.counter_pheno,
+ counter_qtl : data_Vue.counter_qtl,
+ counter_qtl_sub : data_Vue.counter_qtl_sub,
+ individualsVar_options : data_Vue.individualsVar_options,
+ genetic_data : data_Vue.genetic_data,
+ runned : data_Vue.runned,
+ };
+
+ var data_to_export = {
+ 'Nodes': data_Vue.nodes.get(),
+ 'Edges': data_Vue.edges.get(),
+ 'Genomic Info': data_Vue.geninfo,
+ 'Trait Info': data_Vue.traitsinfo,
+ 'Selection Index': data_Vue.selection_index,
+ 'Selection Index Scaling': data_Vue.selection_index_scaling,
+ 'Phenotyping Info': data_Vue.phenotyping_class,
+ 'Economy': data_Vue.economy,
+ 'Culling': data_Vue.culling,
+ 'Subpopulation': data_Vue.subpopulation,
+ 'Phenotypic Correlation': mat1,
+ 'PhenotypicResidual': data_Vue.use_phenotypic_cor,
+ 'Genetic Correlation': mat2,
+ 'Intern': Intern,
+ };
+ var exportValue = JSON.stringify(data_to_export, undefined, 2);
+
+ exportArea.value = exportValue;
+
+ resizeExportArea();
+
+ //delete data_Vue.geninfo["Chromosomes Info"];
+ return data_to_export;
+
+}
+
+// function to download network:
+function downloadNetwork(){
+ var jsondata = JSON.stringify(exportNetwork(), undefined, 2);
+ var filename = data_Vue.geninfo['Project Name'] ? data_Vue.geninfo['Project Name'] : "File";
+ var element = document.createElement('a');
+ element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(jsondata));
+ element.setAttribute('download', filename+'.json');
+
+ element.style.display = 'none';
+ document.body.appendChild(element);
+
+ element.click();
+
+ document.body.removeChild(element);
+}
+
+
+
+// function to import Data from OutputArea:
+
+function importNetwork() {
+ var exportArea = document.getElementById('OutputArea');
+ var inputValue = exportArea.value;
+ if(inputValue == ''){
+ alert("Nothing to import. Please paste the JSON file into the text area.");
+ return;
+ }
+ var inputData = JSON.parse(inputValue);
+
+ importNetwork_intern(inputData);
+ data_Vue.project_saved = false;
+
+}
+
+function importNetwork_intern(inputData1) {
+ data_Vue.active_edge = new myEdge();
+ if(data_Vue.runned){
+ clearResult();
+ }
+ //console.log(inputData);
+ var inputData = JSON.parse(JSON.stringify(inputData1));
+ data_Vue.nodes = new vis.DataSet(inputData['Nodes']);
+ data_Vue.edges = new vis.DataSet(inputData['Edges']);
+ data_Vue.geninfo = inputData['Genomic Info'] ? inputData['Genomic Info'] : new myGeneral();
+ data_Vue.traitsinfo = inputData['Trait Info'] ? inputData['Trait Info'] : [];
+ data_Vue.selection_index = inputData['Selection Index'];
+ if(inputData['PhenotypicResidual']){
+ data_Vue.use_phenotypic_cor = inputData['PhenotypicResidual'];
+ } else{
+ data_Vue.use_phenotypic_cor = false;
+ }
+
+ if(inputData['Selection Index Scaling']){
+ data_Vue.selection_index_scaling = inputData['Selection Index Scaling'];
+ } else{
+ data_Vue.selection_index_scaling = new mySelectionScaling(data_Vue.selection_index);
+ }
+
+ if(inputData['Economy']){
+ data_Vue.economy = inputData['Economy'];
+ }else{
+ data_Vue.economy = new myEconomy();
+ }
+ if(inputData['Culling']){
+ data_Vue.culling = inputData['Culling'];
+ }else{
+ data_Vue.culling = new myCulling();
+ }
+ if(inputData['Subpopulation']){
+ data_Vue.subpopulation = inputData['Subpopulation'];
+ }else{
+ data_Vue.subpopulation = new myPopulation();
+ }
+
+ if(inputData['Phenotyping Info']){
+ data_Vue.phenotyping_class = inputData['Phenotyping Info'];
+ }else{
+ // an older Version of JSON file, maually add phenoC
+ data_Vue.phenotyping_class = [{Name: "Default PhenoC"}];
+ for(let i=0; i 0){
+ var matrix = [];
+ var matrix2 = [];
+ var row1;
+ var row2;
+ for(let i=0; i < data_Vue.traitsinfo.length; i++){
+ row1 = [];
+ row2 = [];
+ for(let j=0; j <= i; j++){
+ row1.push({val : mat1[i][j]});
+ row2.push({val : mat2[i][j]});
+ }
+ matrix.push({row : row1});
+ matrix2.push({row : row2});
+ }
+
+ data_Vue.matrix = matrix;
+ data_Vue.matrix2 = matrix2;
+ }else{
+ data_Vue.matrix = [];
+ data_Vue.matrix2 = [];
+ }
+
+ draw();
+ console.log("Loading Data successful.");
+ data_Vue.project_saved = true;
+
+}
+
+function resizeExportArea() {
+ exportArea.style.height = (1 + exportArea.scrollHeight) + "px";
+}
+
+// function to save data to database:
+
+function postProject(name, url, jsondata){
+ $.ajax
+ ({
+ type: "POST",
+ url: url,
+ data: {
+ name: name,
+ jsondata : jsondata,
+ versions: JSON.stringify(data_Vue.versions.reverse()),
+ },
+ success: function (data, msg) {
+ $.post('/database', function(dat){
+ data_Vue.database = dat;
+ //document.getElementById("Project_Name").value = name;
+ })
+ alert("Saving Success!");
+ data_Vue.project_saved = true;
+ //loadData(name);
+ data_Vue.versions = data.reverse();
+ //document.getElementById("Project_Name").value = name; //data_Vue.geninfo['Project Name'];
+ document.getElementById("Version").value = "recent";
+ document.getElementById("SaveAs_Div").style.display = 'none';
+ },
+ failure: function(msg)
+ {
+ alert('Saving Error!');
+ },
+ });
+}
+
+function saveProject(name) {
+ if(!name){
+ var name = data_Vue.geninfo['Project Name'];
+ }else{
+ data_Vue.geninfo['Project Name'] = name;
+ }
+ var jsondata = JSON.stringify(exportNetwork());
+
+ if(data_Vue.versions.length > 10){
+ var r = confirm("Only the 10 most recent versions are saved. The oldest version will be deleted. Do you want to proceed? Alternative: Change the Project Name and save to create a new project");
+ if(!r) return;
+ }
+
+ while(data_Vue.versions.length > 10){
+ data_Vue.versions.pop();
+ }
+
+ if(data_Vue.database.filter(function(obj){ return(obj==name)}).length > 0){
+ postProject(name, "/update", jsondata);
+ }else{
+ postProject(name, "/save", jsondata);
+ }
+}
+
+function deleteProject() {
+ var name = data_Vue.geninfo['Project Name'];
+
+ if(data_Vue.database.filter(function(x){return(x == name)}).length > 0){
+ var r = confirm("The whole project including all older versions will be deleted. Do you want to proceed?");
+ if(r){
+ $.ajax
+ ({
+ type: "POST",
+ url: "/delete",
+ data: {
+ name: name,
+ },
+ success: function (msg) {
+ //loadData(name);
+ console.log("Project deleted.");
+ location.reload();
+ },
+ failure: function(msg)
+ {
+ alert('Delete Error!');
+ },
+ });
+ }
+ }
+}
+
+function saveProjectAs() {
+ document.getElementById("SaveAs_Div").style.display = 'block';
+}
+
+// set the path of Own Map file, after map has been uploaded:
+function setMapPath(){
+ data_Vue.geninfo["Own Map Path"] = "UserMaps/"+data_Vue.user+"_"+document.getElementById('mapFile').files[0].name;
+}
+
+function setGenoPath(){
+ data_Vue.active_node["Path"] = "UserGenos/"+data_Vue.user+"_"+document.getElementById('genoFile').files[0].name;
+}
+//******************************************************************************************//
+//************************* Network functions **********************************************//
+
+var network_data = data_Vue;
+
+function destroy() {
+ if (network !== null) {
+ network.destroy();
+ network = null;
+ }
+}
+
+function draw() {
+ destroy();
+
+ // create a network
+ var container = document.getElementById('mynetwork');
+ var options = {
+ locale: 'en',
+ autoResize: false,
+ layout: {
+ improvedLayout: false,
+ },
+ manipulation: {
+ addNode: function (data, callback) {
+ // creating node:
+ data = new myNode("", data.x, data.y);
+ data_Vue.show_info = 'node';
+ // set default values for DOM:
+ data_Vue.active_node = data;
+ // filling in the popup DOM elements
+ data_Vue.node_operation = "Add Node";
+ editNode(data, clearNodePopUp, callback);
+ },
+ editNode: function (data, callback) {
+ // filling in the popup DOM elements
+ data_Vue.node_operation = "Edit Node";
+ editNode(data, cancelNodeEdit, callback);
+ },
+ addEdge: function (data, callback) {
+ if (typeof data.to === 'object')
+ data.to = data.to.id
+ if (typeof data.from === 'object')
+ data.from = data.from.id
+ //creating edge:
+ data = new myEdge(data.from, data.to);
+ data_Vue.show_info = 'edge';
+ // set default values for DOM:
+ data_Vue.active_edge = data;
+ // calculate Selection Proportion by using number of individuals of parent and offspring nodes:
+ data.useVar = Array(data_Vue.individualsVar_options.length).fill('');
+
+ if (data.from == data.to) {
+ alert("You cannot connect a node to itself.");
+ callback(null);
+ return;
+ }
+ data_Vue.edge_operation = "Add Edge";
+ editEdgeWithoutDrag(data, callback);
+ },
+ editEdge: {
+ editWithoutDrag: function(data, callback) {
+ data_Vue.edge_operation = "Edit Edge";
+ editEdgeWithoutDrag(data,callback);
+ }
+ }
+ },
+ physics: {enabled: false},
+ edges: {
+ arrows: {
+ to: true,
+ },
+ chosen: true,
+ smooth: {
+ type: "diagonalCross",
+ forceDirection: "none",
+ roundness: 0.2
+ },
+ width: 2,
+ },
+ nodes: {
+ shape: 'box',
+ shapeProperties: {borderRadius: 0},
+ },
+ interaction: {
+ hover: true,
+ hoverConnectedEdges: false,
+ selectConnectedEdges: true,
+ },
+ };
+ network = new vis.Network(container, network_data, options);
+
+ network.on("selectNode", function(params){
+ data_Vue.show_info = 'node';
+ data_Vue.active_node = data_Vue.nodes.get(params.nodes[0]);
+ console.log('Active Node is ' + data_Vue.active_node.id);
+ });
+ network.on("selectEdge", function(params){
+ if(params.nodes.length == 0) data_Vue.show_info = 'edge';
+ data_Vue.active_edge = data_Vue.edges.get(params.edges[0]);
+ console.log('Active Edge is ' + data_Vue.active_edge.id);
+ });
+ network.on("doubleClick", function(params){
+ var copy_node = data_Vue.nodes.get(params.nodes[0]);
+ var str = Math.round(Math.random() * 10000);
+ copy_node.id = copy_node.id + 'Copy' +str;
+ copy_node.label = copy_node.label + 'Copy' +str;
+ copy_node.x = copy_node.x + 50;
+ copy_node.y = copy_node.y + 50;
+ data_Vue.nodes.add(copy_node);
+ //console.log(document.getElementById("node-individuals").value);
+ });
+ network.on('dragEnd', function (params) {
+ //console.log(params.nodes);
+ if(params.nodes.length > 0 ){
+ data_Vue.active_node = data_Vue.nodes.get(params.nodes[0]);
+ var positions = network.getPositions(params.nodes[0]);
+ data_Vue.active_node.x = positions[params.nodes[0]].x;
+ data_Vue.active_node.y = positions[params.nodes[0]].y;
+ data_Vue.nodes.update(data_Vue.active_node);
+ }
+ });
+}
+
+function editNode(data, cancelAction, callback) {
+ // when id is changed, update alle the edges:
+ document.getElementById('node-saveButton').onclick = saveNodeData.bind(this, data, callback);
+ document.getElementById('node-cancelButton').onclick = cancelAction.bind(this, callback);
+ document.getElementById('node-popUp').style.display = 'block';
+}
+
+// Callback passed as parameter is ignored
+function clearNodePopUp() {
+ document.getElementById('node-saveButton').onclick = null;
+ document.getElementById('node-cancelButton').onclick = null;
+ document.getElementById('node-popUp').style.display = 'none';
+}
+
+function cancelNodeEdit(callback) {
+ clearNodePopUp();
+ callback(null);
+}
+
+function addNode_extern(data) {
+ data.label = data.id;
+ data.color = data_Vue.node_colors[data.Sex];
+ data.title = data_Vue.id + ':' + data['Number of Individuals'] + 'Ind';
+ if(data['Sex'] != "Both"){
+ data['Proportion of Male'] = data.Sex == 'Male' ? 1 : 0;
+ }
+ if(data_Vue.nodes.get(data.id) != null){
+ alert("Node Name already exists! Node cannot be added!")
+ return;
+ }else{
+ data_Vue.nodes.update(data);
+ }
+}
+
+function saveNodeData(data, callback) {
+ var old_id = data.id;
+ data = data_Vue.active_node;
+ //data.label = data.id;
+ var myInd = JSON.stringify(data['Number of Individuals']).replace(/\"/g, "");
+ //data.label = data.id+'\n'+myInd;
+ data.label = data.id+" ("+myInd+")";
+ data.color = data_Vue.node_color;
+ data.title = data_Vue.node_title;
+ if(data['Sex'] != "Both"){
+ data['Proportion of Male'] = data.Sex == 'Male' ? 1 : 0;
+ }
+ if(data_Vue.node_operation=='Add Node' && data_Vue.nodes.get(data.id) != null){
+ alert("Node Name already exists! Node cannot be added!")
+ cancelNodeEdit(callback);
+ }else if(data_Vue.node_operation=='Edit Node' && old_id != data.id){
+ data_Vue.nodes.add(data);
+ data_Vue.nodes.remove(old_id);
+
+ // update edges from:
+ var items = data_Vue.edges.getIds({
+ filter: function (item) {
+ return item.from == old_id;
+ }
+ });
+ console.log(items);
+ if(items.length >= 1){
+ for(ii=0; ii < items.length; ii++){
+ data_Vue.edges.update({id: items[ii], from: data.id});
+ }
+ }
+ // update edges to:
+ var items = data_Vue.edges.getIds({
+ filter: function (item) {
+ return item.to == old_id;
+ }
+ });
+ console.log(items);
+ if(items.length >= 1){
+ for(ii=0; ii < items.length; ii++){
+ data_Vue.edges.update({id: items[ii], to: data.id});
+ }
+ }
+ cancelNodeEdit(callback);
+ } else {
+ clearNodePopUp();
+ callback(data);
+ }
+}
+
+function editEdgeWithoutDrag(data, callback) {
+ document.getElementById('edge-saveButton').onclick = saveEdgeData.bind(this, data, callback);
+ document.getElementById('edge-cancelButton').onclick = cancelEdgeEdit.bind(this,callback);
+ document.getElementById('edge-popUp').style.display = 'block';
+}
+
+function clearEdgePopUp() {
+ document.getElementById('edge-saveButton').onclick = null;
+ document.getElementById('edge-cancelButton').onclick = null;
+ document.getElementById('edge-popUp').style.display = 'none';
+}
+
+function cancelEdgeEdit(callback) {
+ clearEdgePopUp();
+ callback(null);
+}
+
+function addEdge_extern(data) {
+ var col = data_Vue.edge_colors[data['Breeding Type']];
+ data.color = {color: col, highlight:col, hover:col};
+ data.title = data['Breeding Type'];
+ data_Vue.edges.update(data);
+}
+
+function saveEdgeData(data, callback) {
+ data = data_Vue.active_edge;
+ data.color = data_Vue.edge_color;
+ data.title = data_Vue.edge_title;
+ // delete unnecessary data:
+ if(data['Selection Type'] == "Phenotypic" | data['Selection Type'] == "Random" | data['Selection Type'] == "Aging"){
+ var keys = ['Relationship Matrix', 'BVE Method', 'Cohorts used in BVE', 'Depth of Pedigree'];
+ for(let i=0; i< keys.length; i++){
+ data[keys[i]] = "";
+ }
+ data['Manuel selected cohorts'] = [];
+ }
+ clearEdgePopUp();
+ callback(data);
+ addServices();
+}
+
+function init() {
+ draw();
+ updateUser();
+}
+
+
+//******************* If the User take data from database, then load them here **********/
+function updateUser(){
+ $.get('/user', function(dat){
+ data_Vue.user = dat.username;
+ data_Vue.curUserGroup = dat.usergroup;
+ data_Vue.geninfo['curUserGroup'] = dat.usergroup;
+ })
+
+ $.post('/database', function(dat){
+ data_Vue.database = dat;
+ })
+
+ $.post('/template_database', function(dat){
+ data_Vue.template_database = dat;
+ //console.log(dat);
+ })
+ data_Vue.project_saved = true;
+}
+
+
+function loadData(ind){
+ // console.log(ind);
+ if(ind != "Create_New_123456YYYY"){
+ $.ajax
+ ({
+ type: "POST",
+ url: '/loadproject',
+ data: {name : ind},
+ success: function (data, msg) {
+ if(data != ''){
+ //console.log("data original");
+ console.log(data);
+ data_Vue.filename = data[0].name;
+ importNetwork_intern(data[0].json);
+ if(data[0].versions.length > 0){
+ data_Vue.versions = data[0].versions.reverse();
+ }
+ //document.getElementById("Project_Name") = ind;
+ document.getElementById("Version").value = "recent";
+ data_Vue.project_saved = true;
+ }else{
+ alert("Loading Data failed. Contact administrator.");
+ }
+ },
+ failure: function(msg)
+ {
+ alert("Loading Data failed. Contact administrator.");
+ },
+ });
+ }else{
+ location.reload();
+ }
+}
+
+function loadVersion(ind){
+ if(ind != "recent"){
+ var json = data_Vue.versions[ind].json;
+ //console.log(json);
+ importNetwork_intern(json);
+ }else{
+ var json = data_Vue.versions[0].json;
+ //console.log(json);
+ importNetwork_intern(json);
+ }
+ data_Vue.project_saved = true;
+}
+
+function loadTemplate(ind){
+ if(ind != "New"){
+ var json = data_Vue.template_database[ind].json;
+ //console.log(json);
+ importNetwork_intern(json);
+ }else{
+ location.reload();
+ }
+}
+
+//************* warn the user about unsaved changes, when leaving:
+window.addEventListener('beforeunload', function (e) {
+ if(data_Vue.project_saved == false){
+ // Cancel the event
+ e.preventDefault();
+ // Chrome requires returnValue to be set
+ e.returnValue = '';
+ }
+});
+
+
+
+function myFunction() {
+ document.getElementById("Icon").classList.toggle("change");
+ data_Vue.show_menu = !data_Vue.show_menu;
+}
+
+
+
+// excel to Array
+var excelToArr = document.getElementById('excelToArray');
+if(excelToArr) {
+ excelToArr.addEventListener('change', importexcelToArray, false);
+}
+
+function importexcelToArray(evt) {
+ var selectedFile = evt.target.files;
+ var excelToArray = new ExcelToArray();
+ excelToArray.parseExcel(selectedFile[0]);
+ }
+
+function saveMatrixToProject(name) {
+ if(!name){
+ var name = data_Vue.geninfo['Project Name'];
+ }else{
+ data_Vue.geninfo['Project Name'] = name;
+ }
+ saveProject(name);
+ loadData(name);
+}
+
+// excel to Array end
diff --git a/public/javascript/testcheck.js b/public/javascript/testcheck.js
new file mode 100644
index 0000000..0073dc3
--- /dev/null
+++ b/public/javascript/testcheck.js
@@ -0,0 +1,744 @@
+// this function will always be called when the body is focused on,
+// it will check all possibly inconsistencies if anything of the following components are changed:
+function checkEverything(id){
+ console.log(id);
+
+
+ if(id == "General_Info"){
+
+ data_Vue.warnings1 = [];
+
+ gen_warn_text = "Please specify a Project Name.";
+ if(!data_Vue.geninfo['Project Name'] & data_Vue.warnings1.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings1.push(gen_warn_text);
+ }else if(data_Vue.geninfo['Project Name'] != "" & data_Vue.warnings1.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings1.splice(data_Vue.warnings1.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Please specify a Species.";
+ if(!data_Vue.geninfo['Species'] & data_Vue.warnings1.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings1.push(gen_warn_text);
+ }else if(data_Vue.geninfo['Species'] != "" & data_Vue.warnings1.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings1.splice(data_Vue.warnings1.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Please specify Time Unit.";
+ if(!data_Vue.geninfo['Time Unit'] & data_Vue.warnings1.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings1.push(gen_warn_text);
+ }else if(data_Vue.geninfo['Time Unit'] != "" & data_Vue.warnings1.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings1.splice(data_Vue.warnings1.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_textEns = "Please specify an Ensembl Dataset.";
+ if ((data_Vue.genetic_data == "Ens" & !data_Vue.geninfo['Ensembl Dataset'] & data_Vue.warnings1.indexOf(gen_warn_textEns) == -1)){
+ data_Vue.warnings1.push(gen_warn_textEns);
+ }else if(data_Vue.genetic_data == "Ens" & data_Vue.geninfo['Ensembl Dataset'] != "" & data_Vue.warnings1.indexOf(gen_warn_textEns) > -1) {
+ data_Vue.warnings1.splice(data_Vue.warnings1.indexOf(gen_warn_textEns),1);
+ }
+ else if (data_Vue.genetic_data != "Ens" & data_Vue.warnings1.indexOf(gen_warn_textEns) > -1){
+ data_Vue.warnings1.splice(data_Vue.warnings1.indexOf(gen_warn_textEns),1);
+ }
+
+ gen_warn_textSNP = "Please specify Max.Number of SNPs. SNPs are in positive integer";
+ checkPosSNP = isPositiveInt(data_Vue.geninfo['Max Number of SNPs']);
+ if (data_Vue.genetic_data == "Ens" & (isNaN(data_Vue.geninfo['Max Number of SNPs']) || data_Vue.geninfo['Max Number of SNPs'] < 0 || (data_Vue.geninfo['Max Number of SNPs'] != "" & checkPosSNP == false )) & data_Vue.warnings1.indexOf(gen_warn_textSNP) == -1){
+ data_Vue.warnings1.push(gen_warn_textSNP);
+ }else if((data_Vue.geninfo['Max Number of SNPs'] == "" || (data_Vue.geninfo['Max Number of SNPs'] >=0 & checkPosSNP == true)) & data_Vue.warnings1.indexOf(gen_warn_textSNP) > -1) {
+ data_Vue.warnings1.splice(data_Vue.warnings1.indexOf(gen_warn_textSNP),1);
+ }
+ else if (data_Vue.genetic_data != "Ens" & data_Vue.warnings1.indexOf(gen_warn_textSNP) > -1){
+ data_Vue.warnings1.splice(data_Vue.warnings1.indexOf(gen_warn_textSNP),1);
+ }
+
+ gen_warn_text = "Please upload Own Map.";
+ if ((data_Vue.genetic_data == "Own" & !data_Vue.geninfo['Own Map Path']) & data_Vue.warnings1.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings1.push(gen_warn_text);
+ }else if(data_Vue.geninfo['Own Map Path'] != "Own" & data_Vue.warnings1.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings1.splice(data_Vue.warnings1.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Please enter number of Chromosomes. Chromosomes are in positive integer.";
+ checkCus = isPositiveInteger(data_Vue.geninfo['Number of Chromosomes']) ? "true" : "false";
+ checkNumeric = isNumeric(data_Vue.geninfo['Number of Chromosomes']);
+ if ((data_Vue.genetic_data == "Cus" & !data_Vue.geninfo['Number of Chromosomes'] & checkCus == "false") & data_Vue.warnings1.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings1.push(gen_warn_text);
+ }
+ else if ((data_Vue.genetic_data == "Cus" & (data_Vue.geninfo['Number of Chromosomes'] != "" & (checkNumeric == "false") || checkCus == "false")) & data_Vue.warnings1.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings1.push(gen_warn_text);
+ }
+ else if ((data_Vue.genetic_data == "Cus" & data_Vue.geninfo['Number of Chromosomes'] != "" & checkCus == "true") & data_Vue.warnings1.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings1.splice(data_Vue.warnings1.indexOf(gen_warn_text),1);
+ }
+ else if (data_Vue.genetic_data != "Cus" & data_Vue.warnings1.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings1.splice(data_Vue.warnings1.indexOf(gen_warn_text),1);
+ }
+
+
+ thisChromoLen = data_Vue.geninfo['Chromosomes of Equal Length'];
+ thisChromoNum = data_Vue.geninfo['Chromosomes Info'].length;
+
+ if (thisChromoNum > 0 ) {
+ for (i=0; i 0 ) & data_Vue.warnings1.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings1.splice(data_Vue.warnings1.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Chromo "+(i+1)+" : "+"Please enter Chromosomes MD and must be in number.";
+ if((!data_Vue.geninfo['Chromosomes Info'][i]['MD'] || isNaN(data_Vue.geninfo['Chromosomes Info'][i]['MD']) || data_Vue.geninfo['Chromosomes Info'][i]['MD'] < 0) & data_Vue.warnings1.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings1.push(gen_warn_text);
+ }
+ else if((data_Vue.geninfo['Chromosomes Info'][i]['MD'] != "" & data_Vue.geninfo['Chromosomes Info'][i]['MD'] > 0) & data_Vue.warnings1.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings1.splice(data_Vue.warnings1.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Chromo "+(i+1)+" : "+"Please enter Chromosomes Recombination and must be in number.";
+ if((!data_Vue.geninfo['Chromosomes Info'][i]['Recombination'] || isNaN(data_Vue.geninfo['Chromosomes Info'][i]['Recombination']) || data_Vue.geninfo['Chromosomes Info'][i]['Recombination'] < 0) & data_Vue.warnings1.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings1.push(gen_warn_text);
+ }
+ else if((data_Vue.geninfo['Chromosomes Info'][i]['Recombination'] != "" & data_Vue.geninfo['Chromosomes Info'][i]['Recombination'] > 0) & data_Vue.warnings1.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings1.splice(data_Vue.warnings1.indexOf(gen_warn_text),1);
+ }
+ }
+ }
+ data_Vue.warnings = data_Vue.warnings1.concat(data_Vue.warnings2, data_Vue.warnings3, data_Vue.warnings4, data_Vue.warnings5);
+ data_Vue.warnings = data_Vue.warnings.filter(Boolean);
+ }
+// end general info validation
+
+
+
+ // phenotype validation
+ if(id == "Phenotype_Info_Div"){
+
+
+ data_Vue.warnings2 = [];
+ count = 0;
+ for(key in data_Vue.warnings1) {
+ if(data_Vue.warnings1.hasOwnProperty(key)) {
+ count++;
+ }
+ }
+
+ if(count==0){
+ data_Vue.warnings1 = [];
+ }
+
+ var phenoLength = data_Vue.traitsinfo.length;
+
+ if (phenoLength > 0 ) {
+ for (i=0; i -1){
+ data_Vue.warnings2.splice(data_Vue.warnings2.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Pheno "+(i+1)+": Please enter Phenotype Mean and must be in number.";
+ if((!data_Vue.traitsinfo[i]['Trait Mean'] || isNaN(data_Vue.traitsinfo[i]['Trait Mean'])) & data_Vue.warnings2.indexOf(gen_warn_text) == -1) {
+ data_Vue.warnings2.push(gen_warn_text);
+ }
+ else if (data_Vue.traitsinfo[i]['Trait Mean'] != "" & isNaN(data_Vue.traitsinfo[i]['Trait Mean']) == false & data_Vue.warnings2.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings2.splice(data_Vue.warnings2.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Pheno "+(i+1)+" : "+"Please enter Phenotype Standard deviation and must be a Positive number.";
+ thisStdDev = data_Vue.traitsinfo[i]['Trait Std Deviation'];
+
+ if ((!thisStdDev || isNaN(thisStdDev) || thisStdDev < 0) & data_Vue.warnings2.indexOf(gen_warn_text) == -1) {
+ data_Vue.warnings2.push(gen_warn_text);
+ }
+ else if ((thisStdDev != "" & thisStdDev >=0) & isNaN(thisStdDev) == false & data_Vue.warnings2.indexOf(gen_warn_text) > -1) {
+ data_Vue.warnings2.splice(data_Vue.warnings2.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Pheno"+(i+1)+" : "+"Please enter Trait Heritability and must be a number between 0 and 1. ";
+ if((!data_Vue.traitsinfo[i]['Trait Heritability'] || data_Vue.traitsinfo[i]['Trait Heritability'] < 0 || data_Vue.traitsinfo[i]['Trait Heritability'] > 1) & data_Vue.warnings2.indexOf(gen_warn_text) == -1) {
+ data_Vue.warnings2.push(gen_warn_text);
+ }
+ else if ((data_Vue.traitsinfo[i]['Trait Heritability'] != "" & data_Vue.traitsinfo[i]['Trait Heritability'] >= 0 & data_Vue.traitsinfo[i]['Trait Heritability'] <= 1) & data_Vue.warnings2.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings2.splice(data_Vue.warnings2.indexOf(gen_warn_text),1);
+ }
+
+ checkPoly = isPositiveInt(data_Vue.traitsinfo[i]['Trait Number of Polygenic Loci']);
+ gen_warn_text = "Pheno"+(i+1)+" : "+"Please enter polygenic loci and must be a Number.";
+ if((!data_Vue.traitsinfo[i]['Trait Number of Polygenic Loci'] || data_Vue.traitsinfo[i]['Trait Number of Polygenic Loci'] < 0 || checkPoly == false) & data_Vue.warnings2.indexOf(gen_warn_text) == -1) {
+ data_Vue.warnings2.push(gen_warn_text);
+ }
+ else if ((data_Vue.traitsinfo[i]['Trait Number of Polygenic Loci'] != "" & data_Vue.traitsinfo[i]['Trait Number of Polygenic Loci'] > 0 & checkPoly == true) & data_Vue.warnings2.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings2.splice(data_Vue.warnings2.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Pheno"+(i+1)+" : "+"Please enter Value per Unit and must be in number.";
+ if((data_Vue.traitsinfo[i]['Trait Value per Unit'] == "" & data_Vue.traitsinfo[i]['Trait Value per Unit'] != "0") & data_Vue.warnings2.indexOf(gen_warn_text) == -1) {
+ data_Vue.warnings2.push(gen_warn_text);
+ }
+ else if (data_Vue.traitsinfo[i]['Trait Value per Unit'] != "" & data_Vue.warnings2.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings2.splice(data_Vue.warnings2.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Pheno"+(i+1)+" : "+"Please enter Major QTL and must be in positive number or can be zero. ";
+ thisMajorQTL = data_Vue.traitsinfo[i]['Trait Major QTL']
+ if(thisMajorQTL < 0 & data_Vue.warnings2.indexOf(gen_warn_text) ==-1){
+ data_Vue.warnings2.push(gen_warn_text);
+ }
+ else if(thisMajorQTL >= 0 & data_Vue.warnings2.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings2.splice(data_Vue.warnings2.indexOf(gen_warn_text),1);
+ }
+
+ var qtlCnt = data_Vue.traitsinfo[i]['Trait Major QTL'];
+ var qtlName = i;
+
+ if (qtlCnt > 0) {
+ qtlsforPheno(qtlName, qtlCnt);
+ }
+
+ matrix1();
+ matrix2();
+
+ }
+ }
+ data_Vue.warnings = data_Vue.warnings1.concat(data_Vue.warnings2, data_Vue.warnings3, data_Vue.warnings4, data_Vue.warnings5);
+ data_Vue.warnings = data_Vue.warnings.filter(Boolean);
+ } // end of phenotype validation
+
+
+ if(id == "Selectionindex_Div"){
+ selection_Index();
+ phenotyping_classes();
+ economyWarning();
+ animalHousingCost();
+ }
+
+
+ if(id == "Variables_Info"){
+
+ data_Vue.warnings3 = [];
+
+ count = 0;
+ for(key in data_Vue.warnings1) {
+ if(data_Vue.warnings1.hasOwnProperty(key)) {
+ count++;
+ }
+ }
+
+ if(count==0){
+ data_Vue.warnings1 = [];
+ }
+ var ownVariableCnt = data_Vue.individualsVar_options.length;
+ var ownVariable = data_Vue.individualsVar_options;
+
+ for(let i=0; i < ownVariableCnt; i++){
+ thisName = ownVariable[i]['name'];
+ thisValue = ownVariable[i]['value'];
+
+ gen_warn_text = thisName+" : "+"Please enter Own variable and must be a positive number.";
+
+ if((thisValue == "" || thisValue =="0" || thisValue <0 || isNaN(thisValue)) & data_Vue.warnings3.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings2.push(gen_warn_text);
+ }
+ else if((thisValue != "" & thisValue >0) & data_Vue.warnings3.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings3.splice(data_Vue.warnings3.indexOf(gen_warn_text),1);
+ }
+
+ }
+ data_Vue.warnings = data_Vue.warnings1.concat(data_Vue.warnings2, data_Vue.warnings3, data_Vue.warnings4, data_Vue.warnings5);
+ data_Vue.warnings = data_Vue.warnings.filter(Boolean);
+ }
+
+
+ if(id == "edge-popUp" || id == "node-popUp"){
+
+ data_Vue.warnings4 = [];
+ count = 0;
+ for(key in data_Vue.warnings1) {
+ if(data_Vue.warnings1.hasOwnProperty(key)) {
+ count++;
+ }
+ }
+
+ if(count==0){
+ data_Vue.warnings1 = [];
+ }
+ nodes = data_Vue.nodes.get();
+ nodes = Array.from(nodes);
+ if(nodes.length > 0){
+ for(let i=0; i < nodes.length; i++){
+ active_node = nodes[i];
+
+ gen_warn_text = "Please assign each node with a name.";
+ if (!active_node['id'] & data_Vue.warnings4.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings4.push(gen_warn_text);
+ }
+
+ gen_warn_text = "Number of individuals in Node " + active_node['id'] + " is not specified";
+ if (!active_node['Number of Individuals'] & data_Vue.warnings4.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings4.push(gen_warn_text);
+ }
+
+ gen_warn_text = "Share of genotyped individuals in " + active_node['id'] + " must be between 0 and 1.";
+ if((!active_node['Proportion of genotyped individuals'] || active_node['Proportion of genotyped individuals'] < 0 || active_node['Proportion of genotyped individuals'] > 1) & data_Vue.warnings4.indexOf(gen_warn_text) == -1) {
+ data_Vue.warnings4.push(gen_warn_text);
+ }
+
+ gen_warn_text = "Share of male individuals in " + active_node['id'] + " must be between 0 and 1.";
+ if((active_node['Sex'] == "Both" & (!active_node['Proportion of Male'] || active_node['Proportion of Male'] < 0 || active_node['Proportion of Male'] > 1)) & data_Vue.warnings4.indexOf(gen_warn_text) == -1) {
+ data_Vue.warnings4.push(gen_warn_text);
+ }
+
+ }
+ }
+
+ data_Vue.warnings = data_Vue.warnings1.concat(data_Vue.warnings2, data_Vue.warnings3, data_Vue.warnings4, data_Vue.warnings5);
+ data_Vue.warnings = data_Vue.warnings.filter(Boolean);
+ }
+
+
+ if(id == "edge-popUp" || id == "node-popUp"){
+
+ count = 0;
+ for(key in data_Vue.warnings1) {
+ if(data_Vue.warnings1.hasOwnProperty(key)) {
+ count++;
+ }
+ }
+
+ if(count==0){
+ data_Vue.warnings1 = [];
+ }
+
+ data_Vue.warnings5 = [];
+
+
+ nodes = data_Vue.nodes.get();
+ nodes = Array.from(nodes);
+ edges = data_Vue.edges.get();
+ edges = Array.from(edges);
+
+ if(edges.length > 0){
+ edge_from = [];
+ edge_to = [];
+ edge_nrfrom = [];
+ edge_nrto = [];
+ edge_type = [];
+ node_name = [];
+ node_founder = [];
+
+ for(let i=0; i < nodes.length; i++){
+ node_name.push(nodes[i]['id'])
+ node_founder.push(nodes[i]['Founder'])
+ }
+
+ for(let i=0; i < edges.length; i++){
+ edge_to.push(edges[i]['to']);
+ edge_from.push(edges[i]['from']);
+ edge_type.push(edges[i]['Breeding Type']);
+ for(let j=0; j < nodes.length; j++){
+ if(edge_from[i]==node_name[j]){
+ edge_nrfrom.push(j);
+ }
+ if(edge_to[i]==node_name[j]){
+ edge_nrto.push(j);
+ }
+ }
+ gen_warn_text = "No Breeding Type selected for Edge between " + edges[i]['from'] + " and " + edges[i]['to'];
+ if (edges[i]['Breeding Type']=="" & data_Vue.warnings5.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings5.push(gen_warn_text);
+ }
+ }
+
+
+ for(let i=0; i < edges.length; i++){
+ if(edge_type[i] =="Selection" || edge_type[i] == "Aging" || edge_type[i] == "Split"){
+ size1 = parseFloat(nodes[edge_nrfrom[i]]['Number of Individuals']);
+ size2 = parseFloat(nodes[edge_nrto[i]]['Number of Individuals']);
+ if(size10 && combine_count != size2){
+ gen_warn_text = "Individual number for Combining nodes to "+ node_name[i] +" do not add up";
+ data_Vue.warnings5.push(gen_warn_text);
+ }
+ if(split_count>0 && split_count != size2){
+ gen_warn_text = "Individual numbers for Splitting node "+ node_name[i] +" do not add up";
+ data_Vue.warnings5.push(gen_warn_text);
+ }
+ }
+ }
+
+
+ }
+
+
+
+
+ data_Vue.warnings = data_Vue.warnings1.concat(data_Vue.warnings2, data_Vue.warnings3, data_Vue.warnings4, data_Vue.warnings5);
+ data_Vue.warnings = data_Vue.warnings.filter(Boolean);
+ }
+
+
+ data_Vue.project_saved = false;
+}
+
+
+ function isNumeric(val) {
+ return !isNaN(parseFloat(val)) && isFinite(val);
+ }
+
+ function isPositiveInteger(val) {
+ var isNumber = Math.floor(Number(val));
+ var thisNumber = (String(isNumber) == val && isNumber >= 0);
+ return thisNumber;
+ }
+
+
+ function isPositiveInt(val) {
+ return val >>> 0 === parseFloat(val);
+ }
+
+
+ function qtlsforPheno(qtlName, qtlCnt) {
+
+ var thisQTL = data_Vue.traitsinfo[qtlName]["Trait QTL Info"];
+ var thisTrait = data_Vue.traitsinfo[qtlName]["Trait Name"];
+
+ for (k=0; k 0 & checkBP == true) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = thisTrait+"-Chromo "+(k+1)+":"+"Please enter chromosomes and must be a Positive Number.";
+ checkchromo = isPositiveInt(thisQTL[k]['QTL Chromosome']);
+ if ((!thisQTL[k]['QTL Chromosome'] || thisQTL[k]['QTL Chromosome'] <= 0 || checkchromo == false) & data_Vue.warnings.indexOf(gen_warn_text) == -1) {
+ data_Vue.warnings.push(gen_warn_text);
+ }
+ else if ((thisQTL[k]['QTL Chromosome'] != "" & thisQTL[k]['QTL Chromosome'] > 0 & checkchromo ==true) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ checkAANumeric = isNumeric(thisQTL[k]['QTL Effect AA']);
+ gen_warn_text = thisTrait+"-EffectAA"+(k+1)+":"+"Please enter Effect AA and must be a Number.";
+ if ((!thisQTL[k]['QTL Effect AA'] || checkAANumeric == false ) & data_Vue.warnings.indexOf(gen_warn_text) == -1) {
+ data_Vue.warnings.push(gen_warn_text);
+ }
+ else if (thisQTL[k]['QTL Effect AA'] != "" & checkAANumeric == true & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ checkABNumeric = isNumeric(thisQTL[k]['QTL Effect AB']);
+ gen_warn_textAB = thisTrait+"-EffectAB"+(k+1)+":"+"Please enter Effect AB and must be a Number.";
+ if ((!thisQTL[k]['QTL Effect AB'] || checkABNumeric == false) & data_Vue.warnings.indexOf(gen_warn_textAB) == -1) {
+ data_Vue.warnings.push(gen_warn_textAB);
+ }
+ else if ((thisQTL[k]['QTL Effect AB'] != "" ) & checkABNumeric == true & data_Vue.warnings.indexOf(gen_warn_textAB) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_textAB),1);
+ }
+
+
+ checkBBNumeric = isNumeric(thisQTL[k]['QTL Effect BB']);
+ gen_warn_textBB = thisTrait+"-EffectBB"+(k+1)+":"+"Please enter Effect BB and must be a Number.";
+ if ((!thisQTL[k]['QTL Effect BB'] || checkBBNumeric == false) & data_Vue.warnings.indexOf(gen_warn_textBB) == -1) {
+ data_Vue.warnings.push(gen_warn_textBB);
+ }
+ else if ((thisQTL[k]['QTL Effect BB'] != "") & checkBBNumeric == true & data_Vue.warnings.indexOf(gen_warn_textBB) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_textBB),1);
+ }
+
+ checkAllele = isNumeric(thisQTL[k]['QTL Allele Frequency']);
+ gen_warn_text = thisTrait+"-Allele Freq "+(k+1)+":"+"Please enter Allele Freq and it must be between 0 and 1.";
+ if ((!thisQTL[k]['QTL Allele Frequency'] || thisQTL[k]['QTL Allele Frequency'] <0 || thisQTL[k]['QTL Allele Frequency'] >1 ) & data_Vue.warnings.indexOf(gen_warn_text) == -1) {
+ data_Vue.warnings.push(gen_warn_text);
+ }
+ else if ((thisQTL[k]['QTL Allele Frequency'] != "" & thisQTL[k]['QTL Allele Frequency'] >=0 & thisQTL[k]['QTL Allele Frequency'] <=1) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ }
+ }
+
+ function matrix1() {
+ var traitsCnt = data_Vue.traitsinfo.length;
+ for(let i=0; i < traitsCnt; i++){
+ for(let j=0; j < data_Vue.matrix[i].row.length; j++){
+ curMatVal = data_Vue.matrix[i].row[j].val;
+
+ gen_warn_text = data_Vue.traitsinfo[i]['Trait Name']+"-"+data_Vue.traitsinfo[j]['Trait Name']+":Please enter Phenotypic Correlation and must be a number between -1 and 1 ";
+
+ if (((!curMatVal & curMatVal == "" & curMatVal !="0") || curMatVal <-1 || curMatVal > 1 || isNaN(curMatVal)) & data_Vue.warnings.indexOf(gen_warn_text) == -1) {
+ data_Vue.warnings.push(gen_warn_text);
+ }
+ else if ((curMatVal != "" & curMatVal >=-1 & curMatVal <=1 & isNaN(curMatVal) == false ) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ }
+ }
+ }
+
+
+ function matrix2() {
+ var traitsCnt = data_Vue.traitsinfo.length;
+ for(let i=0; i < traitsCnt; i++){
+ for(let j=0; j < data_Vue.matrix2[i].row.length; j++){
+ curMatVal2 = data_Vue.matrix2[i].row[j].val;
+
+ gen_warn_text = data_Vue.traitsinfo[i]['Trait Name']+"-"+data_Vue.traitsinfo[j]['Trait Name']+":Please enter Genetic Correlation and must be a number between -1 and 1 ";
+
+ if (((!curMatVal2 & curMatVal2 == "" & curMatVal2 !="0") || curMatVal2 <-1 || curMatVal2 > 1 || isNaN(curMatVal2)) & data_Vue.warnings.indexOf(gen_warn_text) == -1) {
+ data_Vue.warnings.push(gen_warn_text);
+ }
+ else if ((curMatVal2 != "" & curMatVal2 >=-1 & curMatVal2 <=1 & isNaN(curMatVal2) == false ) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ }
+ }
+ }
+
+
+
+ function selection_Index() {
+
+ var traitsCnt = data_Vue.traitsinfo.length;
+ var siCnt = data_Vue.selection_index.length
+
+ if (siCnt > 0) {
+ for(let i=0; i -1) {
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ }
+ }
+ }
+ }
+
+
+
+
+ function phenotyping_classes() {
+ var traitsCnt = data_Vue.traitsinfo.length;
+ var piCnt = data_Vue.phenotyping_class.length
+
+ if (piCnt > 0) {
+ for(let i=0; i=0) & data_Vue.warnings.indexOf(gen_warn_text) > -1) {
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = pName+(i+1)+":Pheno"+(j+1)+": Please enter phenotyping classes and it must be a positive number or zero.";
+ if ((pVar == null || isNaN(pVar) || pVar < 0 || checkpVar == false || checkPospVar == false) & data_Vue.warnings.indexOf(gen_warn_text) == -1) {
+ data_Vue.warnings.push(gen_warn_text);
+ }
+ else if ((pVar != null & pVar >= 0 & checkpVar == true & checkPospVar == true) & data_Vue.warnings.indexOf(gen_warn_text) > -1) {
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+ }
+ }
+ }
+ }
+
+
+
+ function economyWarning() {
+
+ gen_warn_text = "Please enter Fixed Cost must be a number between 0 and 100.";
+
+ curFixedCost = data_Vue.economy['Fixed Cost'];
+ console.log(curFixedCost);
+
+ if(((!curFixedCost & curFixedCost !=0) || curFixedCost < 0 || curFixedCost > 100 || isNaN(curFixedCost)) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ console.log('empty'+curFixedCost);
+ }
+ else if((curFixedCost != "" & curFixedCost >= 0 & curFixedCost <= 100) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Please enter Interest Rate must be a number.";
+ curInt = data_Vue.economy['Interest Rate'];
+
+ if(((!curInt & curInt !=0) || curInt < 0 || curInt > 100 || isNaN(curInt)) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ console.log('empty'+curInt);
+ }
+ else if((curInt != "" & curInt >= 0 & curInt <= 100) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ gen_warn_text = "Please enter Genotyping Cost must be a number. Cost must be less than 100 euros";
+ curGenoType = data_Vue.economy['Genotyping Cost'];
+
+ if(((!curGenoType & curGenoType !=0) || curGenoType < 0 || curGenoType > 100 || isNaN(curGenoType)) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ console.log('empty'+curInt);
+ }
+ else if((curGenoType != "" & curGenoType >= 0 & curGenoType <= 100) & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ }
+
+
+function animalHousingCost() {
+
+ var animal_housing_costCnt = data_Vue.economy['Animal Housing Costs'].length;
+ var thisAnimalHousingCosts = data_Vue.economy['Animal Housing Costs'];
+
+ for(let i=0; i < animal_housing_costCnt; i++){
+ thisCost = thisAnimalHousingCosts[i]['Cost'];
+ nameOfCost = thisAnimalHousingCosts[i]['Name'];
+
+ gen_warn_text = nameOfCost+" : "+"Please enter Animal Housing Cost and must be a number.";
+
+ if(((thisCost =="" & thisCost !=0) || thisCost <0 || isNaN(thisCost)) & data_Vue.warnings.indexOf(gen_warn_text) == -1){
+ data_Vue.warnings.push(gen_warn_text);
+ }
+ else if(thisCost != "" & thisCost >=0 & data_Vue.warnings.indexOf(gen_warn_text) > -1){
+ data_Vue.warnings.splice(data_Vue.warnings.indexOf(gen_warn_text),1);
+ }
+
+ }
+}
+
+
+function check_eigen(){
+
+}
+
+// this funtion will always be called after an edge has been created,
+// you can use this function to add further services, e.g add the secong parent automatically if Breeding Type == Reproduction etc.
+function addServices(){
+ if(data_Vue.active_edge['Breeding Type'] == "Reproduction"){
+ var val = document.getElementById("parents_input").value ;
+ if(val =='') return;
+ if(data_Vue.nodes.get(val) == null){ // create new node by copying:
+ var p1_node = data_Vue.nodes.get(data_Vue.active_edge.from);
+ p1_node.Sex = p1_node.Sex == "Male" ? "Female" : "Male" ;
+ p1_node.id = val;
+ p1_node.x = p1_node.x+50;
+ addNode_extern(p1_node);
+ }
+ var child_node = data_Vue.nodes.get(data_Vue.active_edge.to);
+ var new_edge = new myEdge(val, child_node.id);
+ new_edge['Breeding Type'] = "Reproduction";
+ new_edge['Time Needed'] = document.getElementById("time_n").value;
+ for(let i=0; i < data_Vue.active_edge.useVar.length; i++){
+ new_edge['useVar'].push(data_Vue.active_edge.useVar[i]);
+ }
+
+ addEdge_extern(new_edge);
+ }
+ if(data_Vue.active_edge['Breeding Type'] == "Split"){
+ var val = document.getElementById("split_input").value ;
+ if(val =='') return;
+ if(data_Vue.nodes.get(val) == null){ // create new node by copying:
+ var p1_node = data_Vue.nodes.get(data_Vue.active_edge.to);
+ p1_node.id = val;
+ p1_node.x = p1_node.x+50;
+ p1_node['Number of Individuals'] = data_Vue.nodes.get(data_Vue.active_edge.from)['Number of Individuals'] - p1_node['Number of Individuals'];
+ p1_node.individualsVar ='';
+ addNode_extern(p1_node);
+ }
+ var parent_node = data_Vue.nodes.get(data_Vue.active_edge.from);
+ var new_edge = new myEdge(parent_node.id, val);
+ new_edge['Breeding Type'] = "Split";
+
+ addEdge_extern(new_edge);
+ }
+}
diff --git a/public/styles/network.css b/public/styles/network.css
index 3c8113a..ddf8b37 100644
--- a/public/styles/network.css
+++ b/public/styles/network.css
@@ -496,9 +496,4 @@ table.trait_table input[type=Number]{
}
*/
-.excel_table {
- background-color: #f0f0f0;
- border-collapse: collapse;
- text-align: center;
- max-width:800px;
-}
+