use of picard.sam.CreateSequenceDictionary 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