Skip to content

Commit

Permalink
fix automated strand detection in single-end alignment-based moded
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Patro committed Aug 24, 2018
1 parent 2bd7786 commit a02c0e3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
3 changes: 3 additions & 0 deletions include/BAMQueue.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,9 @@ inline bool BAMQueue<FragT>::getFrag_(UnpairedRead& sread, FilterT filt) {
!(bam_flag(sread.read) & BAM_FUNMAP) and
sread.transcriptID() >= 0) {
haveValidRead = true;
bool isFwd = !(bam_strand(sread.read));
int32_t startPos = bam_pos(sread.read);
sread.libFmt = salmon::utils::hitType(startPos, isFwd);
}

if (!haveValidRead) {
Expand Down
2 changes: 1 addition & 1 deletion include/UnpairedRead.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ extern "C" {
struct UnpairedRead {
bam_seq_t* read = nullptr;
double logProb;
LibraryFormat libFmt{ReadType::PAIRED_END, ReadOrientation::NONE,
LibraryFormat libFmt{ReadType::SINGLE_END, ReadOrientation::NONE,
ReadStrandedness::U};

UnpairedRead()
Expand Down
8 changes: 4 additions & 4 deletions src/SalmonQuantify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ void processMiniBatch(ReadExperimentT& readExp, ForgettingMassCalculator& fmCalc
incompatPrior = salmon::math::LOG_1;
}

auto expectedLibraryFormat = readLib.format();
uint64_t zeroProbFrags{0};

// EQClass
Expand All @@ -237,8 +236,8 @@ void processMiniBatch(ReadExperimentT& readExp, ForgettingMassCalculator& fmCalc
double startingCumulativeMass =
fmCalc.cumulativeLogMassAt(firstTimestepOfRound);

auto isUnexpectedOrphan = [expectedLibraryFormat](AlnT& aln) -> bool {
return (expectedLibraryFormat.type == ReadType::PAIRED_END and
auto isUnexpectedOrphan = [](AlnT& aln, LibraryFormat expectedLibFormat) -> bool {
return (expectedLibFormat.type == ReadType::PAIRED_END and
aln.mateStatus != rapmap::utils::MateStatus::PAIRED_END_PAIRED);
};

Expand All @@ -253,6 +252,7 @@ void processMiniBatch(ReadExperimentT& readExp, ForgettingMassCalculator& fmCalc
if (alnGroup.size() == 0) {
continue;
}
LibraryFormat expectedLibraryFormat = readLib.format();
std::fill(libTypeCountsPerFrag.begin(), libTypeCountsPerFrag.end(), 0);

// We start out with probability 0
Expand Down Expand Up @@ -340,7 +340,7 @@ void processMiniBatch(ReadExperimentT& readExp, ForgettingMassCalculator& fmCalc
double logFragProb = LOG_1;
// If we are expecting a paired-end library, and this is an orphan,
// then logFragProb should be small
if (isUnexpectedOrphan(aln)) {
if (isUnexpectedOrphan(aln, expectedLibraryFormat)) {
logFragProb = LOG_EPSILON;
}

Expand Down
14 changes: 7 additions & 7 deletions src/SalmonQuantifyAlignments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ void processMiniBatch(AlignmentLibraryT<FragT>& alnLib,

double startingCumulativeMass =
fmCalc.cumulativeLogMassAt(firstTimestepOfRound);
auto expectedLibraryFormat = alnLib.format();
LibraryFormat expectedLibraryFormat = alnLib.format();
uint32_t numBurninFrags{salmonOpts.numBurninFrags};
bool noLengthCorrection{salmonOpts.noLengthCorrection};

Expand All @@ -200,8 +200,8 @@ void processMiniBatch(AlignmentLibraryT<FragT>& alnLib,

double maxZeroFrac{0.0};

auto isUnexpectedOrphan = [expectedLibraryFormat](FragT* aln) -> bool {
return (expectedLibraryFormat.type == ReadType::PAIRED_END and
auto isUnexpectedOrphan = [](FragT* aln, LibraryFormat expectedLibFormat) -> bool {
return (expectedLibFormat.type == ReadType::PAIRED_END and
!aln->isPaired());
};

Expand All @@ -226,7 +226,7 @@ void processMiniBatch(AlignmentLibraryT<FragT>& alnLib,

// If we actually got some work
if (miniBatch != nullptr) {

expectedLibraryFormat = alnLib.format();
useAuxParams = (processedReads >= salmonOpts.numPreBurninFrags);
bool considerCondProb = (useAuxParams or burnedIn);
++activeBatches;
Expand Down Expand Up @@ -288,7 +288,7 @@ void processMiniBatch(AlignmentLibraryT<FragT>& alnLib,
double logFragProb = LOG_1;
// If we are expecting a paired-end library, and this is an orphan,
// then logFragProb should be small
if (isUnexpectedOrphan(aln)) {
if (isUnexpectedOrphan(aln, expectedLibraryFormat)) {
logFragProb = LOG_EPSILON;
}

Expand Down Expand Up @@ -335,11 +335,11 @@ void processMiniBatch(AlignmentLibraryT<FragT>& alnLib,
detector->addSample(aln->libFormat());
if (detector->canGuess()) {
detector->mostLikelyType(alnLib.getFormat());
expectedLibraryFormat = alnLib.getFormat();
expectedLibraryFormat = alnLib.format();
incompatPrior = salmonOpts.incompatPrior;
autoDetect = false;
} else if (!detector->isActive()) {
expectedLibraryFormat = alnLib.getFormat();
expectedLibraryFormat = alnLib.format();
incompatPrior = salmonOpts.incompatPrior;
autoDetect = false;
}
Expand Down

0 comments on commit a02c0e3

Please sign in to comment.