From bb949fd589d2a2bc374143282223607dfe01f5d7 Mon Sep 17 00:00:00 2001 From: milenovic Date: Wed, 22 Jan 2025 13:20:39 -0800 Subject: [PATCH 1/2] Add rd depth tag from hifiasm rd=n means that n+1 reads were used to construct the node. --- graph/assemblygraphbuilder.cpp | 4 ++++ graph/gfawriter.cpp | 2 ++ 2 files changed, 6 insertions(+) diff --git a/graph/assemblygraphbuilder.cpp b/graph/assemblygraphbuilder.cpp index b1d97cac..aae91758 100644 --- a/graph/assemblygraphbuilder.cpp +++ b/graph/assemblygraphbuilder.cpp @@ -217,6 +217,7 @@ static bool isStandardGFATag(const char name[2]) { case makeGFATag("FC"): case makeGFATag("RC"): case makeGFATag("ka"): + case makeGFATag("rd"): case makeGFATag("LB"): case makeGFATag("L2"): case makeGFATag("CB"): @@ -422,6 +423,9 @@ namespace io { } else if (auto kaTag = gfa::getTag("ka", record.tags)) { graph.m_depthTag = "ka"; nodeDepth = *kaTag; + } else if (auto rdTag = gfa::getTag("rd", record.tags)) { + graph.m_depthTag = "rd"; + nodeDepth = *rdTag; } else if (auto kcTag = gfa::getTag("KC", record.tags)) { graph.m_depthTag = "KC"; nodeDepth = double(*kcTag) / double(length); diff --git a/graph/gfawriter.cpp b/graph/gfawriter.cpp index 79e5eeb1..6bf6ff57 100644 --- a/graph/gfawriter.cpp +++ b/graph/gfawriter.cpp @@ -71,6 +71,8 @@ namespace gfa { //information and so we don't save depth. if (depthTag == "DP" || depthTag == "dp") gfaSegmentLine += "\tDP:f:" + QString::number(node->getDepth()).toLatin1(); + else if (depthTag == "rd") + gfaSegmentLine += "\trd:i:" + QString::number(node->getDepth()).toLatin1(); else if (depthTag == "KC" || depthTag == "RC" || depthTag == "FC") gfaSegmentLine += "\t" + depthTag.toLatin1() + ":i:" + QString::number(int(node->getDepth() * gfaSequence.length() + 0.5)).toLatin1(); From fc8c05f43ba3b8ceb50b82572811407ab8d25b61 Mon Sep 17 00:00:00 2001 From: milenovic Date: Wed, 22 Jan 2025 13:50:42 -0800 Subject: [PATCH 2/2] Display hifiasm coverage in a user-friendly way hifiasm shows coverage as in rd:i:n tag where coverage is n+1. --- graph/assemblygraphbuilder.cpp | 2 +- graph/gfawriter.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/graph/assemblygraphbuilder.cpp b/graph/assemblygraphbuilder.cpp index aae91758..14a9467a 100644 --- a/graph/assemblygraphbuilder.cpp +++ b/graph/assemblygraphbuilder.cpp @@ -425,7 +425,7 @@ namespace io { nodeDepth = *kaTag; } else if (auto rdTag = gfa::getTag("rd", record.tags)) { graph.m_depthTag = "rd"; - nodeDepth = *rdTag; + nodeDepth = *rdTag + 1; } else if (auto kcTag = gfa::getTag("KC", record.tags)) { graph.m_depthTag = "KC"; nodeDepth = double(*kcTag) / double(length); diff --git a/graph/gfawriter.cpp b/graph/gfawriter.cpp index 6bf6ff57..a3a3e787 100644 --- a/graph/gfawriter.cpp +++ b/graph/gfawriter.cpp @@ -72,7 +72,7 @@ namespace gfa { if (depthTag == "DP" || depthTag == "dp") gfaSegmentLine += "\tDP:f:" + QString::number(node->getDepth()).toLatin1(); else if (depthTag == "rd") - gfaSegmentLine += "\trd:i:" + QString::number(node->getDepth()).toLatin1(); + gfaSegmentLine += "\trd:i:" + QString::number(node->getDepth()-1).toLatin1(); else if (depthTag == "KC" || depthTag == "RC" || depthTag == "FC") gfaSegmentLine += "\t" + depthTag.toLatin1() + ":i:" + QString::number(int(node->getDepth() * gfaSequence.length() + 0.5)).toLatin1();