def main(args=None):
if args is None:<EOL><INDENT>parser = get_argument_parser()<EOL>args = parser.parse_args()<EOL><DEDENT>fasta_file = args.fasta_file<EOL>species = args.species<EOL>chrom_pat = args.chromosome_pattern<EOL>output_file = args.output_file<EOL>log_file = args.log_file<EOL>quiet = args.quiet<EOL>verbose = args.verbose<EOL>log_stream = sys.stdout<EOL>if output_file == '<STR_LIT:->':<EOL><INDENT>log_stream = sys.stderr<EOL><DEDENT>logger = misc.get_logger(log_stream=log_stream, log_file=log_file,<EOL>quiet=quiet, verbose=verbose)<EOL>if chrom_pat is None:<EOL><INDENT>chrom_pat = ensembl.SPECIES_CHROMPAT[species]<EOL><DEDENT>chrom_re = re.compile(chrom_pat)<EOL>withmisc.smart_open_read(<EOL>fasta_file, mode='<STR_LIT:r>', encoding='<STR_LIT:ascii>', try_gzip=True<EOL>) as fh,misc.smart_open_write(<EOL>output_file, mode='<STR_LIT:w>', encoding='<STR_LIT:ascii>'<EOL>) as ofh:<EOL><INDENT>reader = FastaReader(fh)<EOL>for seq in reader:<EOL><INDENT>chrom = seq.name.split('<STR_LIT:U+0020>', <NUM_LIT:1>)[<NUM_LIT:0>]<EOL>if chrom_re.match(chrom) is None:<EOL><INDENT>logger.info('<STR_LIT>', chrom)<EOL>continue<EOL><DEDENT>seq.name = chrom<EOL>seq.append_fasta(ofh)<EOL><DEDENT><DEDENT>return <NUM_LIT:0><EOL>
Script body.