From: Bo Li Date: Fri, 9 Mar 2012 04:36:05 +0000 (-0600) Subject: Add warning messages for detected invalid alignments X-Git-Url: https://git.donarmstrong.com/?p=rsem.git;a=commitdiff_plain;h=1f6726865dc80d8dd36462c559da46c9e4a8de8a Add warning messages for detected invalid alignments --- diff --git a/PairedEndModel.h b/PairedEndModel.h index 70d14c9..575344c 100644 --- a/PairedEndModel.h +++ b/PairedEndModel.h @@ -10,6 +10,7 @@ #include #include "utils.h" +#include "my_assert.h" #include "Orientation.h" #include "LenDist.h" #include "RSPD.h" @@ -99,7 +100,15 @@ public: int fpos = (dir == 0 ? pos : totLen - pos - insertLen); // the aligned position reported in SAM file, should be a coordinate in forward strand int effL = std::min(fullLen, totLen - insertLen + 1); - assert(fpos >= 0 && fpos + insertLen <= totLen && insertLen <= totLen); + general_assert(fpos >= 0, "The alignment of fragment " + read.getName() + " to transcript " + itos(sid) + " starts at " + itos(fpos) + \ + " from the forward direction, which should be a non-negative number! " + \ + "It is possible that the aligner you use gave different read lengths for a same read in SAM file."); + general_assert(fpos + insertLen <= totLen,"Fragment " + read.getName() + " is hung over the end of transcript " + itos(sid) + "! " \ + + "It is possible that the aligner you use gave different read lengths for a same read in SAM file."); + general_assert(insertLen <= totLen, "Fragment " + read.getName() + " has length " + itos(insertLen) + ", but it is aligned to transcript " \ + + itos(sid) + ", whose length (" + itos(totLen) + ") is shorter than the fragment's length!"); + + if (fpos >= fullLen || ref.getMask(fpos)) return 0.0; // For paired-end model, fpos is the seedPos prob = ori->getProb(dir) * gld->getAdjustedProb(insertLen, totLen) * diff --git a/PairedEndQModel.h b/PairedEndQModel.h index 2c638ab..c61f6c8 100644 --- a/PairedEndQModel.h +++ b/PairedEndQModel.h @@ -10,6 +10,7 @@ #include #include "utils.h" +#include "my_assert.h" #include "Orientation.h" #include "LenDist.h" #include "RSPD.h" @@ -103,7 +104,14 @@ public: int fpos = (dir == 0 ? pos : totLen - pos - insertLen); // the aligned position reported in SAM file, should be a coordinate in forward strand int effL = std::min(fullLen, totLen - insertLen + 1); - assert(fpos >= 0 && fpos + insertLen <= totLen && insertLen <= totLen); + general_assert(fpos >= 0, "The alignment of fragment " + read.getName() + " to transcript " + itos(sid) + " starts at " + itos(fpos) + \ + " from the forward direction, which should be a non-negative number! " + \ + "It is possible that the aligner you use gave different read lengths for a same read in SAM file."); + general_assert(fpos + insertLen <= totLen,"Fragment " + read.getName() + " is hung over the end of transcript " + itos(sid) + "! " \ + + "It is possible that the aligner you use gave different read lengths for a same read in SAM file."); + general_assert(insertLen <= totLen, "Fragment " + read.getName() + " has length " + itos(insertLen) + ", but it is aligned to transcript " \ + + itos(sid) + ", whose length (" + itos(totLen) + ") is shorter than the fragment's length!"); + if (fpos >= fullLen || ref.getMask(fpos)) return 0.0; // For paired-end model, fpos is the seedPos prob = ori->getProb(dir) * gld->getAdjustedProb(insertLen, totLen) * diff --git a/SingleModel.h b/SingleModel.h index 59db6ec..8b26e0e 100644 --- a/SingleModel.h +++ b/SingleModel.h @@ -10,6 +10,7 @@ #include #include "utils.h" +#include "my_assert.h" #include "Orientation.h" #include "LenDist.h" #include "RSPD.h" @@ -102,7 +103,14 @@ public: int readLen = read.getReadLength(); int fpos = (dir == 0 ? pos : totLen - pos - readLen); // the aligned position reported in SAM file, should be a coordinate in forward strand - assert(fpos >= 0 && fpos + readLen <= totLen && readLen <= totLen); + general_assert(fpos >= 0, "The alignment of read " + read.getName() + " to transcript " + itos(sid) + " starts at " + itos(fpos) + \ + " from the forward direction, which should be a non-negative number! " + \ + "It is possible that the aligner you use gave different read lengths for a same read in SAM file."); + general_assert(fpos + readLen <= totLen,"Read " + read.getName() + " is hung over the end of transcript " + itos(sid) + "! " \ + + "It is possible that the aligner you use gave different read lengths for a same read in SAM file."); + general_assert(readLen <= totLen, "Read " + read.getName() + " has length " + itos(readLen) + ", but it is aligned to transcript " \ + + itos(sid) + ", whose length (" + itos(totLen) + ") is shorter than the read's length!"); + int seedPos = (dir == 0 ? pos : totLen - pos - seedLen); // the aligned position of the seed in forward strand coordinates if (seedPos >= fullLen || ref.getMask(seedPos)) return 0.0; diff --git a/SingleQModel.h b/SingleQModel.h index 786d647..ffc0639 100644 --- a/SingleQModel.h +++ b/SingleQModel.h @@ -10,6 +10,7 @@ #include #include "utils.h" +#include "my_assert.h" #include "Orientation.h" #include "LenDist.h" #include "RSPD.h" @@ -108,7 +109,14 @@ public: int readLen = read.getReadLength(); int fpos = (dir == 0 ? pos : totLen - pos - readLen); // the aligned position reported in SAM file, should be a coordinate in forward strand - assert(fpos >= 0 && fpos + readLen <= totLen && readLen <= totLen); + general_assert(fpos >= 0, "The alignment of read " + read.getName() + " to transcript " + itos(sid) + " starts at " + itos(fpos) + \ + " from the forward direction, which should be a non-negative number! " + \ + "It is possible that the aligner you use gave different read lengths for a same read in SAM file."); + general_assert(fpos + readLen <= totLen,"Read " + read.getName() + " is hung over the end of transcript " + itos(sid) + "! " \ + + "It is possible that the aligner you use gave different read lengths for a same read in SAM file."); + general_assert(readLen <= totLen, "Read " + read.getName() + " has length " + itos(readLen) + ", but it is aligned to transcript " \ + + itos(sid) + ", whose length (" + itos(totLen) + ") is shorter than the read's length!"); + int seedPos = (dir == 0 ? pos : totLen - pos - seedLen); // the aligned position of the seed in forward strand coordinates if (seedPos >= fullLen || ref.getMask(seedPos)) return 0.0;