protected void run(CommandLine commandLine) {
String cls = commandLine.getOptionValue('c');
if (cls == null) {
throw new MissingParameterException("class");
}
Filter filter;
if (cls.equals("one-to-one")) {
filter = new OneToOneSelector();
} else if (cls.equals("fraction")) {
float fraction = createFloat(commandLine, "fraction");
filter = new FractionSelector(fraction);
} else if (cls.equals("probability")) {
float probability = createFloat(commandLine, "probability");
filter = new ProbabilitySelector(probability);
} else if (cls.equals("intersection") || cls.equals("difference")) {
String alignmentString = commandLine.getOptionValue("alignment");
if (alignmentString == null) {
throw new MissingParameterException("alignment");
}
List<Alignment> alignment = loadAlignmentList(alignmentString);
if (cls.equals("intersection")) {
filter = new IntersectionSelector(alignment);
} else if (cls.equals("difference")) {
filter = new DifferenceSelector(alignment);
} else {
throw new UnknownParameterException("class");
}
} else {
throw new UnknownParameterException("class");
}
filter = FilterDecorators.decorate(filter);
Parser parser = new AlParser(getIn());
Formatter formatter = new AlFormatter(getOut());
List<Alignment> alignmentList = parser.parse();
alignmentList = filter.apply(alignmentList);
formatter.format(alignmentList);
}