use of org.broadinstitute.hellbender.tools.readersplitters.ReaderSplitter in project gatk by broadinstitute.
the class SplitReads method createWriters.
/**
* Creates SAMFileWriter instances for the reader splitters based on the input file.
* @param splitters Reader splitters.
* @return A map of file name keys to SAMFileWriter.
*/
private Map<String, SAMFileGATKReadWriter> createWriters(final List<ReaderSplitter<?>> splitters) {
final Map<String, SAMFileGATKReadWriter> outs = new LinkedHashMap<>();
final SAMFileWriterFactory samFileWriterFactory = new SAMFileWriterFactory();
final SAMFileHeader samFileHeaderIn = getHeaderForReads();
// Build up a list of key options at each level.
final List<List<?>> splitKeys = splitters.stream().map(splitter -> splitter.getSplitsBy(samFileHeaderIn)).collect(Collectors.toList());
// For every combination of keys, add a SAMFileWriter.
addKey(splitKeys, 0, "", key -> {
outs.put(key, prepareSAMFileWriter(samFileWriterFactory, samFileHeaderIn, key));
});
return outs;
}
Aggregations