<s> import sys <EOL> from itertools import starmap , izip , chain <EOL> from seqio import iteratorFromExtension , recordToString , FastqRecord <EOL> from nucio import fileIterator <EOL> from args import parseArgs , getHelpStr , CLArgument <EOL> description = ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> argument_list = [ [ "<STR_LIT>" , "<STR_LIT>" , str , "<STR_LIT:/>" , "<STR_LIT>" ] ] <EOL> arguments = map ( CLArgument . _make , argument_list ) <EOL> if not len ( sys . argv ) >= <NUM_LIT:2> : <EOL> sys . exit ( getHelpStr ( description , arguments ) + "<STR_LIT:\n>" ) <EOL> ( p_arg_map , args_remaining ) = parseArgs ( sys . argv [ <NUM_LIT:1> : ] , arguments ) <EOL> its = map ( iteratorFromExtension , args_remaining ) <EOL> file_its = starmap ( fileIterator , izip ( args_remaining , its ) ) <EOL> fh_h = { } <EOL> for entry in chain . from_iterable ( file_its ) : <EOL> h = entry . name . split ( p_arg_map [ "<STR_LIT>" ] ) [ <NUM_LIT:0> ] <EOL> ext = "<STR_LIT>" if isinstance ( entry , FastqRecord ) else "<STR_LIT>" <EOL> if not h in fh_h : <EOL> fh_h [ h ] = open ( h + ext , "<STR_LIT:w>" ) <EOL> fh_h [ h ] . write ( recordToString ( entry ) ) <EOL> fh_h [ h ] . write ( "<STR_LIT:\n>" ) </s>
