Skip to content

Commit

Permalink
Fix compile errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsooknah committed Feb 27, 2015
1 parent cf2954f commit 1d575d2
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
import htsjdk.variant.variantcontext.writer.VariantContextWriterBuilder;
import htsjdk.variant.vcf.VCFFileReader;
import htsjdk.variant.vcf.VCFHeader;
import picard.PicardException;
import picard.cmdline.CommandLineProgram;
import picard.cmdline.CommandLineProgramProperties;
import picard.cmdline.Option;
import picard.cmdline.StandardOptionDefinitions;
import picard.cmdline.programgroups.VcfOrBcf;
import org.broadinstitute.hellbender.cmdline.Argument;
import org.broadinstitute.hellbender.cmdline.CommandLineProgramProperties;
import org.broadinstitute.hellbender.cmdline.PicardCommandLineProgram;
import org.broadinstitute.hellbender.cmdline.StandardArgumentDefinitions;
import org.broadinstitute.hellbender.cmdline.programgroups.VariantProgramGroup;
import org.broadinstitute.hellbender.exceptions.UserException;

import java.io.File;

Expand All @@ -34,37 +34,33 @@
"headers of the two output files will be identical. An index file is created and a" +
"sequence dictionary is required by default.",
usageShort = "Splits an input VCF or BCF file into two VCF or BCF files",
programGroup = VcfOrBcf.class
programGroup = VariantProgramGroup.class
)
public class SplitVcfs extends CommandLineProgram {
public class SplitVcfs extends PicardCommandLineProgram {

@Option(shortName = StandardOptionDefinitions.INPUT_SHORT_NAME, doc="The VCF or BCF input file")
@Argument(shortName = StandardArgumentDefinitions.INPUT_SHORT_NAME, doc = "The VCF or BCF input file")
public File INPUT;

@Option(doc = "The VCF or BCF file to which SNP records should be written. The file format is determined by file extension.")
@Argument(doc = "The VCF or BCF file to which SNP records should be written. The file format is determined by file extension.")
public File SNP_OUTPUT;

@Option(doc = "The VCF or BCF file to which indel records should be written. The file format is determined by file extension.")
@Argument(doc = "The VCF or BCF file to which indel records should be written. The file format is determined by file extension.")
public File INDEL_OUTPUT;

@Option(shortName = "D", doc = "The index sequence dictionary to use instead of the sequence dictionaries in the input files", optional = true)
@Argument(shortName = "D", doc = "The index sequence dictionary to use instead of the sequence dictionaries in the input files", optional = true)
public File SEQUENCE_DICTIONARY;

@Option(doc = "If true an exception will be thrown if an event type other than SNP or indel is encountered")
@Argument(doc = "If true an exception will be thrown if an event type other than SNP or indel is encountered")
public Boolean STRICT = true;

private final Log log = Log.getInstance(SplitVcfs.class);

public static void main(final String[] argv) {
new SplitVcfs().instanceMainWithExit(argv);
}

public SplitVcfs() {
this.CREATE_INDEX = true;
}

@Override
protected int doWork() {
protected Object doWork() {
IOUtil.assertFileIsReadable(INPUT);
final ProgressLogger progress = new ProgressLogger(log, 10000);

Expand All @@ -76,7 +72,7 @@ protected int doWork() {
? SamReaderFactory.makeDefault().referenceSequence(REFERENCE_SEQUENCE).getFileHeader(SEQUENCE_DICTIONARY).getSequenceDictionary()
: fileHeader.getSequenceDictionary();
if (CREATE_INDEX && sequenceDictionary == null) {
throw new PicardException("A sequence dictionary must be available (either through the input file or by setting it explicitly) when creating indexed output.");
throw new UserException("A sequence dictionary must be available (either through the input file or by setting it explicitly) when creating indexed output.");
}

final VariantContextWriterBuilder builder = new VariantContextWriterBuilder()
Expand Down Expand Up @@ -114,6 +110,6 @@ protected int doWork() {
snpWriter.close();
indelWriter.close();

return 0;
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
import htsjdk.variant.variantcontext.writer.VariantContextWriterBuilder;
import htsjdk.variant.vcf.VCFFileReader;
import htsjdk.variant.vcf.VCFHeader;
import picard.cmdline.CommandLineProgram;
import picard.cmdline.CommandLineProgramProperties;
import picard.cmdline.Option;
import picard.cmdline.StandardOptionDefinitions;
import picard.cmdline.programgroups.VcfOrBcf;
import org.broadinstitute.hellbender.cmdline.Argument;
import org.broadinstitute.hellbender.cmdline.CommandLineProgramProperties;
import org.broadinstitute.hellbender.cmdline.PicardCommandLineProgram;
import org.broadinstitute.hellbender.cmdline.StandardArgumentDefinitions;
import org.broadinstitute.hellbender.cmdline.programgroups.VariantProgramGroup;

import java.io.File;

Expand All @@ -53,27 +53,23 @@
@CommandLineProgramProperties(
usage = "Takes a VCF and a second file that contains a sequence dictionary and updates the VCF with the new sequence dictionary.",
usageShort = "Takes a VCF and a second file that contains a sequence dictionary and updates the VCF with the new sequence dictionary.",
programGroup = VcfOrBcf.class
programGroup = VariantProgramGroup.class
)
public class UpdateVcfSequenceDictionary extends CommandLineProgram {
@Option(shortName = StandardOptionDefinitions.INPUT_SHORT_NAME, doc = "Input VCF")
public class UpdateVcfSequenceDictionary extends PicardCommandLineProgram {
@Argument(shortName = StandardArgumentDefinitions.INPUT_SHORT_NAME, doc = "Input VCF")
public File INPUT;

@Option(shortName = StandardOptionDefinitions.OUTPUT_SHORT_NAME, doc = "Output VCF to be written.")
@Argument(shortName = StandardArgumentDefinitions.OUTPUT_SHORT_NAME, doc = "Output VCF to be written.")
public File OUTPUT;

@Option(shortName = StandardOptionDefinitions.SEQUENCE_DICTIONARY_SHORT_NAME, doc = "A Sequence Dictionary (can be read from one of the " +
@Argument(shortName = StandardArgumentDefinitions.SEQUENCE_DICTIONARY_SHORT_NAME, doc = "A Sequence Dictionary (can be read from one of the " +
"following file types (SAM, BAM, VCF, BCF, Interval List, Fasta, or Dict)")
public File SEQUENCE_DICTIONARY;

private final Log log = Log.getInstance(UpdateVcfSequenceDictionary.class);

public static void main(final String[] args) {
new UpdateVcfSequenceDictionary().instanceMainWithExit(args);
}

@Override
protected int doWork() {
protected Object doWork() {
IOUtil.assertFileIsReadable(INPUT);
IOUtil.assertFileIsReadable(SEQUENCE_DICTIONARY);
IOUtil.assertFileIsWritable(OUTPUT);
Expand Down Expand Up @@ -105,6 +101,6 @@ protected int doWork() {
CloserUtil.close(fileReader);
vcfWriter.close();

return 0;
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
import htsjdk.variant.variantcontext.writer.VariantContextWriterBuilder;
import htsjdk.variant.vcf.VCFFileReader;
import htsjdk.variant.vcf.VCFHeader;
import picard.PicardException;
import picard.cmdline.CommandLineProgram;
import picard.cmdline.CommandLineProgramProperties;
import picard.cmdline.Option;
import picard.cmdline.StandardOptionDefinitions;
import picard.cmdline.programgroups.VcfOrBcf;
import org.broadinstitute.hellbender.cmdline.Argument;
import org.broadinstitute.hellbender.cmdline.CommandLineProgramProperties;
import org.broadinstitute.hellbender.cmdline.PicardCommandLineProgram;
import org.broadinstitute.hellbender.cmdline.StandardArgumentDefinitions;
import org.broadinstitute.hellbender.cmdline.programgroups.VariantProgramGroup;
import org.broadinstitute.hellbender.exceptions.UserException;

import java.io.File;

Expand All @@ -55,31 +55,27 @@
usage = "Convert a VCF file to a BCF file, or BCF to VCF.\n" +
"Input and output formats are determined by file extension.",
usageShort = "Converts a VCF file to a BCF file, or BCF to VCF",
programGroup = VcfOrBcf.class
programGroup = VariantProgramGroup.class
)
public class VcfFormatConverter extends CommandLineProgram {
public class VcfFormatConverter extends PicardCommandLineProgram {
// The following attributes define the command-line arguments
public static final Log LOG = Log.getInstance(VcfFormatConverter.class);

@Option(doc="The BCF or VCF input file. The file format is determined by file extension.", shortName= StandardOptionDefinitions.INPUT_SHORT_NAME)
@Argument(doc = "The BCF or VCF input file. The file format is determined by file extension.", shortName = StandardArgumentDefinitions.INPUT_SHORT_NAME)
public File INPUT;

@Option(doc="The BCF or VCF output file. The file format is determined by file extension.", shortName=StandardOptionDefinitions.OUTPUT_SHORT_NAME)
@Argument(doc = "The BCF or VCF output file. The file format is determined by file extension.", shortName = StandardArgumentDefinitions.OUTPUT_SHORT_NAME)
public File OUTPUT;

@Option(doc="Fail if an index is not available for the input VCF/BCF")
@Argument(doc = "Fail if an index is not available for the input VCF/BCF")
public Boolean REQUIRE_INDEX = true;

public static void main(final String[] argv) {
new VcfFormatConverter().instanceMainWithExit(argv);
}

public VcfFormatConverter() {
this.CREATE_INDEX = true;
}

@Override
protected int doWork() {
protected Object doWork() {
final ProgressLogger progress = new ProgressLogger(LOG, 10000);

IOUtil.assertFileIsReadable(INPUT);
Expand All @@ -89,7 +85,7 @@ protected int doWork() {
final VCFHeader header = new VCFHeader(reader.getFileHeader());
final SAMSequenceDictionary sequenceDictionary = header.getSequenceDictionary();
if (CREATE_INDEX && sequenceDictionary == null) {
throw new PicardException("A sequence dictionary must be available in the input file when creating indexed output.");
throw new UserException("A sequence dictionary must be available in the input file when creating indexed output.");
}

final VariantContextWriterBuilder builder = new VariantContextWriterBuilder()
Expand All @@ -113,6 +109,6 @@ protected int doWork() {
CloserUtil.close(reader);
writer.close();

return 0;
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import htsjdk.samtools.util.IntervalList;
import htsjdk.samtools.util.Log;
import htsjdk.variant.vcf.VCFFileReader;
import picard.cmdline.CommandLineProgram;
import picard.cmdline.CommandLineProgramProperties;
import picard.cmdline.Option;
import picard.cmdline.StandardOptionDefinitions;
import picard.cmdline.programgroups.VcfOrBcf;
import org.broadinstitute.hellbender.cmdline.Argument;
import org.broadinstitute.hellbender.cmdline.CommandLineProgramProperties;
import org.broadinstitute.hellbender.cmdline.PicardCommandLineProgram;
import org.broadinstitute.hellbender.cmdline.StandardArgumentDefinitions;
import org.broadinstitute.hellbender.cmdline.programgroups.VariantProgramGroup;

import java.io.File;

Expand All @@ -21,30 +21,26 @@
@CommandLineProgramProperties(
usage = "Converts a VCF or BCF file to a Picard Interval List.",
usageShort = "Converts a VCF or BCF file to a Picard Interval List.",
programGroup = VcfOrBcf.class
programGroup = VariantProgramGroup.class
)
public class VcfToIntervalList extends CommandLineProgram {
public class VcfToIntervalList extends PicardCommandLineProgram {
// The following attributes define the command-line arguments
public static final Log LOG = Log.getInstance(VcfToIntervalList.class);

@Option(doc="The BCF or VCF input file. The file format is determined by file extension.", shortName= StandardOptionDefinitions.INPUT_SHORT_NAME)
@Argument(doc = "The BCF or VCF input file. The file format is determined by file extension.", shortName= StandardArgumentDefinitions.INPUT_SHORT_NAME)
public File INPUT;

@Option(shortName = StandardOptionDefinitions.OUTPUT_SHORT_NAME, doc = "The output Picard Interval List")
@Argument(shortName = StandardArgumentDefinitions.OUTPUT_SHORT_NAME, doc = "The output Picard Interval List")
public File OUTPUT;

public static void main(final String[] argv) {
new VcfToIntervalList().instanceMainWithExit(argv);
}

@Override
protected int doWork() {
protected Object doWork() {
IOUtil.assertFileIsReadable(INPUT);
IOUtil.assertFileIsWritable(OUTPUT);

final IntervalList intervalList = VCFFileReader.fromVcf(INPUT);
// Sort and write the output
intervalList.uniqued().write(OUTPUT);
return 0;
return null;
}
}

0 comments on commit 1d575d2

Please sign in to comment.