From a7cd3be57070b5ce9c3e9f92f2c533d30c1436de Mon Sep 17 00:00:00 2001 From: Xian Chang Date: Tue, 2 Mar 2021 22:17:12 -0500 Subject: [PATCH 1/3] Add proper pairing tag to alignment message and gaf --- deps/vg.proto | 1 + src/alignment_io.cpp | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/deps/vg.proto b/deps/vg.proto index 827d76a..064d8f2 100644 --- a/deps/vg.proto +++ b/deps/vg.proto @@ -146,6 +146,7 @@ message Alignment { double time_used = 35; // The time this alignment took Position to_correct = 36; // A path/offset/orientation pair specifying the distance to the correct alignment bool correctly_mapped = 37; // This can be set to true to annotate the Alignment as having been mapped correctly. + bool properly_paired = 38; google.protobuf.Struct annotation = 100; // Annotations carried along with the Alignment. } diff --git a/src/alignment_io.cpp b/src/alignment_io.cpp index 88fd383..750f604 100644 --- a/src/alignment_io.cpp +++ b/src/alignment_io.cpp @@ -376,6 +376,12 @@ gafkluge::GafRecord alignment_to_gaf(function node_to_length, fun gaf.opt_fields["fp"] = make_pair("Z", aln.fragment_prev().name()); } } + + if (aln.properly_paired()) { + gaf.opt_fields["pd"] = make_pair("b", "1"); + } else { + gaf.opt_fields["pd"] = make_pair("b", "0"); + } } return gaf; @@ -515,6 +521,9 @@ void gaf_to_alignment(function node_to_length, functionset_name(opt_it.second.second); + } else if (opt_it.first == "pd") { + //Is this read properly paired + aln.set_properly_paired(opt_it.second.second == "1"); } } } From d0d39fda18f422ff5fbfbb2fe3a9a446a618ecf5 Mon Sep 17 00:00:00 2001 From: Xian Chang Date: Wed, 3 Mar 2021 11:18:09 -0500 Subject: [PATCH 2/3] Use an annotation for proper pairing instead of a separate field --- deps/vg.proto | 1 - src/alignment_io.cpp | 15 ++++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/deps/vg.proto b/deps/vg.proto index 064d8f2..827d76a 100644 --- a/deps/vg.proto +++ b/deps/vg.proto @@ -146,7 +146,6 @@ message Alignment { double time_used = 35; // The time this alignment took Position to_correct = 36; // A path/offset/orientation pair specifying the distance to the correct alignment bool correctly_mapped = 37; // This can be set to true to annotate the Alignment as having been mapped correctly. - bool properly_paired = 38; google.protobuf.Struct annotation = 100; // Annotations carried along with the Alignment. } diff --git a/src/alignment_io.cpp b/src/alignment_io.cpp index 750f604..94f8f13 100644 --- a/src/alignment_io.cpp +++ b/src/alignment_io.cpp @@ -377,10 +377,12 @@ gafkluge::GafRecord alignment_to_gaf(function node_to_length, fun } } - if (aln.properly_paired()) { - gaf.opt_fields["pd"] = make_pair("b", "1"); - } else { - gaf.opt_fields["pd"] = make_pair("b", "0"); + if (aln.has_annotation()) { + auto& annotation = aln.annotation(); + if (annotation.fields().count("proper_pair")) { + bool is_properly_paired = (annotation.fields().at("proper_pair")).bool_value(); + gaf.opt_fields["pd"] = make_pair("b", is_properly_paired ? "1" : "0"); + } } } @@ -523,7 +525,10 @@ void gaf_to_alignment(function node_to_length, functionset_name(opt_it.second.second); } else if (opt_it.first == "pd") { //Is this read properly paired - aln.set_properly_paired(opt_it.second.second == "1"); + auto* annotation = aln.mutable_annotation(); + google::protobuf::Value is_properly_paired; + is_properly_paired.set_bool_value(opt_it.second.second == "1"); + annotation->mutable_fields()->at("proper_pair") = is_properly_paired; } } } From 34838033f95484152da2e80bf141e6ef0e65b67b Mon Sep 17 00:00:00 2001 From: Xian Chang Date: Wed, 3 Mar 2021 13:20:00 -0500 Subject: [PATCH 3/3] Set annotation value properly --- src/alignment_io.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/alignment_io.cpp b/src/alignment_io.cpp index 94f8f13..fe26acf 100644 --- a/src/alignment_io.cpp +++ b/src/alignment_io.cpp @@ -528,7 +528,7 @@ void gaf_to_alignment(function node_to_length, functionmutable_fields()->at("proper_pair") = is_properly_paired; + (*annotation->mutable_fields())["proper_pair"] = is_properly_paired; } } }