extensions/net.sf.basedb.reggie/trunk/resources/analysis/genotype_standalone_check.js

Code
Comments
Other
Rev Date Author Line
6441 18 Oct 21 nicklas 1 var GenoType = function()
6441 18 Oct 21 nicklas 2 {
6441 18 Oct 21 nicklas 3   var gt = {};
6441 18 Oct 21 nicklas 4   var debug = 0;
6441 18 Oct 21 nicklas 5   var selectionIsValid = false;
6441 18 Oct 21 nicklas 6   var files;
6441 18 Oct 21 nicklas 7   
6441 18 Oct 21 nicklas 8   // Page initialization
6441 18 Oct 21 nicklas 9   gt.initPage = function()
6441 18 Oct 21 nicklas 10   {
6441 18 Oct 21 nicklas 11     
6441 18 Oct 21 nicklas 12     // Step 1
6441 18 Oct 21 nicklas 13     Buttons.addClickHandler('btnBrowse', gt.selectFiles);
6441 18 Oct 21 nicklas 14     Events.addEventHandler('files', 'base-selected', gt.setFileCallback);
6441 18 Oct 21 nicklas 15     Events.addEventHandler('files', 'change', gt.filesOnChange);
6441 18 Oct 21 nicklas 16     Events.addEventHandler('step-1', 'wizard-validate', gt.validateStep1);
6441 18 Oct 21 nicklas 17
6441 18 Oct 21 nicklas 18     // Step 2
6441 18 Oct 21 nicklas 19     Events.addEventHandler('step-2', 'wizard-initialize', gt.initializeStep2);
6441 18 Oct 21 nicklas 20     
6441 18 Oct 21 nicklas 21     // Navigation
6441 18 Oct 21 nicklas 22     Buttons.addClickHandler('gocancel', Wizard.cancelWizard);
6441 18 Oct 21 nicklas 23     Buttons.addClickHandler('gorestart', Wizard.restartWizard);
6441 18 Oct 21 nicklas 24     Buttons.addClickHandler('gonext', Wizard.goNextOnClick);
6441 18 Oct 21 nicklas 25     Buttons.addClickHandler('goregister', Wizard.goRegister);
6441 18 Oct 21 nicklas 26       
6441 18 Oct 21 nicklas 27     // Final registration
6824 30 Aug 22 nicklas 28     //Events.addEventHandler('wizard', 'wizard-submit', gt.submit);
6441 18 Oct 21 nicklas 29
6441 18 Oct 21 nicklas 30     Wizard.showLoadingAnimation('Loading bioassays...');
6441 18 Oct 21 nicklas 31     var url = '../Genotype.servlet?ID='+App.getSessionId();
6441 18 Oct 21 nicklas 32     url += '&cmd=PrepareForGenotypeChecks';
6441 18 Oct 21 nicklas 33     Wizard.asyncJsonRequest(url, gt.initializeStep1);
6441 18 Oct 21 nicklas 34   }
6441 18 Oct 21 nicklas 35   
6441 18 Oct 21 nicklas 36   // --- Step 1 -----------------------------------
6441 18 Oct 21 nicklas 37   gt.initializeStep1 = function(response)
6441 18 Oct 21 nicklas 38   {
6441 18 Oct 21 nicklas 39     var frm = document.forms['reggie'];  
6441 18 Oct 21 nicklas 40
7202 25 May 23 nicklas 41     var msg = response.existingTumorsCount + ' tumors';
7202 25 May 23 nicklas 42     if (response.existingNormalsCount) msg += ' and '+response.existingNormalsCount+' normals';
6595 22 Feb 22 nicklas 43     Doc.element('alreadyChecked').innerHTML = msg;
6441 18 Oct 21 nicklas 44
6441 18 Oct 21 nicklas 45     Doc.show('step-1');
6441 18 Oct 21 nicklas 46     Doc.show('gonext');
6441 18 Oct 21 nicklas 47
6441 18 Oct 21 nicklas 48     frm.files.focus();
6441 18 Oct 21 nicklas 49   }
6441 18 Oct 21 nicklas 50   
6441 18 Oct 21 nicklas 51   gt.validateStep1 = function(event)
6441 18 Oct 21 nicklas 52   {
6441 18 Oct 21 nicklas 53     if (!selectionIsValid) event.preventDefault();
6441 18 Oct 21 nicklas 54   }
6441 18 Oct 21 nicklas 55   
6441 18 Oct 21 nicklas 56   gt.selectFiles = function()
6441 18 Oct 21 nicklas 57   {
6441 18 Oct 21 nicklas 58     var frm = document.forms['reggie'];
6441 18 Oct 21 nicklas 59     if (frm.files.disabled) return;
6441 18 Oct 21 nicklas 60     
6441 18 Oct 21 nicklas 61     var url = '&resetTemporary=1';
6597 22 Feb 22 nicklas 62     url += '&tmpfilter:STRING:name='+encodeURIComponent('%.vcf|%.vcf.gz');
6441 18 Oct 21 nicklas 63     Dialogs.selectItem('FILE', 'files', 1, url);
6441 18 Oct 21 nicklas 64   }
6441 18 Oct 21 nicklas 65
6441 18 Oct 21 nicklas 66   gt.setFileCallback = function(event)
6441 18 Oct 21 nicklas 67   {
6441 18 Oct 21 nicklas 68     var frm = document.forms['reggie'];
6441 18 Oct 21 nicklas 69     var file = event.detail;
6441 18 Oct 21 nicklas 70     App.debug(event.detail);
6441 18 Oct 21 nicklas 71     var opt = Reggie.getListOption('files', file.id);
6441 18 Oct 21 nicklas 72     if (opt)
6441 18 Oct 21 nicklas 73     {
6441 18 Oct 21 nicklas 74       opt.selected = true;
6441 18 Oct 21 nicklas 75     }
6441 18 Oct 21 nicklas 76     else
6441 18 Oct 21 nicklas 77     {
6441 18 Oct 21 nicklas 78       var option = gt.createListOption(frm.files.length+1, file, true);
6441 18 Oct 21 nicklas 79       frm.files[frm.files.length] = option;
6441 18 Oct 21 nicklas 80     }
6441 18 Oct 21 nicklas 81     
6456 25 Oct 21 nicklas 82     if (file.remaining == 0) 
6456 25 Oct 21 nicklas 83     {
6456 25 Oct 21 nicklas 84       Events.sendChangeEvent('files');
6456 25 Oct 21 nicklas 85       frm.files.focus();
6456 25 Oct 21 nicklas 86     }
6441 18 Oct 21 nicklas 87   }
6441 18 Oct 21 nicklas 88
6441 18 Oct 21 nicklas 89   gt.createListOption = function(index, file, selected)
6441 18 Oct 21 nicklas 90   {
6441 18 Oct 21 nicklas 91     var name = index+': '+file.name;
6441 18 Oct 21 nicklas 92     var option = new Option(name, file.id, false, selected);
6441 18 Oct 21 nicklas 93     option.file = file;
6441 18 Oct 21 nicklas 94     return option;  
6441 18 Oct 21 nicklas 95   }
6441 18 Oct 21 nicklas 96   
6441 18 Oct 21 nicklas 97   gt.filesOnChange = function()
6441 18 Oct 21 nicklas 98   {
6441 18 Oct 21 nicklas 99     var frm = document.forms['reggie'];
6441 18 Oct 21 nicklas 100     
6441 18 Oct 21 nicklas 101     selectionIsValid = false;
6441 18 Oct 21 nicklas 102     var numSelected = 0;
6441 18 Oct 21 nicklas 103     Wizard.setInputStatus('files');
6441 18 Oct 21 nicklas 104     Wizard.hideGoNextConfirmation();
6441 18 Oct 21 nicklas 105
6441 18 Oct 21 nicklas 106     for (var fNo = 0; fNo < frm.files.length; fNo++)
6441 18 Oct 21 nicklas 107     {
6441 18 Oct 21 nicklas 108       if (frm.files[fNo].selected) 
6441 18 Oct 21 nicklas 109       {
6441 18 Oct 21 nicklas 110         numSelected++;
6441 18 Oct 21 nicklas 111       }
6441 18 Oct 21 nicklas 112     }
6441 18 Oct 21 nicklas 113     
6441 18 Oct 21 nicklas 114     if (numSelected == 0)
6441 18 Oct 21 nicklas 115     {
6441 18 Oct 21 nicklas 116       Wizard.setInputStatus('files', 'invalid', 'Select at least one file');
6441 18 Oct 21 nicklas 117       return;
6441 18 Oct 21 nicklas 118     }
6441 18 Oct 21 nicklas 119     selectionIsValid = true;
6441 18 Oct 21 nicklas 120     Wizard.setInputStatus('files', 'valid');
6441 18 Oct 21 nicklas 121   }
6441 18 Oct 21 nicklas 122
6441 18 Oct 21 nicklas 123   gt.initializeStep2 = function()
6441 18 Oct 21 nicklas 124   {
6441 18 Oct 21 nicklas 125     var frm = document.forms['reggie'];
6441 18 Oct 21 nicklas 126     
6441 18 Oct 21 nicklas 127     var submitInfo = {};
6441 18 Oct 21 nicklas 128     var files = [];
6441 18 Oct 21 nicklas 129     submitInfo.files = files;
6441 18 Oct 21 nicklas 130       
6441 18 Oct 21 nicklas 131     for (var fNo = 0; fNo < frm.files.length; fNo++)
6441 18 Oct 21 nicklas 132     {
6441 18 Oct 21 nicklas 133       if (frm.files[fNo].selected) 
6441 18 Oct 21 nicklas 134       {
6441 18 Oct 21 nicklas 135         files[files.length] = { 'id': parseInt(frm.files[fNo].file.id) };
6441 18 Oct 21 nicklas 136       }
6441 18 Oct 21 nicklas 137     }
6441 18 Oct 21 nicklas 138
6441 18 Oct 21 nicklas 139     var url = '../Genotype.servlet?ID='+App.getSessionId();
6441 18 Oct 21 nicklas 140     url += '&cmd=GenotypeStandaloneFileCheck';
6441 18 Oct 21 nicklas 141     Wizard.showLoadingAnimation('Comparing genotypes...', 'genotypes-progress');
6441 18 Oct 21 nicklas 142     Wizard.asyncJsonRequest(url, gt.checkCompleted, 'POST', JSON.stringify(submitInfo));
6441 18 Oct 21 nicklas 143   }
6441 18 Oct 21 nicklas 144   
6441 18 Oct 21 nicklas 145   gt.checkCompleted = function(response)
6441 18 Oct 21 nicklas 146   {
6441 18 Oct 21 nicklas 147     files = response.files;
6441 18 Oct 21 nicklas 148     
6441 18 Oct 21 nicklas 149     var html = '<table id="compareTable">';
6441 18 Oct 21 nicklas 150     html += '<thead class="bg-filled-100">';
6441 18 Oct 21 nicklas 151     html += '<tr>';
6451 22 Oct 21 nicklas 152     html += '<th colspan="3">Comparisons</th>';
6444 19 Oct 21 nicklas 153     html += '<th class="dottedleft" colspan="5">Genotypes</th>';
6451 22 Oct 21 nicklas 154     html += '<th class="dottedleft" colspan="5"></th>';
6456 25 Oct 21 nicklas 155     html += '<th class="dottedleft"></th>';
6441 18 Oct 21 nicklas 156     html += '</tr>';
6441 18 Oct 21 nicklas 157     html += '<tr>';
6441 18 Oct 21 nicklas 158     html += '<th>Total</th>';
6451 22 Oct 21 nicklas 159     html += '<th>Same PAT</th>';
6441 18 Oct 21 nicklas 160     html += '<th>Skipped</th>';
6441 18 Oct 21 nicklas 161     html += '<th class="dottedleft">File</th>';
6441 18 Oct 21 nicklas 162     html += '<th>Total</th>';
6444 19 Oct 21 nicklas 163     html += '<th>Usable</th>';
6441 18 Oct 21 nicklas 164     html += '<th>HET</th>';
6441 18 Oct 21 nicklas 165     html += '<th class="icon-col"></th>';
6441 18 Oct 21 nicklas 166     html += '<th class="dottedleft icon-col"></th>';
6451 22 Oct 21 nicklas 167     html += '<th colspan="3">Warnings and messages</th>';
6441 18 Oct 21 nicklas 168     html += '<th class="icon-col"></th>';
6456 25 Oct 21 nicklas 169     html += '<th class="dottedleft comment"></th>';
6441 18 Oct 21 nicklas 170     html += '</tr>';
6441 18 Oct 21 nicklas 171     html += '</thead>';
6441 18 Oct 21 nicklas 172     
6441 18 Oct 21 nicklas 173     var htmlNoMessages = '';
6441 18 Oct 21 nicklas 174     var htmlNoWarnings = '';
6441 18 Oct 21 nicklas 175     
6441 18 Oct 21 nicklas 176     for (var fNo = 0; fNo < files.length; fNo++)
6441 18 Oct 21 nicklas 177     {
6441 18 Oct 21 nicklas 178       var file = files[fNo];
6443 19 Oct 21 nicklas 179       var cmp = file.compare;
6443 19 Oct 21 nicklas 180       var vcf = cmp.vcf;
6441 18 Oct 21 nicklas 181       
6441 18 Oct 21 nicklas 182       var hetPercentage = vcf.gtCount ? Reggie.formatNumber(100*vcf.hetCount/vcf.gtCount, '%', -1) : '-';
6441 18 Oct 21 nicklas 183       var rowspan = cmp.messages.length || 1;
6441 18 Oct 21 nicklas 184       
6441 18 Oct 21 nicklas 185       var tmp = '<tbody class="highlight"><tr>';
6441 18 Oct 21 nicklas 186       tmp += '<td rowspan="'+rowspan+'">'+cmp.total+'</td>';
6451 22 Oct 21 nicklas 187       tmp += '<td rowspan="'+rowspan+'">'+(cmp.samePat || '')+'</td>';
6441 18 Oct 21 nicklas 188       tmp += '<td rowspan="'+rowspan+'">'+(cmp.skipped || '')+'</td>';
6595 22 Feb 22 nicklas 189       tmp += '<td rowspan="'+rowspan+'" class="dottedleft text-col">'+Strings.encodeTags(file.path)+'</td>';
6444 19 Oct 21 nicklas 190       tmp += '<td rowspan="'+rowspan+'">'+vcf.totalCount+'</td>';
6441 18 Oct 21 nicklas 191       tmp += '<td rowspan="'+rowspan+'">'+vcf.gtCount+'</td>';
6441 18 Oct 21 nicklas 192       tmp += '<td rowspan="'+rowspan+'">'+hetPercentage+'</td>';
6441 18 Oct 21 nicklas 193       tmp += '<td rowspan="'+rowspan+'" class="icon-col">';
6441 18 Oct 21 nicklas 194       tmp += '<span class="link vcf-link" data-file-id="'+vcf.fileId+'" title="View genotype statistics"><img src="../images/vcf_file.png"></span>';
6441 18 Oct 21 nicklas 195       tmp += '</td>';
6441 18 Oct 21 nicklas 196
6441 18 Oct 21 nicklas 197       // The first message is on the main <tr>
6441 18 Oct 21 nicklas 198       var numWarnings = 0;
6441 18 Oct 21 nicklas 199       if (cmp.messages.length > 0)
6441 18 Oct 21 nicklas 200       {
6441 18 Oct 21 nicklas 201         var msg = cmp.messages[0];
6441 18 Oct 21 nicklas 202         if (msg.warningLevel != 'INFO') numWarnings++;
6441 18 Oct 21 nicklas 203         tmp += gt.getMessageHtml(msg, file, vcf);
6441 18 Oct 21 nicklas 204       }
6441 18 Oct 21 nicklas 205       else
6441 18 Oct 21 nicklas 206       {
6441 18 Oct 21 nicklas 207         tmp += '<td class="dottedleft icon-col"></td>';
6441 18 Oct 21 nicklas 208         tmp += '<td class="text-col" colspan="2"></td>';
6441 18 Oct 21 nicklas 209         tmp += '<td class="icon-col"></td>';
6441 18 Oct 21 nicklas 210       }
6456 25 Oct 21 nicklas 211       tmp += '<td rowspan="'+rowspan+'" class="dottedleft comment"></td>';
6441 18 Oct 21 nicklas 212       tmp += '</tr>';
6441 18 Oct 21 nicklas 213       
6441 18 Oct 21 nicklas 214       // If there are more messages, add more <tr>
6441 18 Oct 21 nicklas 215       for (var mNo = 1; mNo < cmp.messages.length; mNo++)
6441 18 Oct 21 nicklas 216       {
6441 18 Oct 21 nicklas 217         var msg = cmp.messages[mNo];
6441 18 Oct 21 nicklas 218         if (msg.warningLevel != 'INFO') numWarnings++;
6441 18 Oct 21 nicklas 219         tmp += '<tr>'+gt.getMessageHtml(msg, file, vcf) + '</tr>';
6441 18 Oct 21 nicklas 220       }
6441 18 Oct 21 nicklas 221       tmp += '</tbody>';
6441 18 Oct 21 nicklas 222       
6441 18 Oct 21 nicklas 223       if (cmp.messages.length == 0)
6441 18 Oct 21 nicklas 224       {
6441 18 Oct 21 nicklas 225         // No messages are sorted last in the list
6441 18 Oct 21 nicklas 226         htmlNoMessages += tmp;
6441 18 Oct 21 nicklas 227       }
6441 18 Oct 21 nicklas 228       else if (numWarnings == 0)
6441 18 Oct 21 nicklas 229       {
6441 18 Oct 21 nicklas 230         // No warnings are sorted in the middle
6441 18 Oct 21 nicklas 231         htmlNoWarnings += tmp;
6441 18 Oct 21 nicklas 232       }
6441 18 Oct 21 nicklas 233       else
6441 18 Oct 21 nicklas 234       {
6441 18 Oct 21 nicklas 235         // Items with at least one warning are sorted first
6441 18 Oct 21 nicklas 236         html += tmp;
6441 18 Oct 21 nicklas 237       }
6441 18 Oct 21 nicklas 238     }
6441 18 Oct 21 nicklas 239     
6441 18 Oct 21 nicklas 240     html += htmlNoWarnings;
6441 18 Oct 21 nicklas 241     html += htmlNoMessages;
6441 18 Oct 21 nicklas 242     html += '</table>';
6441 18 Oct 21 nicklas 243     Doc.element('comparisons').innerHTML = html;
6441 18 Oct 21 nicklas 244
6441 18 Oct 21 nicklas 245     // Add click handler to VCF files
6441 18 Oct 21 nicklas 246     var clickableItems = document.getElementsByClassName('vcf-link');
6441 18 Oct 21 nicklas 247     for (var i = 0; i < clickableItems.length; i++)
6441 18 Oct 21 nicklas 248     {
6441 18 Oct 21 nicklas 249       Events.addEventHandler(clickableItems[i], 'click', gt.vcfLinkOnClick);
6441 18 Oct 21 nicklas 250     }
6441 18 Oct 21 nicklas 251     
6456 25 Oct 21 nicklas 252     // Case summary links
6456 25 Oct 21 nicklas 253     var cs = document.getElementsByClassName('case-summary');
6456 25 Oct 21 nicklas 254     for (var i = 0; i < cs.length; i++)
6456 25 Oct 21 nicklas 255     {
6456 25 Oct 21 nicklas 256       Events.addEventHandler(cs[i], 'click', Reggie.openCaseSummaryPopupOnEvent);
6456 25 Oct 21 nicklas 257     }
6456 25 Oct 21 nicklas 258
6441 18 Oct 21 nicklas 259     Wizard.setCurrentStep(2);
6441 18 Oct 21 nicklas 260     Doc.show('step-2');
6456 25 Oct 21 nicklas 261     Doc.show('gorestart');
6441 18 Oct 21 nicklas 262   }
6441 18 Oct 21 nicklas 263
6441 18 Oct 21 nicklas 264   
6441 18 Oct 21 nicklas 265   gt.getMessageHtml = function(message, file, vcf)
6441 18 Oct 21 nicklas 266   {
6441 18 Oct 21 nicklas 267     var level = message.warningLevel;
6441 18 Oct 21 nicklas 268     var icon = null;
6441 18 Oct 21 nicklas 269     if (level == 'INFO')
6441 18 Oct 21 nicklas 270     {
6441 18 Oct 21 nicklas 271       icon = 'ok.png';
6441 18 Oct 21 nicklas 272     }
6441 18 Oct 21 nicklas 273     else if (level == 'LOW')
6441 18 Oct 21 nicklas 274     {
6441 18 Oct 21 nicklas 275       icon = 'warning_small.png';
6441 18 Oct 21 nicklas 276     }
6441 18 Oct 21 nicklas 277     else
6441 18 Oct 21 nicklas 278     {
6441 18 Oct 21 nicklas 279       icon = 'warning.png';
6441 18 Oct 21 nicklas 280     }
6441 18 Oct 21 nicklas 281
6441 18 Oct 21 nicklas 282     var html = '';
6441 18 Oct 21 nicklas 283     html += '<td class="dottedleft icon-col"><img src="../images/'+icon+'"></td>';
6441 18 Oct 21 nicklas 284     html += '<td class="text-col" title="'+(message.messageTooltip || '')+'">'+Strings.encodeTags(message.message) + '</td>';
6441 18 Oct 21 nicklas 285     html += '<td class="text-col">';
6451 22 Oct 21 nicklas 286     if (message.specimen)
6451 22 Oct 21 nicklas 287     {
6451 22 Oct 21 nicklas 288       html += Strings.encodeTags(message.specimen.patientName);
6451 22 Oct 21 nicklas 289     }
6451 22 Oct 21 nicklas 290     html += '</td>';
6451 22 Oct 21 nicklas 291     html += '<td class="text-col">';
6595 22 Feb 22 nicklas 292     if (message.otherAssay)
6441 18 Oct 21 nicklas 293     {
6595 22 Feb 22 nicklas 294       html += gt.tagCommonPartOfName(file.name, message.otherAssay);
6595 22 Feb 22 nicklas 295       html += '<span class="link case-summary" data-name="'+Strings.encodeTags(message.otherAssay)+'" title="Show case summary"><img src="../images/case_summary.png"></span>';
6441 18 Oct 21 nicklas 296       if (message.DO_NOT_USE) html += '<img src="../images/donotuse.png" title="DoNotUse-'+Strings.encodeTags(message.DO_NOT_USE + ': ' + message.DO_NOT_USE_COMMENT)+'">';
6595 22 Feb 22 nicklas 297       if (message.flagged) html += '<img src="../images/flag.png" title="'+Strings.encodeTags(message.otherAssay)+' is already flagged">';
6441 18 Oct 21 nicklas 298       if (message.currentVerifiedBy) 
6441 18 Oct 21 nicklas 299       {
6441 18 Oct 21 nicklas 300         var vicon = message.currentVerifiedBy == 'LYSATE' ? 'gt-verified-lysate.png' : 'gt-verified.png';
6595 22 Feb 22 nicklas 301         html += '<img src="../images/'+vicon+'" title="'+Strings.encodeTags(message.otherAssay+' is already verified by '+message.currentVerifiedBy)+'">';
6441 18 Oct 21 nicklas 302       }
6441 18 Oct 21 nicklas 303     }
6441 18 Oct 21 nicklas 304     html += '</td>';
6441 18 Oct 21 nicklas 305     html += '<td class="icon-col">';
6441 18 Oct 21 nicklas 306     if (message.vcf)
6441 18 Oct 21 nicklas 307     {
6441 18 Oct 21 nicklas 308       html += ' <span class="link vcf-link" data-file-id="'+vcf.fileId+'"';
6441 18 Oct 21 nicklas 309       html += ' data-item-id2="'+message.id+'" data-file-id2="'+message.vcf.fileId+'"';
6441 18 Oct 21 nicklas 310       html += ' title="Compare genotypes (hold CTRL, ALT or SHIFT to open in a new popup)"><img src="../images/vcf_file.png"></span>';
6441 18 Oct 21 nicklas 311     }
6441 18 Oct 21 nicklas 312     html += '</td>';
6441 18 Oct 21 nicklas 313     return html;
6441 18 Oct 21 nicklas 314   }
6441 18 Oct 21 nicklas 315   
6441 18 Oct 21 nicklas 316   
6441 18 Oct 21 nicklas 317   gt.tagCommonPartOfName = function(name1, name2)
6441 18 Oct 21 nicklas 318   {
6441 18 Oct 21 nicklas 319     var n1 = name1.split('.');
6441 18 Oct 21 nicklas 320     var n2 = name2.split('.');
6441 18 Oct 21 nicklas 321     var i = 0;
6441 18 Oct 21 nicklas 322     
6441 18 Oct 21 nicklas 323     var common = '';
6441 18 Oct 21 nicklas 324     var sep = '.';
6441 18 Oct 21 nicklas 325     while (i < n1.length && i < n2.length && n1[i] == n2[i])
6441 18 Oct 21 nicklas 326     {
6441 18 Oct 21 nicklas 327       common += n1[i] + sep;
6441 18 Oct 21 nicklas 328       i++;
6441 18 Oct 21 nicklas 329     }
6441 18 Oct 21 nicklas 330     
6441 18 Oct 21 nicklas 331     var diff = '';
6441 18 Oct 21 nicklas 332     sep = '';
6441 18 Oct 21 nicklas 333     while (i < n2.length)
6441 18 Oct 21 nicklas 334     {
6441 18 Oct 21 nicklas 335       diff += sep + n2[i];
6441 18 Oct 21 nicklas 336       i++;
6441 18 Oct 21 nicklas 337       sep = '.';
6441 18 Oct 21 nicklas 338     }
6441 18 Oct 21 nicklas 339     
6441 18 Oct 21 nicklas 340     return '<span class="commonpart">'+Strings.encodeTags(common)+'</span><span class="diffpart">'+Strings.encodeTags(diff)+'</span>';
6441 18 Oct 21 nicklas 341   }
6441 18 Oct 21 nicklas 342   
6441 18 Oct 21 nicklas 343   gt.vcfLinkOnClick = function(event)
6441 18 Oct 21 nicklas 344   {
6441 18 Oct 21 nicklas 345     var fileId = Data.int(event.currentTarget, 'file-id');
6441 18 Oct 21 nicklas 346     var itemId = Data.get(event.currentTarget, 'item-id');
6441 18 Oct 21 nicklas 347     var fileId2 = Data.int(event.currentTarget, 'file-id2');
6441 18 Oct 21 nicklas 348     var itemId2 = Data.get(event.currentTarget, 'item-id2');
6441 18 Oct 21 nicklas 349     var specialKey = event.altKey || event.ctrlKey || event.shiftKey;
6441 18 Oct 21 nicklas 350     
6441 18 Oct 21 nicklas 351     var url = 'view_genotypes.jsp?ID=' + App.getSessionId();
6441 18 Oct 21 nicklas 352     url += '&fileId='+fileId;
6441 18 Oct 21 nicklas 353     url += '&itemId='+itemId;
6441 18 Oct 21 nicklas 354     url += '&fileId2='+fileId2;
6441 18 Oct 21 nicklas 355     url += '&itemId2='+itemId2;
6441 18 Oct 21 nicklas 356     
6441 18 Oct 21 nicklas 357     Dialogs.openPopup(url, (specialKey ? 'ViewVcf'+itemId+itemId2 : 'ViewVcf'), 900, 600);
6441 18 Oct 21 nicklas 358   }
6441 18 Oct 21 nicklas 359
6441 18 Oct 21 nicklas 360   return gt;
6441 18 Oct 21 nicklas 361 }();
6441 18 Oct 21 nicklas 362
6441 18 Oct 21 nicklas 363 Doc.onLoad(GenoType.initPage);
6441 18 Oct 21 nicklas 364