Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix LeftAlignAndTrimVariants args. #5519

Merged
merged 1 commit into from
Jan 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.broadinstitute.hellbender.tools.walkers.variantutils;

import com.google.common.annotations.VisibleForTesting;
import htsjdk.samtools.Cigar;
import htsjdk.samtools.CigarElement;
import htsjdk.samtools.CigarOperator;
Expand All @@ -16,7 +17,6 @@
import org.broadinstitute.hellbender.engine.ReadsContext;
import org.broadinstitute.hellbender.engine.ReferenceContext;
import org.broadinstitute.hellbender.engine.VariantWalker;
import org.broadinstitute.hellbender.tools.walkers.annotator.ChromosomeCounts;
import org.broadinstitute.hellbender.utils.variant.GATKVCFConstants;
import org.broadinstitute.hellbender.utils.variant.GATKVCFHeaderLines;
import org.broadinstitute.hellbender.utils.variant.GATKVariantContextUtils;
Expand Down Expand Up @@ -122,6 +122,12 @@ public class LeftAlignAndTrimVariants extends VariantWalker {
public static final String SPLIT_MULTIALLELEICS_LONG_NAME = "split-multi-allelics";
public static final String KEEP_ORIGINAL_AC_LONG_NAME = "keep-original-ac";
public static final String MAX_INDEL_LENGTH_LONG_NAME = "max-indel-length";

private static final int DEFAULT_MAX_LEADING_BASES= 1000;

@VisibleForTesting
static final int DEFAULT_MAX_INDEL_SIZE = 200;

public static final String MAX_LEADING_BASES_LONG_NAME = "max-leading-bases";
/**
* Output file to which to write left aligned variants
Expand Down Expand Up @@ -155,26 +161,28 @@ public class LeftAlignAndTrimVariants extends VariantWalker {
* Maximum indel size to realign. Indels larger than this will be left unadjusted.
*/
@Argument(fullName = MAX_INDEL_LENGTH_LONG_NAME, doc = "Set maximum indel size to realign", optional = true)
protected static int maxIndelSize = 200;
protected int maxIndelSize = DEFAULT_MAX_INDEL_SIZE;

/**
* Distance in reference to look back before allele
*/
@Argument(fullName = MAX_LEADING_BASES_LONG_NAME, doc = "Set max reference window size to look back before allele", optional = true)
protected static int maxLeadingBases = 1000;
protected int maxLeadingBases = DEFAULT_MAX_LEADING_BASES;

@Hidden
@Argument(fullName = "suppress-reference-path", optional = true,
doc = "Suppress reference path in output for test result differencing")
private boolean suppressReferencePath = false;

protected VariantContextWriter vcfWriter = null;
protected int numRealignedVariants;
protected int numVariantsSplit;
protected int numVariantsSplitTo;
protected int numVariantsTrimmed;
protected int numSkippedForLength;
protected int longestSkippedVariant;
private VariantContextWriter vcfWriter = null;
private int numRealignedVariants;
private int numVariantsSplit;
private int numVariantsSplitTo;
private int numVariantsTrimmed;
@VisibleForTesting
int numSkippedForLength;
@VisibleForTesting
int longestSkippedVariant;
private int furthestEndOfEarlierVariant;
private String currentContig;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
import java.util.stream.*;
import java.io.File;

/**
* These tests should be refactored. They currently call LeftalignAndTrimVariants instance methods without
* putting it through the tool lifecycle.
*/
public class LeftAlignAndTrimVariantsUnitTest extends GATKBaseTest {
final String refBases1 = "GCAGAGCTGACCCTCCCTCCCCTCTCCCAGTGCAACAGCACGGGCGGCGACTGCTTTTACCGAGGCTACACGTCAGGCGTGGCGGCTGTCCAGGACTGGTACCACTTCCACTATGTGGATCTCTGCTGAGGACCAGGAAAGCCAGCACCCGCAGAGACTCTTCCCCAGTGCTCCATACGATCACCATTCTCTGCAGAAGG";
final String longStr = "AGTCGCTCGAGCTCGAGCTCGAGTGTGCGCTCTACAGCTCAGCTCGCTCGCACACAT";
Expand Down Expand Up @@ -96,7 +100,7 @@ public Object[][] LeftAlignTestData() throws UnsupportedEncodingException {
ReferenceContext ref = new ReferenceContext(refSource, interval);

final VariantContext vc = new VariantContextBuilder("test", artificialContig, indelIndex + 1, indelIndex + alleles.get(0).length(), alleles).make();
final boolean expectRealigned = (indelIndex != repeatStart - 1) && (indelRepeats * strLength <= LeftAlignAndTrimVariants.maxIndelSize);
final boolean expectRealigned = (indelIndex != repeatStart - 1) && (indelRepeats * strLength <= LeftAlignAndTrimVariants.DEFAULT_MAX_INDEL_SIZE);
final int expectedStart = expectRealigned ? repeatStart : indelIndex + 1;
tests.add(new Object[]{vc, ref, expectRealigned, expectedStart});
}
Expand Down Expand Up @@ -155,7 +159,7 @@ public void testSkipForLength(final VariantContext vc, final ReferenceContext re
Assert.assertEquals(1, leftAligner.numSkippedForLength);
leftAligner.longestSkippedVariant = 0;
leftAligner.numSkippedForLength = 0;
LeftAlignAndTrimVariants.maxIndelSize = lengthSkippedVariant;
leftAligner.maxIndelSize = lengthSkippedVariant;
leftAligner.leftAlign(vc, ref);
Assert.assertEquals(0, leftAligner.longestSkippedVariant);
Assert.assertEquals(0, leftAligner.numSkippedForLength);
Expand Down