corrected save_contigs function
parent
2245289d91
commit
1d75d1417c
|
|
@ -1,6 +1,7 @@
|
||||||
"""
|
"""
|
||||||
Small assembly module based on de bruijn graphs
|
Small assembly module based on de bruijn graphs
|
||||||
"""
|
"""
|
||||||
|
import os
|
||||||
import networkx as nx
|
import networkx as nx
|
||||||
from networkx import algorithms
|
from networkx import algorithms
|
||||||
|
|
||||||
|
|
@ -113,6 +114,9 @@ def remove_paths():
|
||||||
def select_best_path():
|
def select_best_path():
|
||||||
pass
|
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):
|
def save_contigs(tuples, outname):
|
||||||
"""
|
"""
|
||||||
|
|
@ -120,9 +124,12 @@ def save_contigs(tuples, outname):
|
||||||
tuples, tuple: Obtained from get_contigs()
|
tuples, tuple: Obtained from get_contigs()
|
||||||
outname, str: name of the file to be written
|
outname, str: name of the file to be written
|
||||||
"""
|
"""
|
||||||
|
i = 0
|
||||||
with open(outname, "w") as outfile:
|
with open(outname, "w") as outfile:
|
||||||
for duo in tuples:
|
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
|
return
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue