Commit f3465bdc authored by Mathieu Giraud's avatar Mathieu Giraud

Merge branch 'feature-c/4308-Vstart-Jend-client' into 'dev'

Resolve "Début de V et fin de J : affichage client"

Closes #4308

See merge request !709
parents 2f9c3cdf 5651c8e9
Pipeline #151748 passed with stages
in 12 minutes and 22 seconds
......@@ -932,13 +932,23 @@ Clone.prototype = {
}
var s = ''
s += this.sequence.substring(0, this.seg['5'].stop+1)
s += '\n'
if (this.seg['5'].start != undefined && this.seg['5'].start != 0){
s += this.sequence.substring(0, this.seg['5'].start) + '\n'
s += this.sequence.substring(this.seg['5'].start, this.seg['5'].stop+1) + '\n'
} else {
s += this.sequence.substring(0, this.seg['5'].stop+1) + '\n'
}
if (this.seg['5'].stop+1 < this.seg['3'].start ) {
s += this.sequence.substring(this.seg['5'].stop+1, this.seg['3'].start)
s += '\n'
}
s += this.sequence.substring(this.seg['3'].start)
if (this.seg['3'].stop != undefined && this.seg['3'].stop != this.sequence.length){
s += this.sequence.substring(this.seg['3'].start, this.seg['3'].stop+1) +'\n'
s += this.sequence.substring(this.seg['3'].stop+1)
} else {
s += this.sequence.substring(this.seg['3'].start)
}
return s
},
......
......@@ -1570,20 +1570,25 @@ Sequence.prototype = Object.create(genSeq.prototype);
// We first put the end positions
highlights.push({'type':'N', 'color': "", 'start': vdjArray["5"].stop});
highlights.push({'type':'N', 'color': "", 'start': vdjArray["3"].start});
highlights.push({'type':'before5', 'color': "black", 'start': 0}); // from seq start to 5 start
highlights.push({'type':'after3', 'color': "black", 'start': vdjArray["3"].stop}); // from 3 stop to seq end
// TOOD: remove the two previous lines, see #2135
var key;
for (var i in SEGMENT_KEYS) {
key = SEGMENT_KEYS[i]
if (typeof vdjArray[key] != 'undefined' && typeof vdjArray[key].stop != 'undefined'){
highlights.push({'type':'N', 'color': "", 'start': vdjArray[key].stop});
}}
}
}
// We now put the start positions (that may override previous end positions)
for (var j in SEGMENT_KEYS) {
key = SEGMENT_KEYS[j]
if (typeof vdjArray[key] != 'undefined' && typeof vdjArray[key].start!= 'undefined'){
highlights.push({'type':'D', 'color': "", 'start': vdjArray[key].start});
}}
}
}
highlights.push({'type':'V', 'color': this.m.colorMethod == "V" ? clone.colorV : "", 'start': vdjArray["5"].start});
highlights.push({'type':'J', 'color': this.m.colorMethod == "J" ? clone.colorJ : "", 'start': vdjArray["3"].start});
......@@ -1615,10 +1620,10 @@ Sequence.prototype = Object.create(genSeq.prototype);
Sequence.prototype.getVdjStartEnd = function (clone) {
var vdjArray ={"5": {}, "3": {}} ;
vdjArray["5"].start = 0;
vdjArray["5"].stop = this.pos[clone.seg["5"].stop] + 1;
vdjArray["5"].start = (clone.seg["5"].start != undefined) ? this.pos[clone.seg["5"].start] : 0;
vdjArray["5"].stop = this.pos[clone.seg["5"].stop] + 1;
vdjArray["3"].start = this.pos[clone.seg["3"].start];
vdjArray["3"].stop = this.seq.length;
vdjArray["3"].stop = (clone.seg["3"].stop != undefined) ? this.pos[clone.seg["3"].stop] : this.seq.length;
for (var i in SEGMENT_KEYS)
{
......
......@@ -122,6 +122,42 @@ var json_clone6 = {
"normalized_reads" : [20,20,0,null],
}
// Cmone with seg start and stop position
var json_clone7 = {
"germline": "IGH",
"id": "id7",
"name": "clone with exact position",
"reads": [0,0,0,0],
"seg": {
"3": {
"delLeft": 1,
"delRight": 40,
"name": "IGHJ6*02",
"start": 16,
"stop": 25
},
"4": {
"delLeft": 4,
"delRight": 9,
"name": "IGHD3-3*01",
"start": 13,
"stop": 15
},
"5": {
"delLeft": 0,
"delRight": 2,
"name": "IGHV1-69*06",
"start": 6,
"stop": 10
},
"N1": 15,
"N2": 0,
},
"sequence": "bbbbbVVVVVnnDDDJJJJJJJJJJaaaaaa",
"top": 7
}
QUnit.test("name, informations, getHtmlInfo", function(assert) {
assert.equal(json_clone1.seg.junction.start, 10, "Start junction is 10 in JSON for clone 1");
......@@ -527,14 +563,21 @@ QUnit.test("export", function(assert) {
]
assert.deepEqual(c4.toCSV(), res4, "c4.toCSV() - no junctionAA")
m.select(0)
m.select(1)
m.merge()
assert.equal(c3.toCSV()[0], "0+1", ".toCSV(), merged clone")
});
// Fasta output for clone with preV and postJ
var c7 = new Clone(json_clone7, m, 1, c_attributes)
assert.equal(c7.getFasta(), ">clone with exact position 31 nt, 0 read \nbbbbb\nVVVVV\nnnDDD\nJJJJJJJJJJ\naaaaaa\n", "getFasta() with preV and postJ: Ok");
// Test if preV and postJ are empty (no empty line waited)
c7.seg["5"].start = 0
c7.seg["3"].stop = c7.sequence.length
assert.equal(c7.getFasta(), ">clone with exact position 31 nt, 0 read \nbbbbbVVVVV\nnnDDD\nJJJJJJJJJJaaaaaa\n", "getFasta() with preV and postJ: Ok");
})
QUnit.test("changeLocus/Segment", function(assert) {
......
......@@ -476,8 +476,9 @@ QUnit.test("getFasta", function(assert) {
m.select(1)
var fasta = m.getFasta()
console.log( fasta )
clone = m.clone(0)
fasta_to_get = ">hello 19 nt, 10 reads (5.000%, 10.00% of TRG)\naaaaaa\naaaattttt\ntttt\n\n>IGHV3-23*01 6/ACGTG/4 IGHD1-1*01 5/CCCACGTGGGGG/4 IGHJ5*02 11 nt, 10 reads (5.000%, 10.00% of IGH)\nAACGTACCAGG\n\n"
fasta_to_get = ">hello 19 nt, 10 reads (5.000%, 10.00% of TRG)\na\naaaaa\naaaattttt\ntttt\n\n>IGHV3-23*01 6/ACGTG/4 IGHD1-1*01 5/CCCACGTGGGGG/4 IGHJ5*02 11 nt, 10 reads (5.000%, 10.00% of IGH)\nAACGTACCAGG\n\n"
assert.equal(fasta, fasta_to_get, "getFasta return the correct content")
});
......
......@@ -363,3 +363,43 @@ QUnit.test("reset", function (assert) {
}, delay+=step)
})
QUnit.test("highlight", function (assert) {
var m = new Model();
m.parseJsonData(json_data, 100);
m.initClones();
var segment = new Segment("segment",m)
segment.init();
var clone = m.clone(3);
clone.seg["5"].start = 15 // 15 nt before V
clone.seg["3"].stop = 221 // 20 nt after J
m.select(3)
segment.addToSegmenter(3);
// "<span class='seq-marge'></span> // Marge
// <span></span>
// <span style=\"color: black;\" class=\"before5\">GGAAGGCCCCACAGC</span> // before V
// <span class=\"V\">GTCTTCTGTACTAT...TCTGGGGTCTATTACTGTGCCACCTGGGACAGG</span> // seg V
// <span class=\"N\">CTGA</span> // insert N1
// <span class=\"N\"></span> // insert N2
// <span class=\"J\">AGGATTGGATCAAGACGTTTGCAAAAGGGACTAGGCTC</span> // seg J
// <span style=\"color: black;\" class=\"after3\">ATAGTAACTTCGCCTGGTAA</span>" // after J
//
var str = segment.sequence[3].toString()
var spans = str.split("</span>")
assert.equal(spans.length, 9, "correct number of spans");
assert.includes(spans[0], "seq-marge", "")
assert.includes(spans[2], "GGAAGGCCCCACAGC", "segment highlight: seq before V")
assert.includes(spans[2], "class=\"before5\"", "segment highlight: color of seq before V")
assert.includes(spans[3], "GTCTTCTGTACTAT", "segment highlight: part seq V")
assert.includes(spans[3], "class=\"V\"", "segment highlight: class V")
assert.includes(spans[4], ">CTGA", "segment highlight: seq N1 (VJ)")
assert.includes(spans[4], "class=\"N\"", "segment highlight: class N")
assert.includes(spans[6], "AGGATTGGATCAAGACGTTTGCAAAAGGGACTAGGCTC", "segment highlight: seq J")
assert.includes(spans[6], "class=\"J\"", "segment highlight: class J")
assert.includes(spans[7], "ATAGTAACTTCGCCTGGTAA", "segment highlight: seq after J")
assert.includes(spans[7], "class=\"after3\"", "segment highlight: color of seq after J")
})
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