def scaffolds_to_contigs(infile, outfile, number_contigs=False):
seq_reader = sequences.file_reader(infile)<EOL>fout = utils.open_file_write(outfile)<EOL>for seq in seq_reader:<EOL><INDENT>contigs = seq.contig_coords()<EOL>counter = <NUM_LIT:1><EOL>for contig in contigs:<EOL><INDENT>if number_contigs:<EOL><INDENT>name = seq.id + '<STR_LIT:.>' + str(counter)<EOL>counter += <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>name = '<STR_LIT:.>'.join([seq.id, str(contig.start + <NUM_LIT:1>), str(contig.end + <NUM_LIT:1>)])<EOL><DEDENT>print(sequences.Fasta(name, seq[contig.start:contig.end+<NUM_LIT:1>]), file=fout)<EOL><DEDENT><DEDENT>utils.close(fout)<EOL>
Makes a file of contigs from scaffolds by splitting at every N.
       Use number_contigs=True to add .1, .2, etc onto end of each
       contig, instead of default to append coordinates.