corrected save_contigs function
parent
2245289d91
commit
1d75d1417c
|
|
@ -1,6 +1,7 @@
|
|||
"""
|
||||
Small assembly module based on de bruijn graphs
|
||||
"""
|
||||
import os
|
||||
import networkx as nx
|
||||
from networkx import algorithms
|
||||
|
||||
|
|
@ -113,6 +114,9 @@ def remove_paths():
|
|||
def select_best_path():
|
||||
pass
|
||||
|
||||
def fill(text, width=80):
|
||||
"""Split text with a line return to respect fasta format"""
|
||||
return os.linesep.join(text[i:i+width] for i in range(0, len(text), width))
|
||||
|
||||
def save_contigs(tuples, outname):
|
||||
"""
|
||||
|
|
@ -120,9 +124,12 @@ def save_contigs(tuples, outname):
|
|||
tuples, tuple: Obtained from get_contigs()
|
||||
outname, str: name of the file to be written
|
||||
"""
|
||||
i = 0
|
||||
with open(outname, "w") as outfile:
|
||||
for duo in tuples:
|
||||
outfile.write("{} {}".format(duo[0], duo[1]))
|
||||
i += 1
|
||||
outfile.write(">contig_{} len={}\n".format(i, duo[1]))
|
||||
outfile.write("{}\n".format(fill(duo[0])))
|
||||
|
||||
return
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue