X-Git-Url: https://git.donarmstrong.com/?p=rsem.git;a=blobdiff_plain;f=SamParser.h;h=513536f2a2107e181a0393946a00e9fa77c35416;hp=c5a503554b8c9cf4716b722d47da5f8c5db8540c;hb=683863b75f8d8bef2461039a6911b0e9619cc113;hpb=237bbdf363c9e42ee24e2fd63106dccf20d9bf2f diff --git a/SamParser.h b/SamParser.h index c5a5035..513536f 100644 --- a/SamParser.h +++ b/SamParser.h @@ -112,8 +112,7 @@ int SamParser::parseNext(SingleRead& read, SingleHit& hit) { bool canR = (samread(sam_in, b) >= 0); if (!canR) return -1; - if (b->core.flag & 0x0001) { fprintf(stderr, "Find a paired end read in the file!\n"); exit(-1); } - //(b->core.flag & 0x0100) && && !(b->core.flag & 0x0004) + general_assert(!(b->core.flag & 0x0001), "Find a paired end read in the file!"); int readType = getReadType(b); std::string name = getName(b); @@ -143,8 +142,7 @@ int SamParser::parseNext(SingleReadQ& read, SingleHit& hit) { bool canR = (samread(sam_in, b) >= 0); if (!canR) return -1; - if (b->core.flag & 0x0001) { fprintf(stderr, "Find a paired end read in the file!\n"); exit(-1); } - //assert(!(b->core.flag & 0x0001)); //(b->core.flag & 0x0100) && && !(b->core.flag & 0x0004) + general_assert(!(b->core.flag & 0x0001), "Find a paired end read in the file!"); int readType = getReadType(b); std::string name = getName(b); @@ -175,21 +173,22 @@ int SamParser::parseNext(PairedEndRead& read, PairedEndHit& hit) { bool canR = ((samread(sam_in, b) >= 0) && (samread(sam_in, b2) >= 0)); if (!canR) return -1; - if (!((b->core.flag & 0x0001) && (b2->core.flag & 0x0001))) { - fprintf(stderr, "One of the mate is not paired-end! (RSEM assumes the two mates of a paired-end read should be adjacent)\n"); - exit(-1); - } - //assert((b->core.flag & 0x0001) && (b2->core.flag & 0x0001)); + general_assert((b->core.flag & 0x0001) && (b2->core.flag & 0x0001), \ + "One of the mate is not paired-end! (RSEM assumes the two mates of a paired-end read should be adjacent)"); bam1_t *mp1 = NULL, *mp2 = NULL; - if ((b->core.flag & 0x0040) && (b2->core.flag & 0x0080)) { + // If lose mate info, discard. is it necessary? + if (!((b->core.flag & 0x0040) && (b2->core.flag & 0x0080)) && !((b->core.flag & 0x0080) && (b2->core.flag & 0x0040))) return 4; + // If only one mate is mapped, discard + if (((b->core.flag & 0x0004) && !(b2->core.flag & 0x0004)) || (!(b->core.flag & 0x0004) && (b2->core.flag & 0x0004))) return 4; + + if (b->core.flag & 0x0040) { mp1 = b; mp2 = b2; } - else if ((b->core.flag & 0x0080) && (b2->core.flag & 0x0040)) { + else { mp1 = b2; mp2 = b; } - else return 4; // If lose mate info, discard. is it necessary? int readType = getReadType(mp1, mp2); std::string name = getName(mp1); @@ -226,21 +225,22 @@ int SamParser::parseNext(PairedEndReadQ& read, PairedEndHit& hit) { bool canR = ((samread(sam_in, b) >= 0) && (samread(sam_in, b2) >= 0)); if (!canR) return -1; - if (!((b->core.flag & 0x0001) && (b2->core.flag & 0x0001))) { - fprintf(stderr, "One of the mate is not paired-end! (RSEM assumes the two mates of a paired-end read should be adjacent)\n"); - exit(-1); - } - //assert((b->core.flag & 0x0001) && (b2->core.flag & 0x0001)); + general_assert((b->core.flag & 0x0001) && (b2->core.flag & 0x0001), \ + "One of the mate is not paired-end! (RSEM assumes the two mates of a paired-end read should be adjacent)"); bam1_t *mp1 = NULL, *mp2 = NULL; - if ((b->core.flag & 0x0040) && (b2->core.flag & 0x0080)) { + // If lose mate info, discard. is it necessary? + if (!((b->core.flag & 0x0040) && (b2->core.flag & 0x0080)) && !((b->core.flag & 0x0080) && (b2->core.flag & 0x0040))) return 4; + // If only one mate is mapped, discard + if (((b->core.flag & 0x0004) && !(b2->core.flag & 0x0004)) || (!(b->core.flag & 0x0004) && (b2->core.flag & 0x0004))) return 4; + + if (b->core.flag & 0x0040) { mp1 = b; mp2 = b2; } - else if ((b->core.flag & 0x0080) && (b2->core.flag & 0x0040)) { + else { mp1 = b2; mp2 = b; } - else return 4; int readType = getReadType(mp1, mp2); std::string name = getName(mp1);