From cd997ff5db2dbef0e458f976dc85a15161de538b Mon Sep 17 00:00:00 2001 From: Marek Schwarz Date: Mon, 15 Oct 2018 16:22:07 +0200 Subject: [PATCH] update html minor location fixes version up --- rna_blast_analyze/BA.py | 2 +- rna_blast_analyze/BR_core/BA_methods.py | 4 +- rna_blast_analyze/BR_core/expand_by_BLAST.py | 15 ++++--- .../BR_core/expand_by_LOCARNA.py | 16 +++++-- .../expand_by_joined_pred_with_rsearch.py | 4 ++ rna_blast_analyze/BR_core/output/onehit.html | 42 ++++++++++--------- rna_blast_analyze/BR_core/output/script.js | 32 ++++++++++---- setup.py | 2 +- .../RF00001_reference_output.html.md5 | 2 +- 9 files changed, 74 insertions(+), 45 deletions(-) diff --git a/rna_blast_analyze/BA.py b/rna_blast_analyze/BA.py index d4389fc..b32ffbd 100644 --- a/rna_blast_analyze/BA.py +++ b/rna_blast_analyze/BA.py @@ -154,7 +154,7 @@ def f_parser(): misc_group.add_argument( '--version', action='version', - version='%(prog)s 0.0.4' + version='%(prog)s 0.0.5' ) parameters_group.add_argument( '--config_file', diff --git a/rna_blast_analyze/BR_core/BA_methods.py b/rna_blast_analyze/BR_core/BA_methods.py index 6775471..f5832aa 100644 --- a/rna_blast_analyze/BR_core/BA_methods.py +++ b/rna_blast_analyze/BR_core/BA_methods.py @@ -306,6 +306,6 @@ def to_tab_delim_header(input_args): def add_loc_to_description(analyzed_hits): for hit in analyzed_hits.hits: - d2a = ' {}-{}'.format(hit.best_start, hit.best_end) - hit.source.description += d2a + d2a = '{}-{}'.format(hit.best_start, hit.best_end) + # hit.source.description += d2a hit.subs[hit.ret_keys[0]].description += d2a diff --git a/rna_blast_analyze/BR_core/expand_by_BLAST.py b/rna_blast_analyze/BR_core/expand_by_BLAST.py index c5a2e97..270b94c 100644 --- a/rna_blast_analyze/BR_core/expand_by_BLAST.py +++ b/rna_blast_analyze/BR_core/expand_by_BLAST.py @@ -116,19 +116,18 @@ def trim_before(seqs): def compute_true_location_se(hit): hh = hit.subs[hit.ret_keys[0]] ann = hh.annotations - if ann['strand'] == -1: + if ann['strand'] == 1: if ann['trimmed_es']: - s = 0 + s = 1 else: - s = ann['blast'][1].sbjct_end - ann['blast'][1].query_start - e = s + len(hh.seq) + s = ann['blast'][1].sbjct_start - ann['blast'][1].query_start + 1 + e = s + len(hh.seq) - 1 else: if ann['trimmed_es']: - s = 0 + s = 1 else: - s = ann['blast'][1].sbjct_start - ann['blast'][1].query_start - e = s + len(hh.seq) - + s = ann['blast'][1].sbjct_end - ann['blast'][1].query_start + 1 + e = s + len(hh.seq) - 1 return s, e diff --git a/rna_blast_analyze/BR_core/expand_by_LOCARNA.py b/rna_blast_analyze/BR_core/expand_by_LOCARNA.py index f43f92a..abe1b9f 100644 --- a/rna_blast_analyze/BR_core/expand_by_LOCARNA.py +++ b/rna_blast_analyze/BR_core/expand_by_LOCARNA.py @@ -400,12 +400,20 @@ def _select_refold_structure(refold_structures_, exp_hit_id): def compute_true_location_locarna(hit, match): start, end = match.span() - if hit.source.annotations['trimmed_ss']: - s = start + if hit.source.annotations['blast'][1].strand == 1: + if hit.source.annotations['trimmed_ss']: + s = start + 1 + else: + s = hit.source.annotations['super_start'] + start + + e = end - start + s + 1 else: - s = hit.source.annotations['super_start'] + start + if hit.source.annotations['trimmed_ss']: + s = start + 1 + else: + s = hit.source.annotations['super_start'] + start - e = end - start + s + e = end - start + s - 1 return s, e diff --git a/rna_blast_analyze/BR_core/expand_by_joined_pred_with_rsearch.py b/rna_blast_analyze/BR_core/expand_by_joined_pred_with_rsearch.py index 0659406..ed09112 100644 --- a/rna_blast_analyze/BR_core/expand_by_joined_pred_with_rsearch.py +++ b/rna_blast_analyze/BR_core/expand_by_joined_pred_with_rsearch.py @@ -139,6 +139,10 @@ def joined_wrapper_inner(args_inner, shared_list=None): fah.write('>{}\n{}\n'.format(hit.subs[hit.ret_keys[0]].id, str(hit.subs[hit.ret_keys[0]].seq))) + # remove description from hits and sources + for hit in analyzed_hits.hits: + hit.subs[hit.ret_keys[0]].description = '' + out_line = [] # multiple prediction params if args_inner.dev_pred: diff --git a/rna_blast_analyze/BR_core/output/onehit.html b/rna_blast_analyze/BR_core/output/onehit.html index b731f83..26bb8d4 100644 --- a/rna_blast_analyze/BR_core/output/onehit.html +++ b/rna_blast_analyze/BR_core/output/onehit.html @@ -4,7 +4,10 @@ {% endblock %} {% block content %} {% macro create_onehit(data) %} -

Hit: {{data.source_seq_name}} @@ -21,11 +24,11 @@

- + - + @@ -39,26 +42,25 @@

- - + +
- +
- -
- {% for pic in data.pictures %} -
- - - -
- {{pic.picname}} - -
-
- {% endfor %} -
+
+ {% for pic in data.pictures %} +
+ + + +
+ {{pic.picname}} + +
+
+ {% endfor %} +
{% if data.draw_seqview %} diff --git a/rna_blast_analyze/BR_core/output/script.js b/rna_blast_analyze/BR_core/output/script.js index 01b1028..d811750 100644 --- a/rna_blast_analyze/BR_core/output/script.js +++ b/rna_blast_analyze/BR_core/output/script.js @@ -51,6 +51,19 @@ function buildFasta(seqname, sequence) { return ">" + seqname + "\n" + sequence + "\n"; } +function mySaveFile(uri, filename) { + var link = document.createElement('a'); + if (typeof(link.download) === 'string') { + document.body.appendChild(link); + link.download = filename; + link.href = uri; + link.click(); + document.body.removeChild(link); + } else { + window.open(uri, "_self"); + } +} + function writeSelectionStructures() { console.log("write selection fasta"); var sel = exportSelected("individualStructureCheckbox"); @@ -58,12 +71,13 @@ function writeSelectionStructures() { var exportdata = ""; for (i = 0; i < sel.length; i++) { - var pnodedata = sel[i].parentNode.parentNode.parentNode.parentNode.dataset; - var structure = sel[i].parentNode.parentNode.dataset.brna_secondary_structure; - - exportdata += buildFastaStructure(pnodedata.brna_seqname, pnodedata.brna_sequence, structure); + var intid = parseInt(sel[i].id) + var oh = document.getElementById(intid + "onehit"); + var method = sel[i].parentNode.textContent.trim() + var seqname = oh.dataset.brna_seqname + "-" + method + " " + document.getElementById(intid + "SeqStart").textContent + "-" + document.getElementById(intid + "SeqEnd").textContent + exportdata += buildFastaStructure(seqname, oh.dataset.brna_sequence, document.getElementById(intid + method).dataset.brna_secondary_structure); } - window.open("data:application/txt," + encodeURIComponent(exportdata), "_self"); + mySaveFile("data:application/txt," + encodeURIComponent(exportdata), "structures.txt"); } function placeSelection(boxlist, val2place) { @@ -106,10 +120,12 @@ function writeSelectionFasta() { var exportdata = ""; for (i = 0; i < sel.length; i++) { - var pnodedata = sel[i].parentNode.parentNode.parentNode.dataset; - exportdata += buildFasta(pnodedata.brna_seqname, pnodedata.brna_sequence); + var intid = parseInt(sel[i].id) + var pnodedata = document.getElementById(intid + "FormSeq"); + + exportdata += pnodedata.textContent; } - window.open("data:application/txt," + encodeURIComponent(exportdata), "_self"); + mySaveFile("data:application/txt," + encodeURIComponent(exportdata), "sequences.fasta"); } function GetHits() { diff --git a/setup.py b/setup.py index 3785e08..6762d1a 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,7 @@ setup( name='rna_blast_analyze', - version='0.0.4', + version='0.0.5', description='Analyze BLAST output for RNA query', author='Marek Schwarz', author_email='marek.schwarz@biomed.cas.cz', diff --git a/test_func/test_data/RF00001_reference_output.html.md5 b/test_func/test_data/RF00001_reference_output.html.md5 index b2e2f42..aa4214e 100644 --- a/test_func/test_data/RF00001_reference_output.html.md5 +++ b/test_func/test_data/RF00001_reference_output.html.md5 @@ -1 +1 @@ -8d941ad1ea3912af31e4b3ce16c5d893 \ No newline at end of file +87f65c91302e718fedddacadaea3b5f8 \ No newline at end of file

sequence start:{{data.ext_start}}{{data.ext_start}}
sequence end:{{data.ext_end}}{{data.ext_end}}
RSEARCH bits score: