Skip to content

Commit 47b50fb

Browse files
authored
Allow no symbol or gene field (#113)
1 parent 236b9ec commit 47b50fb

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

src/bcf/report/js/report.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ vegaEmbed('#oncoprint', spec).then(function(result) {
5252
result.view.addEventListener('click', function(event, item) {
5353
if (item.datum.gene !== undefined || item.datum.key !== undefined) {
5454
if (item.datum.gene !== undefined ) {
55-
window.location.href = '../genes/' + item.datum.gene + '1.html';
55+
if (item.datum.gene.startsWith("ENST") && item.datum.sample !== undefined) {
56+
window.location.href = '../details/' + item.datum.sample + '/' + item.datum.gene + '.html';
57+
} else {
58+
window.location.href = '../genes/' + item.datum.gene + '1.html';
59+
}
5660
} else {
5761
window.location.href = '../genes/' + item.datum.key + '1.html';
5862
}
@@ -61,7 +65,7 @@ vegaEmbed('#oncoprint', spec).then(function(result) {
6165
});
6266
});
6367

64-
window.addEventListener('resize', function(event){
68+
window.addEventListener('resize', function(event) {
6569
let page_width = $(window).width();
6670
let matrix_width = Math.min(page_width - 740, samples*20);
6771
if (matrix_width < 20 && samples >= 2) {
@@ -84,7 +88,11 @@ window.addEventListener('resize', function(event){
8488
result.view.addEventListener('click', function(event, item) {
8589
if (item.datum.gene !== undefined || item.datum.key !== undefined) {
8690
if (item.datum.gene !== undefined ) {
87-
window.location.href = '../genes/' + item.datum.gene + '1.html';
91+
if (item.datum.gene.startsWith("ENST") && item.datum.sample !== undefined) {
92+
window.location.href = '../details/' + item.datum.sample + '/' + item.datum.gene + '.html';
93+
} else {
94+
window.location.href = '../genes/' + item.datum.gene + '1.html';
95+
}
8896
} else {
8997
window.location.href = '../genes/' + item.datum.key + '1.html';
9098
}

src/bcf/report/oncoprint.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,11 @@ pub fn oncoprint(
159159
get_field("SYMBOL")?
160160
} else if !get_field("Gene")?.is_empty() {
161161
get_field("Gene")?
162+
} else if !get_field("HGVSg")?.is_empty() {
163+
warn!("Warning! Found allele in {:?} without SYMBOL or Gene field. Using HGVSg instead.", record);
164+
get_field("HGVSg")?
162165
} else {
163-
warn!("Warning! Found allele in {:?} without SYMBOL or Gene field. This record will be skipped!", record);
166+
warn!("Warning! Found allele in {:?} without SYMBOL, Gene or HGVSg field. This record will be skipped!", record);
164167
continue;
165168
};
166169
let dna_alteration = get_field("HGVSg")?;

src/bcf/report/table_report/create_report_table.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ pub(crate) fn make_table_report(
7979
*ann_indices
8080
.get(&String::from("Gene"))
8181
.expect("No field named Gene found. Please only use VEP-annotated VCF-files."),
82+
*ann_indices
83+
.get(&String::from("HGVSg"))
84+
.expect("No field named HGVSg found. Please only use VEP-annotated VCF-files."),
8285
)?;
8386

8487
for (record_index, v) in vcf.records().enumerate() {
@@ -209,8 +212,11 @@ pub(crate) fn make_table_report(
209212
get_field("SYMBOL")?
210213
} else if !get_field("Gene")?.is_empty() {
211214
get_field("Gene")?
215+
} else if !get_field("HGVSg")?.is_empty() {
216+
warn!("Warning! Found allele in {:?} without SYMBOL or Gene field. Using HGVSg instead.", variant);
217+
get_field("HGVSg")?
212218
} else {
213-
warn!("Warning! Found allele in {:?} without SYMBOL or Gene field. This record will be skipped!", variant);
219+
warn!("Warning! Found allele in {:?} without SYMBOL, Gene or HGVSg field. This record will be skipped!", variant);
214220
continue;
215221
};
216222
genes.push(gene.to_owned());
@@ -563,6 +569,7 @@ fn get_gene_ending(
563569
vcf_path: &Path,
564570
symbol_index: usize,
565571
gene_index: usize,
572+
hgvsg_index: usize,
566573
) -> Result<HashMap<String, u32>, Box<dyn Error>> {
567574
let mut endings = HashMap::new();
568575
let mut vcf = rust_htslib::bcf::Reader::from_path(&vcf_path).unwrap();
@@ -575,6 +582,9 @@ fn get_gene_ending(
575582
if gene.is_empty() {
576583
gene = std::str::from_utf8(fields[gene_index])?;
577584
}
585+
if gene.is_empty() {
586+
gene = std::str::from_utf8(fields[hgvsg_index])?;
587+
}
578588
endings.insert(gene.to_owned(), record_index as u32);
579589
}
580590
}

0 commit comments

Comments
 (0)