Skip to content

Commit fc597d4

Browse files
committed
fixed comments on output reads and adjusted tests to reflect new comment structure
1 parent 0672477 commit fc597d4

8 files changed

+4851
-4837
lines changed

src/DistributedFunctions.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -918,6 +918,9 @@ done when empty cycle is received
918918
int maxKmers = std::max(1, (int) this->_reads.getMaxSequenceLength() - (int) KmerSizer::getSequenceLength());
919919
int reserveBB = ((batchSize * maxKmers) / numThreads) + 1;
920920
int reserveOffsets = (batchSize / numThreads) + 1;
921+
std::vector<bool> markupTrim;
922+
if (!useKmers)
923+
markupTrim.resize(batchSize);
921924

922925
LOG_DEBUG_GATHER(1, "Starting scoreAndTrimReadsMPI - trimming: " << readsSize << " using " << numThreads << " threads");
923926

@@ -986,7 +989,7 @@ done when empty cycle is received
986989
if (useKmers) {
987990
_batchKmerLookup(read, markupLength, offset, batchBuffer[threadId], *reqRespBuffer, threadId, numThreads, rank, worldSize, kmers);
988991
} else {
989-
this->trimReadByMarkupLength(read, this->_trims[readIdx], markupLength);
992+
markupTrim[i] = this->trimReadByMarkupLength(read, this->_trims[readIdx], markupLength);
990993
}
991994
}
992995
LOG_VERBOSE_OPTIONAL(1, _world.rank() == 0 && loopThreadId == 0, "trimming batch: " << batchReadIdx * _world.size());
@@ -1013,12 +1016,15 @@ done when empty cycle is received
10131016
*it = 0.0;
10141017
}
10151018

1019+
bool wasTrimmed = false;
10161020
if (useKmers) {
1017-
this->trimReadByMinimumKmerScore(minimumKmerScore, trim, buffBegin, buffEnd);
1021+
wasTrimmed = this->trimReadByMinimumKmerScore(minimumKmerScore, trim, buffBegin, buffEnd);
10181022
this->scoreReadByScoringType(buffBegin + trim.trimOffset, buffBegin + trim.trimOffset + trim.trimLength, trim, scoringType);
1023+
} else {
1024+
wasTrimmed = markupTrim[i];
10191025
}
10201026

1021-
this->setTrimHeaders(trim, useKmers, trim.trimLength < this->_reads.getRead(readIdx).getLength());
1027+
this->setTrimHeaders(trim, useKmers, wasTrimmed);
10221028
}
10231029

10241030
}

src/ReadSelector.h

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -930,24 +930,28 @@ class ReadSelector {
930930
}
931931
}
932932

933-
void trimReadByMarkupLength(const Read &read, ReadTrimType &trim, SequenceLengthType markupLength) {
933+
bool trimReadByMarkupLength(const Read &read, ReadTrimType &trim, SequenceLengthType markupLength) {
934+
bool wasTrimmed = false;
934935
if ( markupLength == 0 ) {
935936
trim.trimLength = read.getLength();
936937
} else {
937938
// TODO find longest stretch...
938939
// trim at first N or X markup
939940
trim.trimOffset = 0;
940941
trim.trimLength = markupLength - 1;
942+
wasTrimmed = true;
941943
}
942944
trim.score = trim.trimLength;
945+
return wasTrimmed;
943946
}
944947

945948
template<typename U>
946-
void trimReadByMinimumKmerScore(double minimumKmerScore, ReadTrimType &trim, U buffBegin, U buffEnd) {
949+
bool trimReadByMinimumKmerScore(double minimumKmerScore, ReadTrimType &trim, U buffBegin, U buffEnd) {
947950

948951
ReadTrimType test, best;
949952
std::stringstream ss;
950953
U it = buffBegin;
954+
int len = buffEnd - buffBegin;
951955

952956
while (it != buffEnd) {
953957
ScoreType score = *(it++);
@@ -1005,6 +1009,8 @@ class ReadSelector {
10051009
trim.trimOffset = best.trimOffset;
10061010
trim.trimLength = best.trimLength;
10071011

1012+
return (int) trim.trimLength < len;
1013+
10081014
};
10091015
void setTrimHeaders(ReadTrimType &trim, bool useKmers, bool wasTrimmed = true) {
10101016
if (trim.trimLength > 0) {
@@ -1039,17 +1045,20 @@ class ReadSelector {
10391045
}
10401046
}
10411047
}
1042-
void scoreReadByKmers(const Read &read, SequenceLengthType markupLength, ReadTrimType &trim, double minimumKmerScore, KA &kmers) {
1048+
bool scoreReadByKmers(const Read &read, SequenceLengthType markupLength, ReadTrimType &trim, double minimumKmerScore, KA &kmers) {
1049+
bool wasTrimmed = false;
10431050
getKmersForRead(read, kmers);
10441051
setKmerValues(kmers, minimumKmerScore);
10451052
LOG_DEBUG_OPTIONAL(5, true, "Trim and Score: " << read.getName());
10461053

1047-
trimReadByKmers(kmers.beginValue(), kmers.endValue(), markupLength, trim, minimumKmerScore);
1054+
wasTrimmed = trimReadByKmers(kmers.beginValue(), kmers.endValue(), markupLength, trim, minimumKmerScore);
10481055

10491056
if (trim.trimLength > 0)
10501057
scoreReadByScoringType(kmers.beginValue() + trim.trimOffset, kmers.beginValue() + trim.trimOffset + trim.trimLength, trim, _defaultScoringType);
10511058
else
10521059
trim.score = -1;
1060+
1061+
return wasTrimmed;
10531062
}
10541063

10551064
void setKmerValues(KA &kmers, double minimumKmerScore) {
@@ -1067,13 +1076,13 @@ class ReadSelector {
10671076
}
10681077

10691078
template<typename IT>
1070-
void trimReadByKmers(IT begin, IT end, SequenceLengthType markupLength, ReadTrimType &trim, double minimumKmerScore) {
1079+
bool trimReadByKmers(IT begin, IT end, SequenceLengthType markupLength, ReadTrimType &trim, double minimumKmerScore) {
10711080

10721081
SequenceLengthType numKmers = end-begin;
10731082

10741083
_setNumKmers(markupLength, numKmers);
10751084

1076-
trimReadByMinimumKmerScore(minimumKmerScore, trim, begin, begin + numKmers);
1085+
return trimReadByMinimumKmerScore(minimumKmerScore, trim, begin, begin + numKmers);
10771086
};
10781087

10791088
void scoreReadByScoringType(KA &kmers, ReadTrimType &trim, enum KmerScoringType scoringType) {
@@ -1183,19 +1192,19 @@ class ReadSelector {
11831192
KA &kmers = _kmers[omp_get_thread_num()];
11841193
ReadTrimType &trim = _trims[i];
11851194
const Read &read = _reads.getRead(i);
1186-
SequenceLengthType seqLen = read.getLength();
11871195
if (read.isDiscarded()) {
11881196
continue;
11891197
}
11901198
Sequence::BaseLocationVectorType markups = read.getMarkups();
11911199
SequenceLengthType markupLength = TwoBitSequence::firstMarkupNorX(markups);
11921200

1201+
bool wasTrimmed = false;
11931202
if (useKmers) {
1194-
scoreReadByKmers(read, markupLength, trim, minimumKmerScore, kmers);
1203+
wasTrimmed = scoreReadByKmers(read, markupLength, trim, minimumKmerScore, kmers);
11951204
} else { // !useKmers
1196-
trimReadByMarkupLength(read, trim, markupLength);
1205+
wasTrimmed = trimReadByMarkupLength(read, trim, markupLength);
11971206
}
1198-
setTrimHeaders(trim, useKmers, trim.trimLength < seqLen);
1207+
setTrimHeaders(trim, useKmers, wasTrimmed);
11991208
}
12001209
}
12011210

0 commit comments

Comments
 (0)