use of org.broadinstitute.hellbender.utils.smithwaterman.SWPairwiseAlignment in project gatk by broadinstitute.
the class ReadThreadingGraph method generateCigarAgainstDownwardsReferencePath.
/**
* Generates the CIGAR string from the Smith-Waterman alignment of the dangling path (where the
* provided vertex is the sink) and the reference path.
*
* @param vertex the sink of the dangling chain
* @param pruneFactor the prune factor to use in ignoring chain pieces
* @return a SmithWaterman object which can be null if no proper alignment could be generated
*/
@VisibleForTesting
final DanglingChainMergeHelper generateCigarAgainstDownwardsReferencePath(final MultiDeBruijnVertex vertex, final int pruneFactor, final int minDanglingBranchLength) {
// while heads can be 0, tails absolutely cannot
final int minTailPathLength = Math.max(1, minDanglingBranchLength);
// find the lowest common ancestor path between this vertex and the diverging master path if available
final List<MultiDeBruijnVertex> altPath = findPathUpwardsToLowestCommonAncestor(vertex, pruneFactor);
if (// add 1 to include the LCA
altPath == null || isRefSource(altPath.get(0)) || altPath.size() < minTailPathLength + 1) {
return null;
}
// now get the reference path from the LCA
final List<MultiDeBruijnVertex> refPath = getReferencePath(altPath.get(0), TraversalDirection.downwards, Optional.ofNullable(incomingEdgeOf(altPath.get(1))));
// create the Smith-Waterman strings to use
final byte[] refBases = getBasesForPath(refPath, false);
final byte[] altBases = getBasesForPath(altPath, false);
// run Smith-Waterman to determine the best alignment (and remove trailing deletions since they aren't interesting)
final SWPairwiseAlignment alignment = new SWPairwiseAlignment(refBases, altBases, SWPairwiseAlignment.STANDARD_NGS, SWPairwiseAlignment.OverhangStrategy.LEADING_INDEL);
return new DanglingChainMergeHelper(altPath, refPath, altBases, refBases, AlignmentUtils.removeTrailingDeletions(alignment.getCigar()));
}
use of org.broadinstitute.hellbender.utils.smithwaterman.SWPairwiseAlignment in project gatk by broadinstitute.
the class ReadThreadingGraph method generateCigarAgainstUpwardsReferencePath.
/**
* Generates the CIGAR string from the Smith-Waterman alignment of the dangling path (where the
* provided vertex is the source) and the reference path.
*
* @param vertex the source of the dangling head
* @param pruneFactor the prune factor to use in ignoring chain pieces
* @return a SmithWaterman object which can be null if no proper alignment could be generated
*/
@VisibleForTesting
final DanglingChainMergeHelper generateCigarAgainstUpwardsReferencePath(final MultiDeBruijnVertex vertex, final int pruneFactor, final int minDanglingBranchLength) {
// find the highest common descendant path between vertex and the reference source if available
final List<MultiDeBruijnVertex> altPath = findPathDownwardsToHighestCommonDescendantOfReference(vertex, pruneFactor);
if (// add 1 to include the LCA
altPath == null || isRefSink(altPath.get(0)) || altPath.size() < minDanglingBranchLength + 1) {
return null;
}
// now get the reference path from the LCA
final List<MultiDeBruijnVertex> refPath = getReferencePath(altPath.get(0), TraversalDirection.upwards, Optional.empty());
// create the Smith-Waterman strings to use
final byte[] refBases = getBasesForPath(refPath, true);
final byte[] altBases = getBasesForPath(altPath, true);
// run Smith-Waterman to determine the best alignment (and remove trailing deletions since they aren't interesting)
final SWPairwiseAlignment alignment = new SWPairwiseAlignment(refBases, altBases, SWPairwiseAlignment.STANDARD_NGS, SWPairwiseAlignment.OverhangStrategy.LEADING_INDEL);
return new DanglingChainMergeHelper(altPath, refPath, altBases, refBases, AlignmentUtils.removeTrailingDeletions(alignment.getCigar()));
}
Aggregations