use of htsjdk.samtools.reference.FastaSequenceFile 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);
}
}
Aggregations