From aabceca0a62d4956302b250a886abe181d48feb9 Mon Sep 17 00:00:00 2001 From: "Philip R. Kensche" Date: Thu, 1 Feb 2024 16:45:33 +0100 Subject: [PATCH] Comments and layout changes. Signed-off-by: Philip R. Kensche --- CodingConventions.md | 6 ++++++ include/ChosenBp.h | 6 ++++++ include/SuppAlignment.h | 12 ++++++++++-- src/Alignment.cpp | 11 +++++++---- src/Breakpoint.cpp | 24 ++++++++++++++++++------ 5 files changed, 47 insertions(+), 12 deletions(-) diff --git a/CodingConventions.md b/CodingConventions.md index 03b2cb7..2c57290 100644 --- a/CodingConventions.md +++ b/CodingConventions.md @@ -12,3 +12,9 @@ The code still has severe legacy problems with these issues. 7. Use the standard library, including the Standard Template Library. Prefer searching in the C++ standard library over reinventing the wheel. 8. Use the boost library. It is already a dependency. Prefer search in boost over reinventing the wheel. 9. Always try to leave the code in a better (more readable, understandable, maintainable, safer) state than you found it. +10. C++ is hard to read, so don't make it harder than necessary. Code readability is **not optional**. + * Use descriptive but concise names for variables, functions, classes, etc. + * Keep lines short. + * Prefer vertical lists (e.g. of function arguments) over horizontal lists). + * Avoid "what" and "how" comments. Prefer "why" comments. +11. If you figure out something really hard and unintuitive, add a comment instead of letting the next programmer figure it out again. diff --git a/include/ChosenBp.h b/include/ChosenBp.h index dfd6333..30d4b18 100644 --- a/include/ChosenBp.h +++ b/include/ChosenBp.h @@ -36,6 +36,12 @@ using namespace std; friend class Alignment; public: + + /** + * + * @param selfNodeIndexIn Index into an array of supporting alignments. + * See alignment::setChosenBp. + */ ChosenBp(char bpTypeIn, int bpSizeIn, bool bpEncounteredMIn, diff --git a/include/SuppAlignment.h b/include/SuppAlignment.h index e560666..4d9c82a 100644 --- a/include/SuppAlignment.h +++ b/include/SuppAlignment.h @@ -45,6 +45,10 @@ namespace sophia { SuppAlignment(); public: + + /** + * @param originIndexIn Index into an array of supporting alignments + **/ static SuppAlignment create( ChrIndex chrIndexIn, ChrSize posIn, @@ -62,8 +66,12 @@ namespace sophia { * breakpoints BED format and generated by SuppAlignment::print. */ static SuppAlignment parseSaSupport(const string &saIn); - /** Parse the supplementary alignment information from SAM format SA:Z: tags. */ - static SuppAlignment parseSamSaTag(string::const_iterator saCbegin, + /** Parse the supplementary alignment information from SAM format SA:Z: tags. + * + * @param originIndexIn Index into an array of supporting alignments + */ + static SuppAlignment parseSamSaTag( + string::const_iterator saCbegin, string::const_iterator saCend, bool primaryIn, bool lowMapqSourceIn, diff --git a/src/Alignment.cpp b/src/Alignment.cpp index a915236..5886071 100644 --- a/src/Alignment.cpp +++ b/src/Alignment.cpp @@ -662,9 +662,12 @@ namespace sophia { } } chosenBp.reset(); - chosenBp = make_unique(bpType, bpSize, bpEncounteredM, - overhangStartIndex, overhangLength, - alignmentIndex); + chosenBp = make_unique(bpType, + bpSize, + bpEncounteredM, + overhangStartIndex, + overhangLength, + alignmentIndex /* origin index */); } vector @@ -722,7 +725,7 @@ namespace sophia { !supplementary, lowMapq, nullMapq, - chosenBp->selfNodeIndex)); + chosenBp->selfNodeIndex /* origin index */)); } } } diff --git a/src/Breakpoint.cpp b/src/Breakpoint.cpp index 6525f92..1dd8be4 100644 --- a/src/Breakpoint.cpp +++ b/src/Breakpoint.cpp @@ -808,10 +808,16 @@ namespace sophia { mateInfo.matePower / (0.0 + leftDiscordantsTotal) >= 0.33 && (pos - mateInfo.readEndPos) < DEFAULT_READ_LENGTH / 2) { supplementsPrimary.emplace_back(SuppAlignment::create( - mateInfo.mateChrIndex, mateInfo.mateStartPos, - mateInfo.matePower, leftDiscordantsTotal, true, + mateInfo.mateChrIndex, + mateInfo.mateStartPos, + mateInfo.matePower, + leftDiscordantsTotal, true, mateInfo.inversionSupport > mateInfo.straightSupport, - mateInfo.mateEndPos, false, false, false, -1)); + mateInfo.mateEndPos, + false, + false, + false, + -1 /* origin index */)); } } for (const auto &mateInfo : poolRight) { @@ -819,10 +825,16 @@ namespace sophia { mateInfo.matePower / (0.0 + rightDiscordantsTotal) >= 0.33 && (mateInfo.readStartPos - pos) < DEFAULT_READ_LENGTH / 2) { supplementsPrimary.emplace_back(SuppAlignment::create( - mateInfo.mateChrIndex, mateInfo.mateStartPos, - mateInfo.matePower, rightDiscordantsTotal, false, + mateInfo.mateChrIndex, + mateInfo.mateStartPos, + mateInfo.matePower, + rightDiscordantsTotal, false, mateInfo.inversionSupport > mateInfo.straightSupport, - mateInfo.mateEndPos, false, false, false, -1)); + mateInfo.mateEndPos, + false, + false, + false, + -1 /* origin index */)); } } for (auto &sa : doubleSidedMatches) {