/**
* The initialize function.
*/
public void initialize() {
final GenomeAnalysisEngine toolkit = getToolkit();
if ( toolkit != null )
readTransformers = toolkit.getReadTransformers();
//Sample names are case-insensitive
final TreeSet<String> samplesToChoose = new TreeSet<>(new Comparator<String>() {
@Override
public int compare(String a, String b) {
return a.compareToIgnoreCase(b);
}
});
Collection<String> samplesFromFile;
if (!sampleFile.isEmpty()) {
samplesFromFile = SampleUtils.getSamplesFromFiles(sampleFile);
samplesToChoose.addAll(samplesFromFile);
}
if (!sampleNames.isEmpty())
samplesToChoose.addAll(sampleNames);
random = GenomeAnalysisEngine.getRandomGenerator();
if (toolkit != null) {
final SAMFileHeader outputHeader = toolkit.getSAMFileHeader().clone();
readGroupsToKeep = determineReadGroupsOfInterest(outputHeader, samplesToChoose);
//If some read groups are to be excluded, remove them from the output header
pruneReadGroups(outputHeader);
//Add the program record (if appropriate) and set up the writer
final boolean preSorted = true;
if (toolkit.getArguments().BQSR_RECAL_FILE != null && !NO_PG_TAG ) {
Utils.setupWriter(out, toolkit, outputHeader, preSorted, this, PROGRAM_RECORD_NAME);
} else {
out.writeHeader(outputHeader);
out.setPresorted(preSorted);
}