From df2a7039cbca9d8efa8a7736069a10bcda8bae9d Mon Sep 17 00:00:00 2001 From: asivache Date: Sat, 21 Mar 2009 18:32:18 +0000 Subject: [PATCH] Henious bug fixed: only rookies forget that external conditions need to be re-checked after loop ends on some other condition, duh! In addition, msa piles are now seeded with a single read sequence each (if there are less then 4 reads it might be hard to seed with two pairs) git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@129 348d0f76-0448-11de-a6fe-93d51630548a --- .../indels/IndelRecordPileCollector.java | 36 ++++++++++--------- .../sting/indels/PileBuilder.java | 9 ++--- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/playground/java/src/org/broadinstitute/sting/indels/IndelRecordPileCollector.java b/playground/java/src/org/broadinstitute/sting/indels/IndelRecordPileCollector.java index 5a1997b3b..b86645403 100755 --- a/playground/java/src/org/broadinstitute/sting/indels/IndelRecordPileCollector.java +++ b/playground/java/src/org/broadinstitute/sting/indels/IndelRecordPileCollector.java @@ -305,24 +305,26 @@ public class IndelRecordPileCollector implements RecordReceiver { // we are done with current indel, get next one if any: if ( i_iter.hasNext() ) { indel = i_iter.next(); - if ( curr_stop < indel.getObject().getStart() ) { - // all alignments that overlapped with the previous indel ended before the current indel started, - // this means that the current train and pile of reads overlapping with it are fully built; - // emit into indel receiver if the train is interesting enough, or into the nonindel receiver: - - if ( shouldAcceptForOutput(finalTrain ) ) { - System.out.print(mLastContig+":"+ finalTrain.get(0).getObject().getStart() + "-" + - finalTrain.get(finalTrain.size()-1).getObject().getStop() + " " + - finalTrain.size() + " indels; "); - System.out.print(finalPile.size() + " reads in the pile;") ; - System.out.println(formatRange(finalTrain)); - indelPileReceiver.receive(finalPile); - } else for ( SAMRecord r : finalPile ) defaultReceiver.receive(r); - finalPile.clear(); - finalTrain.clear(); - curr_stop = -1; - } // ELSE: otherwise we have reads that overlap with both previous and current indel, so we just continue } else indel = null; + if ( indel == null || curr_stop < indel.getObject().getStart() ) { + // if there are no more indels or + // all alignments that overlapped with the previous indel ended before the current indel started, + // this means that the current train and pile of reads overlapping with it are fully built + // and can be emitted + + if ( shouldAcceptForOutput(finalTrain ) ) { + System.out.print(mLastContig+":"+ finalTrain.get(0).getObject().getStart() + "-" + + finalTrain.get(finalTrain.size()-1).getObject().getStop() + " " + + finalTrain.size() + " indels; "); + System.out.print(finalPile.size() + " reads in the pile;") ; + System.out.println(formatRange(finalTrain)); + indelPileReceiver.receive(finalPile); + } else for ( SAMRecord r : finalPile ) defaultReceiver.receive(r); + finalPile.clear(); + finalTrain.clear(); + curr_stop = -1; + } // ELSE: otherwise we have reads that overlap with both previous and current indel, so we just continue + // with building the indel train } setWaitState(); diff --git a/playground/java/src/org/broadinstitute/sting/indels/PileBuilder.java b/playground/java/src/org/broadinstitute/sting/indels/PileBuilder.java index 772157aba..801f7c504 100755 --- a/playground/java/src/org/broadinstitute/sting/indels/PileBuilder.java +++ b/playground/java/src/org/broadinstitute/sting/indels/PileBuilder.java @@ -262,18 +262,19 @@ public class PileBuilder implements RecordPileReceiver { //System.out.println( distances.format("%8.4g ")); - /* - SelectedPair pworst = pb.findWorst(); + + SelectedPair pworst = findWorst(); pile1.add(seqs[pworst.i()].getSequence(), pworst.i()); pile2.add(seqs[pworst.j()].getSequence(), pworst.j()); -*/ - + +/* // initialize piles with best and next-best pairs SelectedPair p_best = findClosestPair(); SelectedPair p_nextbest = findNextClosestPairAfter(p_best); pile1.add( alignments.get(p_best.i(), p_best.j()),p_best.i(),p_best.j()); pile2.add( alignments.get(p_nextbest.i(), p_nextbest.j()),p_nextbest.i(),p_nextbest.j()); +*/ /* System.out.println("Best pair ("+p_best.i() + "," + p_best.j()+", d="+p_best.d()+"):"); System.out.println(pile1.toString());