Commit 5c7c754f authored by Floreal Cabanettes's avatar Floreal Cabanettes
Browse files

Add export no match targets to query

parent d843bcb0
......@@ -126,16 +126,17 @@ dgenies.result.export.export_association_table = function () {
document.getElementById('my-download').click();
};
dgenies.result.export.export_no_association_file = function () {
dgenies.result.export.export_no_association_file = function (to) {
let on = to === "query" ? "target" : "query";
dgenies.post("/no-assoc/" + dgenies.result.id_res,
{},
{"to": to},
function (data, success) {
if (!data["empty"]) {
let blob = new Blob([data["file_content"]], {type: "text/plain"});
saveAs(blob, `nomatches_${d3.boxplot.name_y}_to_${d3.boxplot.name_x}.txt`);
saveAs(blob, `no_${to}_matches_${d3.boxplot.name_y}_to_${d3.boxplot.name_x}.txt`);
}
else {
dgenies.notify("No contigs in query have None match with any target!", "success")
dgenies.notify(`No contigs in ${to} have None match with any ${on}!`, "success")
}
})
};
......@@ -160,7 +161,10 @@ dgenies.result.export.export = function () {
dgenies.result.export.export_association_table();
}
else if (selection === 6) {
dgenies.result.export.export_no_association_file();
dgenies.result.export.export_no_association_file("query");
}
else if (selection === 7) {
dgenies.result.export.export_no_association_file("target");
}
else
dgenies.notify("Not supported yet!", "danger", 2000);
......
......@@ -488,15 +488,17 @@ class Paf:
content += "%s\t%s\t%s\n" % (contig, "None", strand)
return content
def build_list_no_assoc(self):
def build_list_no_assoc(self, to):
"""
Build list of queries that match with None target
Build list of queries that match with None target, or the opposite
:param to: query or target
:return: content of the file
"""
name, contigs_list, contigs, reversed, abs_start, abs_current_start, c_len = self.load_index(self.idx_q)
index = self.idx_q if to == "query" else self.idx_t
name, contigs_list, contigs, reversed, abs_start, abs_current_start, c_len = self.load_index(self.idx_t)
with open(self.paf, "r") as paf:
for line in paf:
query_name = line.strip("\n").split("\t")[0]
if query_name in contigs_list:
contigs_list.remove(query_name)
c_name = line.strip("\n").split("\t")[0 if to == "query" else 5]
if c_name in contigs_list:
contigs_list.remove(c_name)
return "\n".join(contigs_list) + "\n"
......@@ -405,7 +405,7 @@ def no_assoc(id_res):
print("Unable to load data!")
abort(404)
return False
file_content = paf.build_list_no_assoc()
file_content = paf.build_list_no_assoc(request.form["to"])
empty = file_content == "\n"
return jsonify({
"file_content": file_content,
......
......@@ -43,6 +43,7 @@
<option value="4">Query Fasta</option>
<option value="5">Association table</option>
<option value="6">No match queries</option>
<option value="7">No match targets</option>
</select>
</form>
</div>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment