@@ -211,6 +211,7 @@ char const * const AlignmentBuffer::extractReferenceSequenceForAlignment(loc con
211
211
// TODO: check why decoded/SequenceProvider writes outside of refSeqLen: This makes + 100 necessary
212
212
refSeq = new char [refSeqLength + 100 ];
213
213
// decode reference refSeqLength
214
+ verbose (0 , true , " RefStart: %llu, RefLength: %d" , onRefStart, refSeqLength);
214
215
if (!SequenceProvider.DecodeRefSequenceExact (refSeq, onRefStart, refSeqLength, 0 )) {
215
216
// Log.Warning("Could not decode reference for alignment (read: %s): %llu, %d", cur_read->Scores[scoreID].Location.m_Location - (corridor >> 1), cur_read->length + corridor, cur_read->name);
216
217
Log.Warning (" Could not decode reference for alignment" );
@@ -429,7 +430,7 @@ Align * AlignmentBuffer::computeAlignment(Interval const * interval,
429
430
delete alignFast; alignFast = 0 ;
430
431
#endif
431
432
} else {
432
- Log.Error (" Could not align reference sequence for read %s." , read ->name );
433
+ Log.Error (" Could not extract reference sequence for read %s." , read ->name );
433
434
validAlignment = false ;
434
435
}
435
436
@@ -760,15 +761,16 @@ bool AlignmentBuffer::canSpanDeletionInsertion(Interval const * a, Interval cons
760
761
verbose (3 , true , " DistOnRef: %llu, DistOnRead: %d, Corridor: %f" , distanceOnRef, distanceOnRead, corridorSize);
761
762
if (distanceOnRead < (2 * readPartLength)) {
762
763
// Possible deletion
763
- merge = (distanceOnRef - distanceOnRead) < corridorSize;
764
+ merge = abs (distanceOnRef - distanceOnRead) < corridorSize;
764
765
} else if (distanceOnRef < (2 * readPartLength)) {
765
766
// Possible insertion
766
- merge = (distanceOnRead - distanceOnRef) < corridorSize;
767
+ merge = abs (distanceOnRead - distanceOnRef) < corridorSize;
767
768
} else {
768
769
/* *
769
770
* Do nothing, intervals show a larger gap. Probably, poor quality read.
770
771
* Better to merge than to risk fragmented alignments
771
772
*/
773
+ merge = abs (distanceOnRead - distanceOnRef) < corridorSize;
772
774
}
773
775
return merge;
774
776
}
@@ -2378,22 +2380,28 @@ void AlignmentBuffer::verbose(int const tabs, bool const newLine, char const * c
2378
2380
bool AlignmentBuffer::extendIntervalStop (Interval * interval, int const readBp, int const readLength) {
2379
2381
bool extended = false ;
2380
2382
2383
+ _SequenceProvider::Chromosome chr = SequenceProvider.getChrBorders (interval->onRefStart , interval->onRefStop );
2384
+
2385
+ verbose (0 , true , " extendIntervalStop - Located on chr %llu %llu" , chr.start , chr.end );
2386
+
2387
+
2381
2388
double lengthRatio = std::min (1 .0f , interval->lengthOnRead () * 1 .0f / interval->lengthOnRef () * 1 .0f );
2382
2389
// lengthRatio = 1.0;
2383
2390
2384
2391
int extendOnRead = std::min (readLength - interval->onReadStop , readBp);
2385
2392
int extendOnRef = (int ) round (extendOnRead / lengthRatio);
2386
2393
2387
- loc maxExtendOnRef = SequenceProvider. GetConcatRefLen () - interval->onRefStop ;
2394
+ loc maxExtendOnRef = interval-> onRefStop > chr. end ? 0 : chr. end - interval->onRefStop ;
2388
2395
if (interval->isReverse ) {
2389
- maxExtendOnRef = interval->onRefStop ;
2396
+ maxExtendOnRef = interval->onRefStop < chr. start ? 0 : interval-> onRefStop - chr. start ;
2390
2397
}
2391
2398
2392
2399
if (extendOnRef > maxExtendOnRef) {
2393
2400
extendOnRef = maxExtendOnRef;
2394
2401
extendOnRead = std::min (extendOnRead, std::max (0 , (int ) round (extendOnRef * lengthRatio) - 1 ));
2395
2402
}
2396
2403
2404
+ verbose (1 , true , " Min/Max extend on ref: %d/%lld" , extendOnRef, maxExtendOnRef);
2397
2405
interval->onReadStop += extendOnRead;
2398
2406
extended = true ;
2399
2407
if (interval->isReverse ) {
@@ -2408,16 +2416,22 @@ bool AlignmentBuffer::extendIntervalStop(Interval * interval, int const readBp,
2408
2416
bool AlignmentBuffer::extendIntervalStart (Interval * interval, int const readBp) {
2409
2417
bool extended = false ;
2410
2418
2419
+ _SequenceProvider::Chromosome chr = SequenceProvider.getChrBorders (interval->onRefStart , interval->onRefStop );
2420
+
2421
+ verbose (0 , true , " extendIntervalStart - Located on chr %llu %llu" , chr.start , chr.end );
2422
+
2423
+
2411
2424
double lengthRatio = std::min (1 .0f , interval->lengthOnRead () * 1 .0f / interval->lengthOnRef () * 1 .0f );
2412
2425
// lengthRatio = 1.0;
2413
2426
2414
2427
int extendOnRead = std::min (interval->onReadStart , readBp);
2415
2428
int extendOnRef = (int ) round (extendOnRead / lengthRatio);
2416
2429
2417
- loc maxExtendOnRef = interval->onRefStart ;
2430
+ loc maxExtendOnRef = interval->onRefStart < chr. start ? 0 : interval-> onRefStart - chr. start ;
2418
2431
if (interval->isReverse ) {
2419
- maxExtendOnRef = SequenceProvider. GetConcatRefLen () - interval->onRefStart ;
2432
+ maxExtendOnRef = interval-> onRefStart > chr. end ? 0 : chr. end - interval->onRefStart ;
2420
2433
}
2434
+ verbose (1 , true , " Min/Max extend on ref: %d/%lld" , extendOnRef, maxExtendOnRef);
2421
2435
if (extendOnRef > maxExtendOnRef) {
2422
2436
extendOnRef = maxExtendOnRef;
2423
2437
extendOnRead = std::min (extendOnRead, std::max (0 , (int ) round (extendOnRef * lengthRatio) - 1 ));
@@ -2466,6 +2480,8 @@ bool AlignmentBuffer::shortenIntervalEnd(Interval * interval, int const readBp)
2466
2480
2467
2481
int refBp = (int ) round (readBp / lengthRatio);
2468
2482
2483
+ verbose (1 , true , " %llu %d" , interval->onRefStop , refBp);
2484
+
2469
2485
if (readBp < interval->lengthOnRead () && refBp < interval->lengthOnRef ()) {
2470
2486
2471
2487
interval->onReadStop = interval->onReadStop - readBp;
@@ -3344,6 +3360,7 @@ void AlignmentBuffer::processLongReadLIS(ReadGroup * group) {
3344
3360
currentInterval->onRefStop = tmp;
3345
3361
}
3346
3362
3363
+ verbose (0 , " Aligning interval: " , currentInterval);
3347
3364
if (!Config.getSkipalign ()) {
3348
3365
alignSingleOrMultipleIntervals (read , currentInterval, tmpLocationScores, tmpAlingments, nTempAlignments);
3349
3366
} else {
0 commit comments