Trivial change to LeftAlignVariants: make walker return number of aligned variants on map(), and print out the # of aligned variants at the end of the traversal.
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@4595 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
2f8057bf24
commit
9a60e72364
|
|
@ -76,26 +76,35 @@ public class LeftAlignVariants extends RodWalker<Integer, Integer> {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
Collection<VariantContext> VCs = tracker.getVariantContexts(ref, "variant", null, context.getLocation(), true, false);
|
Collection<VariantContext> VCs = tracker.getVariantContexts(ref, "variant", null, context.getLocation(), true, false);
|
||||||
for ( VariantContext vc : VCs )
|
|
||||||
alignAndWrite(vc, ref);
|
|
||||||
|
|
||||||
return 0;
|
int changedSites = 0;
|
||||||
|
for ( VariantContext vc : VCs )
|
||||||
|
changedSites += alignAndWrite(vc, ref);
|
||||||
|
|
||||||
|
return changedSites;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer reduceInit() { return 0; }
|
public Integer reduceInit() { return 0; }
|
||||||
|
|
||||||
public Integer reduce(Integer value, Integer sum) { return 0; }
|
public Integer reduce(Integer value, Integer sum) {
|
||||||
|
return sum + value;
|
||||||
public void onTraversalDone(Integer result) {}
|
|
||||||
|
|
||||||
private void alignAndWrite(VariantContext vc, final ReferenceContext ref) {
|
|
||||||
if ( vc.isBiallelic() && vc.isIndel() )
|
|
||||||
writeLeftAlignedIndel(vc, ref);
|
|
||||||
else
|
|
||||||
writer.add(vc, ref.getBase());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeLeftAlignedIndel(final VariantContext vc, final ReferenceContext ref) {
|
public void onTraversalDone(Integer result) {
|
||||||
|
System.out.println(result + " variants were aligned");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private int alignAndWrite(VariantContext vc, final ReferenceContext ref) {
|
||||||
|
if ( vc.isBiallelic() && vc.isIndel() )
|
||||||
|
return writeLeftAlignedIndel(vc, ref);
|
||||||
|
else {
|
||||||
|
writer.add(vc, ref.getBase());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int writeLeftAlignedIndel(final VariantContext vc, final ReferenceContext ref) {
|
||||||
final byte[] refSeq = ref.getBases();
|
final byte[] refSeq = ref.getBases();
|
||||||
|
|
||||||
// get the indel length
|
// get the indel length
|
||||||
|
|
@ -133,8 +142,10 @@ public class LeftAlignVariants extends RodWalker<Integer, Integer> {
|
||||||
newVC = updateAllele(newVC, newAllele);
|
newVC = updateAllele(newVC, newAllele);
|
||||||
|
|
||||||
writer.add(newVC, refSeq[indelIndex-1]);
|
writer.add(newVC, refSeq[indelIndex-1]);
|
||||||
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
writer.add(vc, ref.getBase());
|
writer.add(vc, ref.getBase());
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue