@Override protected Collection<ArgumentTypeDescriptor> getArgumentTypeDescriptors() { List<ArgumentTypeDescriptor> typeDescriptors = new ArrayList<ArgumentTypeDescriptor>(); typeDescriptors.add(new VCFWriterArgumentTypeDescriptor(GATKEngine,System.out,Collections.<Object>emptyList())); typeDescriptors.add(new SAMFileWriterArgumentTypeDescriptor(GATKEngine,System.out)); typeDescriptors.add(new OutputStreamArgumentTypeDescriptor(GATKEngine,System.out)); return typeDescriptors; }
@Override public boolean supports( Class type ) { return getConstructorForClass(type) != null; }
@Override public Object parse( ParsingEngine parsingEngine, ArgumentSource source, Type type, ArgumentMatches matches ) { ArgumentDefinition definition = createDefaultArgumentDefinition(source); String fileName = getArgumentValue( definition, matches ).asString(); // This parser has been passed a null filename and the GATK is not responsible for creating a type default for the object; // therefore, the user must have failed to specify a type default if(fileName == null && source.isRequired()) throw new MissingArgumentValueException(definition); OutputStreamStub stub = new OutputStreamStub(new File(fileName)); engine.addOutput(stub); Object result = createInstanceOfClass(makeRawTypeIfNecessary(type),stub); // WARNING: Side effects required by engine! parsingEngine.addTags(result,getArgumentTags(matches)); return result; }
@Override public Object createTypeDefault(ParsingEngine parsingEngine,ArgumentSource source, Type type) { if(source.isRequired() || !source.defaultsToStdout()) throw new ReviewedGATKException("BUG: tried to create type default for argument type descriptor that can't support a type default."); OutputStreamStub stub = new OutputStreamStub(defaultOutputStream); engine.addOutput(stub); return createInstanceOfClass((Class)type,stub); }
/** * Subclasses of CommandLinePrograms can provide their own types of command-line arguments. * @return A collection of type descriptors generating implementation-dependent placeholders. */ protected Collection<ArgumentTypeDescriptor> getArgumentTypeDescriptors() { return Arrays.asList( new VCFWriterArgumentTypeDescriptor(engine,System.out,argumentSources), new SAMFileWriterArgumentTypeDescriptor(engine,System.out), new OutputStreamArgumentTypeDescriptor(engine,System.out) ); }
/** * Creat a new instance of the class accepting a single outputstream constructor. * @param type Type of object to create. * @param outputStream resulting output stream. * @return A new instance of the outputstream-derived class. */ private Object createInstanceOfClass(Class type,OutputStream outputStream) { try { return getConstructorForClass(type).newInstance(outputStream); } catch (Exception e) { throw new DynamicClassResolutionException(type, e); } } }
@Override public Collection<ArgumentTypeDescriptor> getArgumentTypeDescriptors() { final GenomeAnalysisEngine engine = new GenomeAnalysisEngine(); return Arrays.asList( new SAMFileWriterArgumentTypeDescriptor(engine, System.out), new OutputStreamArgumentTypeDescriptor(engine, System.out), new VCFWriterArgumentTypeDescriptor(engine, System.out, null)); }