<s> import sys <EOL> import argparse <EOL> import pkg_resources <EOL> import vcf <EOL> from vcf . parser import _Filter <EOL> parser = argparse . ArgumentParser ( description = '<STR_LIT>' , <EOL> formatter_class = argparse . RawDescriptionHelpFormatter , <EOL> ) <EOL> parser . add_argument ( '<STR_LIT:input>' , metavar = '<STR_LIT:input>' , type = str , nargs = <NUM_LIT:1> , <EOL> help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , metavar = '<STR_LIT>' , type = str , nargs = '<STR_LIT:+>' , <EOL> help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , action = '<STR_LIT:store>' , default = sys . stdout , <EOL> help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> help = '<STR_LIT>' ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> filters = { } <EOL> filter_help = '<STR_LIT>' <EOL> for p in pkg_resources . iter_entry_points ( '<STR_LIT>' ) : <EOL> filt = p . load ( ) <EOL> filters [ filt . name ] = filt <EOL> filt . customize_parser ( parser ) <EOL> filter_help += '<STR_LIT>' % ( filt . name , filt . description ) <EOL> parser . description += filter_help <EOL> args = parser . parse_args ( ) <EOL> inp = vcf . Reader ( file ( args . input [ <NUM_LIT:0> ] ) ) <EOL> chain = [ ] <EOL> for name in args . filters : <EOL> f = filters [ name ] ( args ) <EOL> chain . append ( f ) <EOL> inp . filters [ f . filter_name ( ) ] = _Filter ( f . filter_name ( ) , f . description ) <EOL> oup = vcf . Writer ( args . output , inp ) <EOL> short_circuit = not args . no_short_circuit <EOL> for record in inp : <EOL> for filt in chain : <EOL> result = filt ( record ) <EOL> if result : <EOL> record . add_filter ( filt . filter_name ( ) ) <EOL> if short_circuit : <EOL> break <EOL> if ( not args . no_filtered ) or ( record . FILTER == '<STR_LIT:.>' ) : <EOL> oup . write_record ( record ) </s>
