def create_input_peptides_files(<EOL>peptides,<EOL>max_peptides_per_file=None,<EOL>group_by_length=False):
if group_by_length:<EOL><INDENT>peptide_lengths = {len(p) for p in peptides}<EOL>peptide_groups = {l: [] for l in peptide_lengths}<EOL>for p in peptides:<EOL><INDENT>peptide_groups[len(p)].append(p)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>peptide_groups = {"<STR_LIT>": peptides}<EOL><DEDENT>file_names = []<EOL>for key, group in peptide_groups.items():<EOL><INDENT>n_peptides = len(group)<EOL>if not max_peptides_per_file:<EOL><INDENT>max_peptides_per_file = n_peptides<EOL><DEDENT>input_file = None<EOL>for i, p in enumerate(group):<EOL><INDENT>if i % max_peptides_per_file == <NUM_LIT:0>:<EOL><INDENT>if input_file is not None:<EOL><INDENT>file_names.append(input_file.name)<EOL>input_file.close()<EOL><DEDENT>input_file = make_writable_tempfile(<EOL>prefix_number=i // max_peptides_per_file,<EOL>prefix_name=key,<EOL>suffix="<STR_LIT>")<EOL><DEDENT>input_file.write("<STR_LIT>" % p)<EOL><DEDENT>if input_file is not None:<EOL><INDENT>file_names.append(input_file.name)<EOL>input_file.close()<EOL><DEDENT><DEDENT>return file_names<EOL>
Creates one or more files containing one peptide per line,
returns names of files.