def to_fastg(infile, outfile, circular=None):
if circular is None:<EOL><INDENT>to_circularise = set()<EOL><DEDENT>elif type(circular) is not set:<EOL><INDENT>f = utils.open_file_read(circular)<EOL>to_circularise = set([x.rstrip() for x in f.readlines()])<EOL>utils.close(f)<EOL><DEDENT>else:<EOL><INDENT>to_circularise = circular<EOL><DEDENT>seq_reader = sequences.file_reader(infile)<EOL>fout = utils.open_file_write(outfile)<EOL>nodes = <NUM_LIT:1><EOL>for seq in seq_reader:<EOL><INDENT>new_id = '<STR_LIT:_>'.join([<EOL>'<STR_LIT>', str(nodes),<EOL>'<STR_LIT>', str(len(seq)),<EOL>'<STR_LIT>', '<STR_LIT:1>',<EOL>'<STR_LIT>', seq.id<EOL>])<EOL>if seq.id in to_circularise:<EOL><INDENT>seq.id = new_id + '<STR_LIT::>' + new_id + '<STR_LIT:;>'<EOL>print(seq, file=fout)<EOL>seq.revcomp()<EOL>seq.id = new_id + "<STR_LIT>" + new_id + "<STR_LIT>"<EOL>print(seq, file=fout)<EOL><DEDENT>else:<EOL><INDENT>seq.id = new_id + '<STR_LIT:;>'<EOL>print(seq, file=fout)<EOL>seq.revcomp()<EOL>seq.id = new_id + "<STR_LIT>"<EOL>print(seq, file=fout)<EOL><DEDENT>nodes += <NUM_LIT:1><EOL><DEDENT>utils.close(fout)<EOL>
Writes a FASTG file in SPAdes format from input file. Currently only whether or not a sequence is circular is supported. Put circular=set of ids, or circular=filename to make those sequences circular in the output. Puts coverage=1 on all contigs