Skip to content

Commit 344ccb4

Browse files
authored
Merge pull request #223 from Irallia/FIX/readd_removed_if
[FIX] Readd removed if case
2 parents f52c733 + 3cd2375 commit 344ccb4

File tree

11 files changed

+67
-70
lines changed

11 files changed

+67
-70
lines changed
Binary file not shown.
-573 KB
Binary file not shown.
573 KB
Loading
Loading

src/variant_detection/variant_output.cpp

Lines changed: 60 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -72,72 +72,75 @@ void write_record(Cluster const & cluster,
7272

7373
if (mate1.seq_name == mate2.seq_name)
7474
{
75-
size_t const insert_size = cluster.get_average_inserted_sequence_size();
76-
int const distance = mate2.position - mate1.position - 1;
77-
int sv_length{};
78-
int sv_length_iGenVar{};
79-
std::string sv_type;
80-
81-
// Tandem Duplication
82-
// In case of a small deletion inside of a duplication, the distance is a small positive value
83-
if (cluster.get_common_tandem_dup_count() > 0 && static_cast<uint64_t>(distance) <= args.max_tol_deleted_length)
75+
if (mate1.orientation == strand::forward)
8476
{
85-
record.alt() = {"<DUP:TANDEM>"};
86-
// Increment end by 1 because VCF is 1-based
87-
record.info().push_back({.id = "END", .value = mate2.position + 1});
88-
sv_length = distance + 2;
89-
sv_length_iGenVar = insert_size;
90-
sv_type = "DUP";
91-
}
92-
// Deletion OR Inversion
93-
else if (distance > 0)
94-
{
95-
// Inversion
96-
// An Inversion consists of 2 Breakpoints, thus it looks like a deletion with an inserted sequence
97-
if (insert_size >= args.min_var_length)
77+
size_t const insert_size = cluster.get_average_inserted_sequence_size();
78+
int const distance = mate2.position - mate1.position - 1;
79+
int sv_length{};
80+
int sv_length_iGenVar{};
81+
std::string sv_type;
82+
83+
// Tandem Duplication
84+
// In case of a small deletion inside of a duplication, the distance is a small positive value
85+
if (cluster.get_common_tandem_dup_count() > 0 && static_cast<uint64_t>(distance) <= args.max_tol_deleted_length)
9886
{
99-
// Increment position by 1 because INV mate1 points on its last element
100-
record.pos() += 1;
101-
record.alt() = {"<INV>"};
87+
record.alt() = {"<DUP:TANDEM>"};
10288
// Increment end by 1 because VCF is 1-based
103-
// Increment end by 1 because inversion ends one base before mate2 begins
10489
record.info().push_back({.id = "END", .value = mate2.position + 1});
105-
sv_length = distance;
106-
sv_length_iGenVar = sv_length;
107-
sv_type = "INV";
90+
sv_length = distance + 2;
91+
sv_length_iGenVar = insert_size;
92+
sv_type = "DUP";
10893
}
109-
// Deletion
110-
// In case of a small insertion inside of an deletion, the insert_size is a small positive value.
111-
else if (insert_size <= args.max_tol_inserted_length)
94+
// Deletion OR Inversion
95+
else if (distance > 0)
11296
{
113-
record.alt() = {"<DEL>"};
97+
// Inversion
98+
// An Inversion consists of 2 Breakpoints, thus it looks like a deletion with an inserted sequence
99+
if (insert_size >= args.min_var_length)
100+
{
101+
// Increment position by 1 because INV mate1 points on its last element
102+
record.pos() += 1;
103+
record.alt() = {"<INV>"};
104+
// Increment end by 1 because VCF is 1-based
105+
// Increment end by 1 because inversion ends one base before mate2 begins
106+
record.info().push_back({.id = "END", .value = mate2.position + 1});
107+
sv_length = distance;
108+
sv_length_iGenVar = sv_length;
109+
sv_type = "INV";
110+
}
111+
// Deletion
112+
// In case of a small insertion inside of a deletion, the insert_size is a small positive value.
113+
else if (insert_size <= args.max_tol_inserted_length)
114+
{
115+
record.alt() = {"<DEL>"};
116+
// Increment end by 1 because VCF is 1-based
117+
// Decrement end by 1 because deletion ends one base before mate2 begins
118+
record.info().push_back({.id = "END", .value = mate2.position});
119+
sv_length = -distance;
120+
sv_length_iGenVar = sv_length;
121+
sv_type = "DEL";
122+
}
123+
}
124+
// Insertion (sv_length is positive)
125+
// In case of a small deletion inside of an insertion, the distance is a small positive value
126+
else if (insert_size > 0 && static_cast<uint64_t>(distance) <= args.max_tol_deleted_length)
127+
{
128+
record.alt() = {"<INS>"};
114129
// Increment end by 1 because VCF is 1-based
115-
// Decrement end by 1 because deletion ends one base before mate2 begins
116-
record.info().push_back({.id = "END", .value = mate2.position});
117-
sv_length = -distance;
130+
record.info().push_back({.id = "END", .value = mate1.position + 1});
131+
sv_length = insert_size;
118132
sv_length_iGenVar = sv_length;
119-
sv_type = "DEL";
133+
sv_type = "INS";
134+
}
135+
// The SVLEN is neither too short nor too long than specified by the user.
136+
if (std::abs(sv_length) >= args.min_var_length &&
137+
std::abs(sv_length) <= args.max_var_length)
138+
{
139+
record.info().push_back({.id = "SVLEN", .value = sv_length});
140+
record.info().push_back({.id = "iGenVar_SVLEN", .value = sv_length_iGenVar});
141+
record.info().push_back({.id = "SVTYPE", .value = sv_type});
142+
found_SV = true;
120143
}
121-
}
122-
// Insertion (sv_length is positive)
123-
// In case of a small deletion inside of an insertion, the distance is a small positive value
124-
else if (insert_size > 0 && static_cast<uint64_t>(distance) <= args.max_tol_deleted_length)
125-
{
126-
record.alt() = {"<INS>"};
127-
// Increment end by 1 because VCF is 1-based
128-
record.info().push_back({.id = "END", .value = mate1.position + 1});
129-
sv_length = insert_size;
130-
sv_length_iGenVar = sv_length;
131-
sv_type = "INS";
132-
}
133-
// The SVLEN is neither too short nor too long than specified by the user.
134-
if (std::abs(sv_length) >= args.min_var_length &&
135-
std::abs(sv_length) <= args.max_var_length)
136-
{
137-
record.info().push_back({.id = "SVLEN", .value = sv_length});
138-
record.info().push_back({.id = "iGenVar_SVLEN", .value = sv_length_iGenVar});
139-
record.info().push_back({.id = "SVTYPE", .value = sv_type});
140-
found_SV = true;
141144
}
142145
}
143146
}

test/benchmark/caller_comparison_iGenVar_only/workflow/rules/callers.smk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ rule run_iGenVar:
77
vcf = "results/caller_comparison_iGenVar_only/{input_combination}/variants.vcf"
88
log:
99
"logs/caller_comparison_iGenVar_only/{input_combination}_output.log"
10-
threads: 2
10+
threads: 4
1111
run:
1212
if wildcards.input_combination == 'S1': # Illumina Paired End
1313
short_bam = config["short_read_bam"]["s1"]

test/data/datasources.cmake

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@ declare_datasource (FILE single_end_mini_example.sam
2929
# copies file to <build>/data/output_err.txt
3030
declare_datasource (FILE output_err.txt
3131
URL ${CMAKE_SOURCE_DIR}/test/data/mini_example/output_err.txt
32-
URL_HASH SHA256=587d7d853a713cc6cb1af211a95190e6bd50b261160f7222d318c0841e9f16ff)
32+
URL_HASH SHA256=f44b6522c6df97506a70e6cc961c4d2b1caf2cef3b245688d327ce22c7425133)
3333

3434
# copies file to <build>/data/output_res.vcf
3535
declare_datasource (FILE output_res.vcf
3636
URL ${CMAKE_SOURCE_DIR}/test/data/mini_example/output_res.vcf
37-
URL_HASH SHA256=7dd5c100edaecf8227e92825aeb49649a8b1c3f459d047d67687b36b6f7cdaa9)
37+
URL_HASH SHA256=9b70052748679b2e29d4985ad9864380c6f7f66f56c6797f73421dd2598a1455)
3838

3939
# copies file to <build>/data/output_short_and_long_err.txt
4040
declare_datasource (FILE output_short_and_long_err.txt
4141
URL ${CMAKE_SOURCE_DIR}/test/data/mini_example/output_short_and_long_err.txt
42-
URL_HASH SHA256=a4aa69df5a9adfd6573e33686fb2c434cea21775420869c08070e458a5786714)
42+
URL_HASH SHA256=568ed8a913fc05f31f91051df6ef17be3b55c0afd79c5f6c657ad6342f897fd2)
4343

4444
# copies file to <build>/data/output_short_and_long_res.vcf
4545
declare_datasource (FILE output_short_and_long_res.vcf
4646
URL ${CMAKE_SOURCE_DIR}/test/data/mini_example/output_short_and_long_res.vcf
47-
URL_HASH SHA256=6ca496cf1c10699cf93c2c32dad2005d3ee5a4c9fd1a391c7eed81abd0b74376)
47+
URL_HASH SHA256=71b92fb734be1fa5b4d5973207920c17e8a2d02d9351a413fb401401eb500ad4)

test/data/mini_example/output_err.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,4 @@ Inverted bases: TAGCAACTCTCCAAAAC
7878
Start clustering...
7979
Done with clustering. Found 21 junction clusters.
8080
No refinement was selected.
81-
Detected 17 SVs.
81+
Detected 14 SVs.

test/data/mini_example/output_res.vcf

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,3 @@ chr1 368 . N <INS> 5 PASS END=368;SVLEN=11;iGenVar_SVLEN=11;SVTYPE=INS GT ./.
2626
chr1 384 . N <DEL> 1 PASS END=395;SVLEN=-11;iGenVar_SVLEN=-11;SVTYPE=DEL GT ./.
2727
chr1 509 . N <DUP:TANDEM> 1 PASS END=529;SVLEN=21;iGenVar_SVLEN=9;SVTYPE=DUP GT ./.
2828
chr1 581 . N <INV> 5 PASS END=598;SVLEN=17;iGenVar_SVLEN=17;SVTYPE=INV GT ./.
29-
chr1 267 . N <DEL> 3 PASS END=285;SVLEN=-18;iGenVar_SVLEN=-18;SVTYPE=DEL GT ./.
30-
chr1 283 . N <DEL> 3 PASS END=298;SVLEN=-15;iGenVar_SVLEN=-15;SVTYPE=DEL GT ./.
31-
chr1 509 . N <DEL> 1 PASS END=528;SVLEN=-19;iGenVar_SVLEN=-19;SVTYPE=DEL GT ./.

test/data/mini_example/output_short_and_long_err.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,4 @@ Inverted bases: TAGCAACTCTCCAAAAC
106106
Start clustering...
107107
Done with clustering. Found 21 junction clusters.
108108
No refinement was selected.
109-
Detected 17 SVs.
109+
Detected 14 SVs.

test/data/mini_example/output_short_and_long_res.vcf

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,3 @@ chr1 368 . N <INS> 5 PASS END=368;SVLEN=11;iGenVar_SVLEN=11;SVTYPE=INS GT ./.
2626
chr1 384 . N <DEL> 1 PASS END=395;SVLEN=-11;iGenVar_SVLEN=-11;SVTYPE=DEL GT ./.
2727
chr1 509 . N <DUP:TANDEM> 1 PASS END=529;SVLEN=21;iGenVar_SVLEN=9;SVTYPE=DUP GT ./.
2828
chr1 581 . N <INV> 5 PASS END=598;SVLEN=17;iGenVar_SVLEN=17;SVTYPE=INV GT ./.
29-
chr1 267 . N <DEL> 3 PASS END=285;SVLEN=-18;iGenVar_SVLEN=-18;SVTYPE=DEL GT ./.
30-
chr1 283 . N <DEL> 3 PASS END=298;SVLEN=-15;iGenVar_SVLEN=-15;SVTYPE=DEL GT ./.
31-
chr1 509 . N <DEL> 1 PASS END=528;SVLEN=-19;iGenVar_SVLEN=-19;SVTYPE=DEL GT ./.

0 commit comments

Comments
 (0)