Search in sources :

Example 1 with ReaderSplitter

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;
}
Also used : DocumentedFeature(org.broadinstitute.barclay.help.DocumentedFeature) LibraryNameSplitter(org.broadinstitute.hellbender.tools.readersplitters.LibraryNameSplitter) CommandLineProgramProperties(org.broadinstitute.barclay.argparser.CommandLineProgramProperties) IOUtil(htsjdk.samtools.util.IOUtil) Argument(org.broadinstitute.barclay.argparser.Argument) StandardArgumentDefinitions(org.broadinstitute.hellbender.cmdline.StandardArgumentDefinitions) SampleNameSplitter(org.broadinstitute.hellbender.tools.readersplitters.SampleNameSplitter) GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) SAMFileHeader(htsjdk.samtools.SAMFileHeader) GATKException(org.broadinstitute.hellbender.exceptions.GATKException) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) ReadWalker(org.broadinstitute.hellbender.engine.ReadWalker) ReadProgramGroup(org.broadinstitute.hellbender.cmdline.programgroups.ReadProgramGroup) ReferenceContext(org.broadinstitute.hellbender.engine.ReferenceContext) FeatureContext(org.broadinstitute.hellbender.engine.FeatureContext) ReadGroupIdSplitter(org.broadinstitute.hellbender.tools.readersplitters.ReadGroupIdSplitter) SAMFileWriterFactory(htsjdk.samtools.SAMFileWriterFactory) ReaderSplitter(org.broadinstitute.hellbender.tools.readersplitters.ReaderSplitter) Collectors(java.util.stream.Collectors) File(java.io.File) Consumer(java.util.function.Consumer) List(java.util.List) UserException(org.broadinstitute.hellbender.exceptions.UserException) SAMFileGATKReadWriter(org.broadinstitute.hellbender.utils.read.SAMFileGATKReadWriter) FilenameUtils(org.apache.commons.io.FilenameUtils) SAMFileWriterFactory(htsjdk.samtools.SAMFileWriterFactory) SAMFileGATKReadWriter(org.broadinstitute.hellbender.utils.read.SAMFileGATKReadWriter) ArrayList(java.util.ArrayList) List(java.util.List) SAMFileHeader(htsjdk.samtools.SAMFileHeader) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

SAMFileHeader (htsjdk.samtools.SAMFileHeader)1 SAMFileWriterFactory (htsjdk.samtools.SAMFileWriterFactory)1 IOUtil (htsjdk.samtools.util.IOUtil)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 Consumer (java.util.function.Consumer)1 Collectors (java.util.stream.Collectors)1 FilenameUtils (org.apache.commons.io.FilenameUtils)1 Argument (org.broadinstitute.barclay.argparser.Argument)1 CommandLineProgramProperties (org.broadinstitute.barclay.argparser.CommandLineProgramProperties)1 DocumentedFeature (org.broadinstitute.barclay.help.DocumentedFeature)1 StandardArgumentDefinitions (org.broadinstitute.hellbender.cmdline.StandardArgumentDefinitions)1 ReadProgramGroup (org.broadinstitute.hellbender.cmdline.programgroups.ReadProgramGroup)1 FeatureContext (org.broadinstitute.hellbender.engine.FeatureContext)1 ReadWalker (org.broadinstitute.hellbender.engine.ReadWalker)1 ReferenceContext (org.broadinstitute.hellbender.engine.ReferenceContext)1 GATKException (org.broadinstitute.hellbender.exceptions.GATKException)1