Commit 19df7b47 authored by Mathieu Giraud's avatar Mathieu Giraud

Merge branch...

Merge branch 'feature-ts/3978-calculer-les-distributions-sur-tous-les-clones-pas-sur-le-top' into 'dev'

Resolve "Calculer les distributions sur tous les clones, pas sur le top"

Closes #3978

See merge request !516
parents 6afd32b4 ab95592c
Pipeline #95949 passed with stages
in 49 minutes and 12 seconds
......@@ -5,7 +5,7 @@
}],
"clones": [ {
"_average_read_length": [
76.0
76.123
],
"_coverage": [
0.973684191703796
......@@ -75,7 +75,7 @@
},
{
"_average_read_length": [
76.0
76.956
],
"_coverage": [
1.0
......@@ -145,7 +145,7 @@
},
{
"_average_read_length": [
76.0
76.5
],
"_coverage": [
1.0
......
......@@ -36,6 +36,7 @@ import os
import datetime
import subprocess
import tempfile
import math
from operator import itemgetter, le
from utils import *
from defs import *
......@@ -145,6 +146,12 @@ class Window:
True
>>> w7.get_values("unavailable_axis")
'unknow_axis'
>>> w7.get_values("lenSeqAverage")
168.0
>>> w7.get_values("lenSeqAverage", 0)
168.0
>>> w7.get_values("lenSeqAverage", 1)
169.0
'''
......@@ -260,6 +267,10 @@ class Window:
"lenJunction": ["junction_stop", "junction_start", 0]
}
axes_rounded = {
"lenSeqAverage" : 1.0
}
try:
if axis in axes.keys():
path = axes[axis]
......@@ -271,15 +282,30 @@ class Window:
while depth != len(path):
value = value[path[depth]]
depth += 1
if axis in axes_rounded.keys():
value = self.round_axis(value, axes_rounded[axis])
if type(value) is list:
# In these cases, should be a list of value at different timepoint
return value[timepoint]
return value
return "unknow_axis"
except:
return "?"
def round_axis(self, value, round_set):
if isinstance(value, list):
for i in range(len(value)):
value[i] = self.round_axis(value[i], round_set)
else:
value = round(float(value) / round_set) * round_set
return value
def latex(self, point=0, base_germline=10000, base=10000, tag=''):
reads = self.d["reads"][point]
ratio_germline = float(reads)/base_germline
......@@ -870,6 +896,8 @@ class ListWindows(VidjilJson):
if len(values) > 1:
# Should increase for one depth
nvalues = values[1:]
if not obj[values[0]] :
obj[values[0]] = defaultdict(lambda: False)
obj[values[0]] = self.recursive_add(obj[values[0]], nvalues, nb_reads)
else:
# last depth
......@@ -907,6 +935,10 @@ seg_w7 = {
"reads": [
16
],
"_average_read_length": [
168.468,
168.568,
],
"seg": {
"3": {
"delLeft": 5,
......@@ -941,9 +973,6 @@ seg_w7 = {
},
},
"germline": "TRA",
"_average_read_length": [
76.0
],
"_coverage": [
0.973684191703796
],
......@@ -1154,6 +1183,9 @@ def main():
else:
jlist.load(path_name, args.pipeline)
jlist.build_stat()
if len(LIST_DISTRIBUTIONS):
jlist.init_distrib(LIST_DISTRIBUTIONS)
jlist.compute_distribution(LIST_DISTRIBUTIONS)
jlist.filter(f)
......@@ -1166,12 +1198,6 @@ def main():
print('\t==> merge to', jlist_fused)
if len(LIST_DISTRIBUTIONS):
print("### Compute distributions")
jlist_fused.init_distrib(LIST_DISTRIBUTIONS)
jlist_fused.compute_distribution(LIST_DISTRIBUTIONS)
if args.compress:
print()
print("### Select point names")
......
......@@ -21,8 +21,8 @@ $ Get correct file name in original_names field and distributions
2:"/some/file_1"
2:"/some/file_2"
$ should have two time 'distributions' (console log + into vidjil file)
2:distributions
$ should have two time 'distributions' (into vidjil file)
1:distributions
$ Axis title should be present 122 times (2*60+1/file)
......
......@@ -98,3 +98,75 @@ $ Filenames (original_files and repname)
###################################################
### Part with real clones, control top to keep ##
###################################################
!LAUNCH: python3 ../../fuse.py -t 3 -d germline,seg5 --no-clones --output fused_distribution_top.vidjil ../../../algo/tests/data/results_five_segmented_clones.vidjil ../../../algo/tests/data/results-two-clones-1-2.vidjil; cat fused_distribution_top.vidjil
$ Top clones; Get correct keys for distributions json content
1:"repertoires"
1:"keys"
1:"filters"
$ Top clones; Get correct files names (original_files, commandline and repname)
3:sequence_file
$ Top clones; Get correct files names (original_files and repname)
2:"/some/file_1"
$ Top clones; Case of an entire result with top idem (axes: germline, seg5)
lr1:"values": { "IGK": { .* "IGKV3-20\*01": \[ 1, 3898 \]
lr1:"values": { "IGK": { .* "IGKV1-39\*01": \[ 1, 5653 \]
lr1:"values": { "IGK": { .* "IGKV1-33\*01": \[ 1, 2597 \]
lr1:"values": { "IGK": { .* "IGKV4-1\*01": \[ 1, 2520 \]
lr1:"values": { "IGK": { .* "IGKV3-15\*01": \[ 1, 2502 \]
$ Case for the other files (axes: germline, seg5)
lr1:"values": { "IGH": { "\?": \[ 2, 900 \]
######################################################
### Part with real clones, distribution with 3 axes ##
######################################################
!LAUNCH: python3 ../../fuse.py -d germline,seg5,seg3 --no-clones --output fused_3_axes.vidjil ../../../algo/tests/data/results_five_segmented_clones.vidjil ../../../algo/tests/data/results-two-clones-1-2.vidjil; cat fused_3_axes.vidjil
$ 3 axes; Correct number of entries for some keys (1 by repertoire): seg5
2:"seg5"
$ 3 axes; Correct number of entries for some keys (1 by repertoire+sample): germline
3:"germline"
$ 3 axes; Get correct files names
:sequence_file
$ 3 axes; Filenames (original_files and repname)
2:"sequence_file"
2:"/some/file_1"
$ Top clones; Case of an entire result with top idem (axes: germline, seg5, seg3)
lr1:"values": { "IGK": { .* "IGKV3-20\*01": { .* "IGKJ2\*01": \[ 1, 3898 \]
lr1:"values": { "IGK": { .* "IGKV1-39\*01": { .* "IGKJ2\*01": \[ 1, 5653 \]
$ Case for the two cloness files (axes: germline, seg5, seg3)
lr1:"values": { "IGH": { "\?": { "\?": \[ 2, 900 \]
#################################################
### Part with real clones, test rounded axis ##
#################################################
!LAUNCH: python3 ../../fuse.py -d lenSeqAverage -d unknow_AXIS --no-clones --output fused_rounded_axes.vidjil ../../../algo/tests/data/results_five_segmented_clones.vidjil; cat fused_rounded_axes.vidjil
$ Rounded values: 76.123 (should not be present)
0:"76.123"
$ Rounded values: 76.0
1:"76.0"
$ Rounded values: 77.0
1:"77.0"
\ No newline at end of file
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