public void prepareWalker( Walker walker, ValidationStringency strictnessLevel ) { for( Map.Entry<ArgumentSource,Object> io: inputs.entrySet() ) { ArgumentSource targetField = io.getKey(); Object targetValue = io.getValue(); // Ghastly hack: reaches in and finishes building out the SameReader. // TODO: Generalize this, and move it to its own initialization step. if( targetValue instanceof SAMReaderBuilder) { SAMReaderBuilder builder = (SAMReaderBuilder)targetValue; builder.setValidationStringency(strictnessLevel); targetValue = builder.build(); } JVMUtils.setFieldValue( targetField.field, walker, targetValue ); } }
@Override public Object parse( ParsingEngine parsingEngine, ArgumentSource source, Type type, ArgumentMatches matches ) { SAMReaderBuilder builder = new SAMReaderBuilder(); ArgumentMatchValue readerFileName = getArgumentValue( createDefaultArgumentDefinition(source), matches ); if( readerFileName == null ) throw new UserException.CommandLineException("SAM file compression was supplied, but no associated writer was supplied with it."); builder.setSAMFile(readerFileName.asFile()); // WARNING: Skipping required side-effect because stub is impossible to generate. engine.addInput(source, builder); // MASSIVE KLUDGE! SamReader is tricky to implement and we don't yet have a stub. Return null, then // let the output tracker load it in. // TODO: Add a stub for SAMReader. return null; } }
/** * Create the SAM writer, given the constituent parts accrued. * @return Newly minted SAM file writer. */ public SamReader build() { if( samFile == null ) throw new ReviewedGATKException( "Filename for output sam file must be supplied."); if( validationStringency == null ) throw new ReviewedGATKException( "Header for output sam file must be supplied."); return SamReaderFactory .makeDefault() .referenceSequence(this.getReferenceFile()) .validationStringency(validationStringency) .open(samFile); } }