6170 |
17 Mar 21 |
nicklas |
var HitDetails = function() |
6170 |
17 Mar 21 |
nicklas |
2 |
{ |
6170 |
17 Mar 21 |
nicklas |
var details = {}; |
6170 |
17 Mar 21 |
nicklas |
4 |
|
6170 |
17 Mar 21 |
nicklas |
// Page initialization |
6170 |
17 Mar 21 |
nicklas |
details.initPage = function() |
6170 |
17 Mar 21 |
nicklas |
7 |
{ |
6170 |
17 Mar 21 |
nicklas |
Buttons.addClickHandler('close', App.closeWindow); |
6170 |
17 Mar 21 |
nicklas |
var url = 'Hit.servlet?ID='+App.getSessionId(); |
6170 |
17 Mar 21 |
nicklas |
url += '&cmd=GetDetails'; |
6170 |
17 Mar 21 |
nicklas |
url += '&rbaId='+Data.int('page-data', 'rba'); |
6170 |
17 Mar 21 |
nicklas |
url += '&fileId='+Data.int('page-data', 'file'); |
6170 |
17 Mar 21 |
nicklas |
url += '&lineNo='+Data.int('page-data', 'line'); |
6551 |
26 Jan 22 |
nicklas |
url += '&snpId='+encodeURIComponent(Data.get('page-data', 'snp')); |
6173 |
18 Mar 21 |
nicklas |
url += '&idx='+encodeURIComponent(Data.get('page-data', 'idx')); |
6253 |
25 May 21 |
nicklas |
Wizard.showLoadingAnimation('Loading variant data...'); |
6170 |
17 Mar 21 |
nicklas |
Wizard.asyncJsonRequest(url, details.detailsLoaded); |
6170 |
17 Mar 21 |
nicklas |
18 |
} |
6170 |
17 Mar 21 |
nicklas |
19 |
|
6170 |
17 Mar 21 |
nicklas |
details.detailsLoaded = function(response) |
6170 |
17 Mar 21 |
nicklas |
21 |
{ |
6170 |
17 Mar 21 |
nicklas |
Doc.show('variant'); |
6253 |
25 May 21 |
nicklas |
Doc.removeClass('content', 'bottomborder'); |
6170 |
17 Mar 21 |
nicklas |
var rba = response.rba; |
6170 |
17 Mar 21 |
nicklas |
var file = response.file; |
6551 |
26 Jan 22 |
nicklas |
var file2 = response.file2; |
6170 |
17 Mar 21 |
nicklas |
var hit = response.hit; |
6395 |
16 Sep 21 |
nicklas |
var hasData = hit.GT != './.'; |
6395 |
16 Sep 21 |
nicklas |
var isVariant = hasData && hit.GT != '0/0'; |
6379 |
14 Sep 21 |
nicklas |
var idx = Data.get('page-data', 'idx'); |
6551 |
26 Jan 22 |
nicklas |
var isOncoArray = idx == 'oncoarray-500K'; |
6551 |
26 Jan 22 |
nicklas |
var isTargeted = idx == 'targeted'; |
6170 |
17 Mar 21 |
nicklas |
33 |
|
6170 |
17 Mar 21 |
nicklas |
document.title += ' - ' + hit['#CHROM']+':'+hit.POS; |
6170 |
17 Mar 21 |
nicklas |
Doc.element('doc-title').innerHTML = Strings.encodeTags(rba.name + ' - ' + hit['#CHROM']+':'+hit.POS); |
6170 |
17 Mar 21 |
nicklas |
36 |
|
6170 |
17 Mar 21 |
nicklas |
var html = ''; |
6554 |
27 Jan 22 |
nicklas |
html += '<tr><th>'+Strings.encodeTags(rba.type)+'</th><td>'+Strings.encodeTags(rba.name)+'</td></tr>'; |
6551 |
26 Jan 22 |
nicklas |
html += '<tr><th>File</th><td>'; |
6551 |
26 Jan 22 |
nicklas |
if (file2) html += Strings.encodeTags(file2.name)+' and '; |
6551 |
26 Jan 22 |
nicklas |
html += Strings.encodeTags(file.name)+'</td></tr>'; |
6170 |
17 Mar 21 |
nicklas |
42 |
|
6395 |
16 Sep 21 |
nicklas |
// Genotype, depth, etc. and other sample-specific values |
6173 |
18 Mar 21 |
nicklas |
html += '<tr><th>Genotype</th><td style="border-top-width: 1px; border-top-style: dotted;">'+Strings.encodeTags(hit.GT); |
6551 |
26 Jan 22 |
nicklas |
if (isOncoArray) |
6551 |
26 Jan 22 |
nicklas |
46 |
{ |
6551 |
26 Jan 22 |
nicklas |
html += ' <b title="B Allele Frequency">BAF</b> '+Strings.encodeTags(hit.BAF); |
6551 |
26 Jan 22 |
nicklas |
html += ' <b title="GenCall Score">GQ</b> '+Strings.encodeTags(hit.GQ); |
6551 |
26 Jan 22 |
nicklas |
html += ' <b title="LogRRatio">LRR</b> '+Strings.encodeTags(hit.LRR); |
6551 |
26 Jan 22 |
nicklas |
50 |
} |
6551 |
26 Jan 22 |
nicklas |
else |
6551 |
26 Jan 22 |
nicklas |
52 |
{ |
6551 |
26 Jan 22 |
nicklas |
html += ' <b title="Depth">DP</b> '+Strings.encodeTags(hit.DP); |
6551 |
26 Jan 22 |
nicklas |
html += ' <b title="Variant depth">VD</b> '+Strings.encodeTags(hit.VD); |
6551 |
26 Jan 22 |
nicklas |
html += ' <b title="Allelic depths for the ref and alt alleles">AD</b> '+Strings.encodeTags(hit.AD); |
6551 |
26 Jan 22 |
nicklas |
html += ' <b title="Allele Frequency">AF</b> '+Strings.encodeTags(hit.AF); |
6551 |
26 Jan 22 |
nicklas |
57 |
} |
6170 |
17 Mar 21 |
nicklas |
html += '</td></tr>'; |
6170 |
17 Mar 21 |
nicklas |
59 |
|
6170 |
17 Mar 21 |
nicklas |
// Location and change at genomic and protein level and other effects |
6170 |
17 Mar 21 |
nicklas |
html += '<tr><th>Gene</th><td style="border-top-width: 1px; border-top-style: dotted;">'+Strings.encodeTags(hit.genes)+'</td></tr>'; |
6170 |
17 Mar 21 |
nicklas |
var chr = hit['#CHROM']; |
6170 |
17 Mar 21 |
nicklas |
var pos = hit.POS; |
6170 |
17 Mar 21 |
nicklas |
var lpos = parseInt(pos); |
6170 |
17 Mar 21 |
nicklas |
html += '<tr><th>Location</th><td>'; |
6170 |
17 Mar 21 |
nicklas |
html += '<a target="_blank" title="View in Genome Browser (new window)"'; |
6170 |
17 Mar 21 |
nicklas |
html += ' href="http://genome.ucsc.edu/cgi-bin/hgTracks?db=hg38'; |
6170 |
17 Mar 21 |
nicklas |
html += '&position='+encodeURIComponent(chr+':'+(lpos-30)+'-'+(lpos+30)); |
6170 |
17 Mar 21 |
nicklas |
html += '&highlight='+encodeURIComponent(chr+':'+pos+'-'+pos)+'">'; |
6170 |
17 Mar 21 |
nicklas |
html += Strings.encodeTags(chr+':'+pos)+'</a></td></tr>'; |
6170 |
17 Mar 21 |
nicklas |
html += '<tr><th>Type</th><td>'+Strings.encodeTags(hit.TYPE)+'</td></tr>'; |
6173 |
18 Mar 21 |
nicklas |
html += '<tr><th>Effect</th><td>'+Strings.encodeTags(hit.effect)+'</td></tr>'; |
6170 |
17 Mar 21 |
nicklas |
html += '<tr><th>Ref › Alt</th><td>'+details.refAlt(hit.REF, hit.ALT)+'</td></tr>'; |
6170 |
17 Mar 21 |
nicklas |
html += '<tr><th>HGVS.c</th><td>'+Strings.encodeTags(hit.hgvsc)+'</td></tr>'; |
6170 |
17 Mar 21 |
nicklas |
html += '<tr><th>HGVS.p</th><td>'+Strings.encodeTags(hit.hgvsp)+'</td></tr>'; |
6170 |
17 Mar 21 |
nicklas |
76 |
|
6170 |
17 Mar 21 |
nicklas |
// dbSNP |
6170 |
17 Mar 21 |
nicklas |
html += '<tr><th>dbSNP</th><td style="border-top-width: 1px; border-top-style: dotted;">'; |
6170 |
17 Mar 21 |
nicklas |
if (hit.dbsnp_ID) |
6170 |
17 Mar 21 |
nicklas |
80 |
{ |
6170 |
17 Mar 21 |
nicklas |
html += '<a target="_blank" title="View in dbSNP (new window)"'; |
6170 |
17 Mar 21 |
nicklas |
html += ' href="https://www.ncbi.nlm.nih.gov/snp/'+encodeURIComponent(hit.dbsnp_ID)+'">'; |
6170 |
17 Mar 21 |
nicklas |
html += Strings.encodeTags(hit.dbsnp_ID)+"</a>"; |
6170 |
17 Mar 21 |
nicklas |
84 |
} |
6170 |
17 Mar 21 |
nicklas |
html += '</td></tr>'; |
6170 |
17 Mar 21 |
nicklas |
86 |
|
6170 |
17 Mar 21 |
nicklas |
// COSMIC |
6170 |
17 Mar 21 |
nicklas |
html += '<tr><th>COSMIC</th><td>'; |
6170 |
17 Mar 21 |
nicklas |
if (hit.cosmic_ID) |
6170 |
17 Mar 21 |
nicklas |
90 |
{ |
6170 |
17 Mar 21 |
nicklas |
html += '<a target="_blank" title="View in COSMIC (new window)"'; |
6170 |
17 Mar 21 |
nicklas |
html += ' href="https://cancer.sanger.ac.uk/cosmic/search?q='+encodeURIComponent(hit.cosmic_ID)+'">'; |
6170 |
17 Mar 21 |
nicklas |
html += Strings.encodeTags(hit.cosmic_ID)+'</a>'; |
6170 |
17 Mar 21 |
nicklas |
94 |
} |
6170 |
17 Mar 21 |
nicklas |
if (hit.cosmic_WES_BRCA_MF) |
6170 |
17 Mar 21 |
nicklas |
96 |
{ |
6170 |
17 Mar 21 |
nicklas |
html += ' <b title="Mutant Frequency in WGS/WES breast cancer samples">MF</b> ' + Strings.encodeTags(hit.cosmic_WES_BRCA_MF); |
6170 |
17 Mar 21 |
nicklas |
98 |
} |
6170 |
17 Mar 21 |
nicklas |
html += '</td></tr>'; |
6170 |
17 Mar 21 |
nicklas |
100 |
|
6170 |
17 Mar 21 |
nicklas |
// SCAN-B |
6551 |
26 Jan 22 |
nicklas |
if (!isTargeted && !isOncoArray) |
6170 |
17 Mar 21 |
nicklas |
103 |
{ |
6379 |
14 Sep 21 |
nicklas |
html += '<tr><th title="Mutant Frequency (and count) among reference of 6653 SCAN-B non-replicate samples">SCAN-B MF</th><td>'+Strings.encodeTags(hit.scanb_MF_NR); |
6379 |
14 Sep 21 |
nicklas |
if (hit.scanb_CNT_NR) |
6379 |
14 Sep 21 |
nicklas |
106 |
{ |
6379 |
14 Sep 21 |
nicklas |
html += ' (' + Strings.encodeTags(hit.scanb_CNT_NR)+'/6653)'; |
6379 |
14 Sep 21 |
nicklas |
108 |
} |
6379 |
14 Sep 21 |
nicklas |
html += '</td></tr>'; |
6170 |
17 Mar 21 |
nicklas |
110 |
} |
6170 |
17 Mar 21 |
nicklas |
111 |
|
6173 |
18 Mar 21 |
nicklas |
html += '<tr class="dynamic"><th></th><td style="border-top-width: 1px; border-top-style: dotted;">'; |
6560 |
01 Feb 22 |
nicklas |
if (hit.numOther >= 0 && isVariant) |
6173 |
18 Mar 21 |
nicklas |
114 |
{ |
6554 |
27 Jan 22 |
nicklas |
var callType = isTargeted || isOncoArray ? 'genotype' : 'variant'; |
6173 |
18 Mar 21 |
nicklas |
html += '<div class="messagecontainer note" style="margin-top: 1em;">'; |
6379 |
14 Sep 21 |
nicklas |
if (hit.numOther == 0) |
6173 |
18 Mar 21 |
nicklas |
118 |
{ |
6560 |
01 Feb 22 |
nicklas |
html += 'This is the only '+callType+' call with this variant.'; |
6173 |
18 Mar 21 |
nicklas |
120 |
} |
6379 |
14 Sep 21 |
nicklas |
else if (hit.numOther == 1) |
6173 |
18 Mar 21 |
nicklas |
122 |
{ |
6554 |
27 Jan 22 |
nicklas |
html += 'There is 1 other '+callType+' call with this variant.'; |
6173 |
18 Mar 21 |
nicklas |
124 |
} |
6379 |
14 Sep 21 |
nicklas |
else if (hit.numOther > 1) |
6173 |
18 Mar 21 |
nicklas |
126 |
{ |
6554 |
27 Jan 22 |
nicklas |
html += 'There are '+hit.numOther+' other '+callType+' calls with this variant.'; |
6173 |
18 Mar 21 |
nicklas |
128 |
} |
6173 |
18 Mar 21 |
nicklas |
html += '</div>'; |
6173 |
18 Mar 21 |
nicklas |
130 |
} |
6173 |
18 Mar 21 |
nicklas |
html += '</td></tr>'; |
6170 |
17 Mar 21 |
nicklas |
132 |
|
6170 |
17 Mar 21 |
nicklas |
Doc.element('hit-summary').innerHTML = html; |
6170 |
17 Mar 21 |
nicklas |
Doc.show('hit-summary', 'table'); |
6170 |
17 Mar 21 |
nicklas |
135 |
|
6170 |
17 Mar 21 |
nicklas |
// RAW DATA (minimally formatted in separate tab) |
6170 |
17 Mar 21 |
nicklas |
var raw = response.raw; |
6551 |
26 Jan 22 |
nicklas |
var raw2 = response.raw2; |
6170 |
17 Mar 21 |
nicklas |
139 |
|
6170 |
17 Mar 21 |
nicklas |
// Main column |
6170 |
17 Mar 21 |
nicklas |
var fixed = ['CHROM', 'POS', 'ID', 'REF', 'ALT', 'QUAL', 'FILTER']; |
6170 |
17 Mar 21 |
nicklas |
var cols = raw.split('\t'); |
6170 |
17 Mar 21 |
nicklas |
var html = '<tbody>'; |
6170 |
17 Mar 21 |
nicklas |
for (var i = 0; i < Math.min(fixed.length, cols.length); i++) |
6170 |
17 Mar 21 |
nicklas |
145 |
{ |
6170 |
17 Mar 21 |
nicklas |
html += '<tr><th>'+fixed[i]+'</th><td>'+Strings.encodeTags(cols[i])+'</td></tr>'; |
6170 |
17 Mar 21 |
nicklas |
147 |
} |
6170 |
17 Mar 21 |
nicklas |
html += '</tbody>'; |
6170 |
17 Mar 21 |
nicklas |
149 |
|
6170 |
17 Mar 21 |
nicklas |
// FORMAT columns |
6551 |
26 Jan 22 |
nicklas |
if (cols.length >= 10) html += details.formatCols(cols[8], cols[9]); |
6551 |
26 Jan 22 |
nicklas |
if (raw2) |
6170 |
17 Mar 21 |
nicklas |
153 |
{ |
6551 |
26 Jan 22 |
nicklas |
var cols2 = raw2.split('\t'); |
6551 |
26 Jan 22 |
nicklas |
if (cols2.length >= 10) html += details.formatCols(cols2[8], cols2[9]); |
6170 |
17 Mar 21 |
nicklas |
156 |
} |
6170 |
17 Mar 21 |
nicklas |
157 |
|
6170 |
17 Mar 21 |
nicklas |
// INFO columns |
6170 |
17 Mar 21 |
nicklas |
if (cols.length >= 8) |
6170 |
17 Mar 21 |
nicklas |
160 |
{ |
6170 |
17 Mar 21 |
nicklas |
var info = cols[7].split('\;'); |
6170 |
17 Mar 21 |
nicklas |
html += '<tbody style="border-top-width: 1px; border-top-style: solid;">'; |
6170 |
17 Mar 21 |
nicklas |
for (var i = 0; i < info.length; i++) |
6170 |
17 Mar 21 |
nicklas |
164 |
{ |
6170 |
17 Mar 21 |
nicklas |
var keyval = info[i].split('='); |
6170 |
17 Mar 21 |
nicklas |
var key = Strings.encodeTags(keyval[0]); |
6170 |
17 Mar 21 |
nicklas |
var val = Strings.encodeTags(keyval[keyval.length-1]); |
6170 |
17 Mar 21 |
nicklas |
168 |
|
6170 |
17 Mar 21 |
nicklas |
// ANN is multi-value separated by ',' |
6170 |
17 Mar 21 |
nicklas |
if (key=='ANN' && val.indexOf(',')>0) |
6170 |
17 Mar 21 |
nicklas |
171 |
{ |
6170 |
17 Mar 21 |
nicklas |
var ann = val.split(','); |
6170 |
17 Mar 21 |
nicklas |
for (var a=0; a<ann.length; a++) |
6170 |
17 Mar 21 |
nicklas |
174 |
{ |
6170 |
17 Mar 21 |
nicklas |
html += '<tr><th>ANN['+a+']</th><td>'+ann[a]+'</td></tr>'; |
6170 |
17 Mar 21 |
nicklas |
176 |
} |
6170 |
17 Mar 21 |
nicklas |
177 |
} |
6170 |
17 Mar 21 |
nicklas |
else |
6170 |
17 Mar 21 |
nicklas |
179 |
{ |
6170 |
17 Mar 21 |
nicklas |
val = val.replace(/,/g, ', '); |
6170 |
17 Mar 21 |
nicklas |
html += '<tr><th title="'+key+'">'+key+'</th><td>'+val+'</td></tr>'; |
6170 |
17 Mar 21 |
nicklas |
182 |
} |
6170 |
17 Mar 21 |
nicklas |
183 |
} |
6170 |
17 Mar 21 |
nicklas |
html += '</tbody>'; |
6170 |
17 Mar 21 |
nicklas |
185 |
} |
6170 |
17 Mar 21 |
nicklas |
186 |
|
6170 |
17 Mar 21 |
nicklas |
Doc.element('hit-all').innerHTML = html; |
6551 |
26 Jan 22 |
nicklas |
188 |
} |
6170 |
17 Mar 21 |
nicklas |
189 |
|
6551 |
26 Jan 22 |
nicklas |
details.formatCols = function(format, gt) |
6551 |
26 Jan 22 |
nicklas |
191 |
{ |
6551 |
26 Jan 22 |
nicklas |
var format = format.split('\:'); |
6551 |
26 Jan 22 |
nicklas |
var gt = gt.split('\:'); |
6551 |
26 Jan 22 |
nicklas |
html = '<tbody style="border-top-width: 1px; border-top-style: solid;">'; |
6551 |
26 Jan 22 |
nicklas |
for (var i = 0; i < Math.min(format.length, gt.length); i++) |
6551 |
26 Jan 22 |
nicklas |
196 |
{ |
6551 |
26 Jan 22 |
nicklas |
html += '<tr><th>'+Strings.encodeTags(format[i])+'</th><td>'+Strings.encodeTags(gt[i])+'</td></tr>'; |
6551 |
26 Jan 22 |
nicklas |
198 |
} |
6551 |
26 Jan 22 |
nicklas |
html += '</tbody>'; |
6551 |
26 Jan 22 |
nicklas |
return html; |
6170 |
17 Mar 21 |
nicklas |
201 |
} |
6170 |
17 Mar 21 |
nicklas |
202 |
|
6170 |
17 Mar 21 |
nicklas |
details.refAlt = function(ref, alt, maxLength) |
6170 |
17 Mar 21 |
nicklas |
204 |
{ |
6170 |
17 Mar 21 |
nicklas |
if (!maxLength) maxLength = 15; |
6170 |
17 Mar 21 |
nicklas |
if (ref.length > maxLength) |
6170 |
17 Mar 21 |
nicklas |
207 |
{ |
6170 |
17 Mar 21 |
nicklas |
ref = "<span title=\""+ref+"\">"+ref.substring(0, maxLength)+"...</span>"; |
6170 |
17 Mar 21 |
nicklas |
209 |
} |
6170 |
17 Mar 21 |
nicklas |
if (alt.length > maxLength) |
6170 |
17 Mar 21 |
nicklas |
211 |
{ |
6170 |
17 Mar 21 |
nicklas |
alt = "<span title=\""+alt+"\">"+alt.substring(0, maxLength)+"...</span>"; |
6170 |
17 Mar 21 |
nicklas |
213 |
} |
6170 |
17 Mar 21 |
nicklas |
return ref + " › " + alt; //   is a narrow non-breaking space |
6170 |
17 Mar 21 |
nicklas |
215 |
} |
6170 |
17 Mar 21 |
nicklas |
216 |
|
6170 |
17 Mar 21 |
nicklas |
217 |
|
6170 |
17 Mar 21 |
nicklas |
return details; |
6170 |
17 Mar 21 |
nicklas |
219 |
}(); |
6170 |
17 Mar 21 |
nicklas |
220 |
|
6170 |
17 Mar 21 |
nicklas |
Doc.onLoad(HitDetails.initPage); |
6170 |
17 Mar 21 |
nicklas |
222 |
|