use of htsjdk.samtools.reference.ReferenceSequenceFile in project gatk by broadinstitute.
the class HaplotypeCaller method onTraversalStart.
@Override
public void onTraversalStart() {
final ReferenceSequenceFile referenceReader = getReferenceReader(referenceArguments);
hcEngine = new HaplotypeCallerEngine(hcArgs, getHeaderForReads(), referenceReader);
// The HC engine will make the right kind (VCF or GVCF) of writer for us
final SAMSequenceDictionary sequenceDictionary = getHeaderForReads().getSequenceDictionary();
vcfWriter = hcEngine.makeVCFWriter(outputVCF, sequenceDictionary);
hcEngine.writeHeader(vcfWriter, sequenceDictionary, getDefaultToolVCFHeaderLines());
}
use of htsjdk.samtools.reference.ReferenceSequenceFile in project gatk-protected by broadinstitute.
the class HaplotypeCaller method onTraversalStart.
@Override
public void onTraversalStart() {
final ReferenceSequenceFile referenceReader = getReferenceReader(referenceArguments);
hcEngine = new HaplotypeCallerEngine(hcArgs, getHeaderForReads(), referenceReader);
// The HC engine will make the right kind (VCF or GVCF) of writer for us
final SAMSequenceDictionary sequenceDictionary = getHeaderForReads().getSequenceDictionary();
vcfWriter = hcEngine.makeVCFWriter(outputVCF, sequenceDictionary);
hcEngine.writeHeader(vcfWriter, sequenceDictionary, getDefaultToolVCFHeaderLines());
}
use of htsjdk.samtools.reference.ReferenceSequenceFile in project gridss by PapenfussLab.
the class GenomicProcessingContext method ensureSeqeunceDictionary.
/**
* Ensures that a sequence dictionary exists for the given reference
* @param referenceFile reference genome fasta
*/
protected void ensureSeqeunceDictionary(File referenceFile) {
try {
ReferenceSequenceFile rsf = new FastaSequenceFile(referenceFile, false);
Path path = referenceFile.toPath().toAbsolutePath();
if (rsf.getSequenceDictionary() == null) {
log.info("Attempting to create sequence dictionary for " + referenceFile);
Path dictPath = path.resolveSibling(path.getFileName().toString() + htsjdk.samtools.util.IOUtil.DICT_FILE_EXTENSION);
picard.sam.CreateSequenceDictionary csd = new picard.sam.CreateSequenceDictionary();
if (program != null) {
CommandLineProgramHelper.copyInputs(program, csd);
}
csd.instanceMain(new String[] { "OUTPUT=" + dictPath.toFile(), "REFERENCE_SEQUENCE=" + referenceFile.getAbsolutePath() });
}
rsf.close();
} catch (Exception e) {
log.error("Sequence dictionary creation failed. Please create using picard CreateSequenceDictionary.", e);
}
}
use of htsjdk.samtools.reference.ReferenceSequenceFile in project gridss by PapenfussLab.
the class MultipleSamFileCommandLineProgram method ensureIndexed.
public static void ensureIndexed(File fa) throws IOException {
try (ReferenceSequenceFile reference = ReferenceSequenceFileFactory.getReferenceSequenceFile(fa)) {
if (!reference.isIndexed()) {
String msg = String.format("Unable to find index for %1$s. Please run 'samtools faidx %1$s' or picard tools BuildBamIndex to generate an index file.", fa);
log.error(msg);
throw new IOException(msg);
} else {
log.debug(fa, " is indexed.");
}
}
}
use of htsjdk.samtools.reference.ReferenceSequenceFile in project gridss by PapenfussLab.
the class MultipleSamFileCommandLineProgram method ensureSequenceDictionary.
public static void ensureSequenceDictionary(File fa) throws IOException {
File output = new File(fa.getAbsolutePath() + ".dict");
try (ReferenceSequenceFile reference = ReferenceSequenceFileFactory.getReferenceSequenceFile(fa)) {
SAMSequenceDictionary dictionary = reference.getSequenceDictionary();
if (dictionary == null) {
log.info("Attempting to generate missing sequence dictionary for ", fa);
try {
final SAMSequenceDictionary sequences = new CreateSequenceDictionary().makeSequenceDictionary(fa);
final SAMFileHeader samHeader = new SAMFileHeader();
samHeader.setSequenceDictionary(sequences);
try (SAMFileWriter samWriter = new SAMFileWriterFactory().makeSAMWriter(samHeader, false, output)) {
}
} catch (Exception e) {
log.error("Missing sequence dictionary for ", fa, " and creation of sequencing dictionary failed.", "Please run the Picard tools CreateSequenceDictionary utility to create", output);
throw e;
}
log.info("Created sequence dictionary ", output);
} else {
log.debug("Found sequence dictionary for ", fa);
}
}
}
Aggregations