Skip to content

Commit

Permalink
update html
Browse files Browse the repository at this point in the history
minor location fixes
version up
  • Loading branch information
SchwarzMarek committed Oct 15, 2018
1 parent d458780 commit cd997ff
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 45 deletions.
2 changes: 1 addition & 1 deletion rna_blast_analyze/BA.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions rna_blast_analyze/BR_core/BA_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 7 additions & 8 deletions rna_blast_analyze/BR_core/expand_by_BLAST.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
16 changes: 12 additions & 4 deletions rna_blast_analyze/BR_core/expand_by_LOCARNA.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
42 changes: 22 additions & 20 deletions rna_blast_analyze/BR_core/output/onehit.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
{% endblock %}
{% block content %}
{% macro create_onehit(data) %}
<div class="onehit" data-brna_sequence="{{data.sequence}}" data-brna_seqname="{{data.seqname}}"
<div class="onehit"
id="{{data.intid}}onehit"
data-brna_sequence="{{data.sequence}}"
data-brna_seqname="{{data.seqname}}"
data-eval="{{data.eval}}">
<h3 class="onehit_heading" style="background:{{data.h_color}};">
Hit: {{data.source_seq_name}}
Expand All @@ -21,11 +24,11 @@ <h3 class="onehit_heading" style="background:{{data.h_color}};">
<table>
<tr>
<th class="left" scope="row">sequence start:</th>
<td class="right">{{data.ext_start}}</td>
<td class="right" id="{{data.intid}}SeqStart">{{data.ext_start}}</td>
</tr>
<tr>
<th class="left" scope="row">sequence end:</th>
<td class="right">{{data.ext_end}}</td>
<td class="right" id="{{data.intid}}SeqEnd">{{data.ext_end}}</td>
</tr>
<tr>
<th class="left" scope="row">RSEARCH bits score:</th>
Expand All @@ -39,26 +42,25 @@ <h3 class="onehit_heading" style="background:{{data.h_color}};">
</div>
<div class="repitem">
<div>
<label for="indivSequenceCheckbox"><u>Extended sequence fasta:</u></label>
<input type="checkbox" class="individualSequenceCheckbox" id="indivSequenceCheckbox">
<label for="{{data.intid}}SeqCheck"><u>Extended sequence fasta:</u></label>
<input type="checkbox" class="individualSequenceCheckbox" id="{{data.intid}}SeqCheck">
</div>
<textarea readonly="true" rows="5" cols="65">{{data.formated_seq}}</textarea>
<textarea id="{{data.intid}}FormSeq" readonly="true" rows="5" cols="65">{{data.formated_seq}}</textarea>
</div>
<!--</div>-->
</div>
<div class="row">
{% for pic in data.pictures %}
<figure class="column" data-brna_secondary_structure="{{pic.secondary_structure}}">
<a href onclick="mypicload(this)">
<img class="rnapic" src="{{pic.pic}}" />
</a>
<figcaption>
{{pic.picname}}
<input type="checkbox" class="individualStructureCheckbox">
</figcaption>
</figure>
{% endfor %}
</div>
<div class="row">
{% for pic in data.pictures %}
<figure class="column" data-brna_secondary_structure="{{pic.secondary_structure}}" id="{{data.intid}}{{pic.picname}}">
<a href onclick="mypicload(this)">
<img class="rnapic" src="{{pic.pic}}" />
</a>
<figcaption>
{{pic.picname}}
<input type="checkbox" class="individualStructureCheckbox" id="{{data.intid}}{{data.picname}}StrCheck">
</figcaption>
</figure>
{% endfor %}
</div>

{% if data.draw_seqview %}

Expand Down
32 changes: 24 additions & 8 deletions rna_blast_analyze/BR_core/output/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,33 @@ 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");
var i;
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) {
Expand Down Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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='[email protected]',
Expand Down
2 changes: 1 addition & 1 deletion test_func/test_data/RF00001_reference_output.html.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8d941ad1ea3912af31e4b3ce16c5d893
87f65c91302e718fedddacadaea3b5f8

0 comments on commit cd997ff

Please sign in to comment.