Commit 678d54be by Eric Coissac

Use logger instead of direct print to stderr

parent 3d4c982e
...@@ -6,10 +6,10 @@ from orgasm.indexer._orgasm cimport * ...@@ -6,10 +6,10 @@ from orgasm.indexer._orgasm cimport *
from ._asmbgraph cimport * from ._asmbgraph cimport *
from ._assembler cimport * from ._assembler cimport *
from orgasm.graph._graphmultiedge cimport * from orgasm.graph._graphmultiedge cimport *
from functools import reduce from functools import reduce
from orgasm.apps.progress cimport ProgressBar from orgasm.apps.progress cimport ProgressBar
from orgasm.apps.config cimport getConfiguration
from orgasm.utils.dna cimport reverseComplement from orgasm.utils.dna cimport reverseComplement
import math import math
...@@ -219,10 +219,8 @@ cpdef dict buildstem(Assembler assembler, ...@@ -219,10 +219,8 @@ cpdef dict buildstem(Assembler assembler,
} }
if circle: if circle:
print(" Circle : %6d bp coverage : %6dx" % getConfiguration()['orgasm']['logger'].info(" Circle : %6d bp coverage : %6dx" %
(length,int(w)), (length,int(w)))
file=sys.stderr
)
return s return s
...@@ -249,7 +247,10 @@ cdef class CompactAssembling(DiGraphMultiEdge): ...@@ -249,7 +247,10 @@ cdef class CompactAssembling(DiGraphMultiEdge):
cdef double minweight cdef double minweight
cdef AsmbGraph graph cdef AsmbGraph graph
cdef dict stem cdef dict stem
cdef dict config=getConfiguration()
logger = config['orgasm']['logger']
DiGraphMultiEdge.__init__(self,'compact') DiGraphMultiEdge.__init__(self,'compact')
self._paths={} self._paths={}
...@@ -262,7 +263,7 @@ cdef class CompactAssembling(DiGraphMultiEdge): ...@@ -262,7 +263,7 @@ cdef class CompactAssembling(DiGraphMultiEdge):
if verbose: if verbose:
print("Compacting graph :",file=sys.stderr) logger.info("Compacting graph :")
else: else:
progress = ProgressBar(lgraph, progress = ProgressBar(lgraph,
head="Compacting graph", head="Compacting graph",
...@@ -282,17 +283,15 @@ cdef class CompactAssembling(DiGraphMultiEdge): ...@@ -282,17 +283,15 @@ cdef class CompactAssembling(DiGraphMultiEdge):
minweight=weight minweight=weight
if verbose: if verbose:
print(" Stem : %6d bp (total : %6d) coverage : %6.2f" % (stem['length'], logger.info(" Stem : %6d bp (total : %6d) coverage : %6.2f" % (stem['length'],
lcontig, lcontig,
weight), weight))
file=sys.stderr)
else: else:
progress(lcontig) progress(lcontig)
self.setStemid() self.setStemid()
print("\nMinimum stem coverage = %d" % int(minweight), logger.info("Minimum stem coverage = %d" % int(minweight))
file=sys.stderr)
...@@ -593,20 +592,23 @@ cdef class Assembler: ...@@ -593,20 +592,23 @@ cdef class Assembler:
cdef int32_t i # @DuplicatedSignature cdef int32_t i # @DuplicatedSignature
cdef set ep cdef set ep
cdef set sp cdef set sp
graph=self.graph graph=self.graph
cd=0 cd=0
d=1 d=1
print('',file=sys.stderr) if sys.stderr.isatty():
print('',file=sys.stderr)
while d > 0: while d > 0:
d=0 d=0
for i in self.endNodeSet(alllink=alllink): for i in self.endNodeSet(alllink=alllink):
print("Remaining edges : %d node : %d" % (graph.edgeCount(),len(graph)), if sys.stderr.isatty():
end='\r', print("Remaining edges : %d node : %d" % (graph.edgeCount(),len(graph)),
file=sys.stderr) end='\r',
file=sys.stderr)
d+=deleteBranch(graph,[i],maxlength) d+=deleteBranch(graph,[i],maxlength)
cd+=d cd+=d
...@@ -620,9 +622,10 @@ cdef class Assembler: ...@@ -620,9 +622,10 @@ cdef class Assembler:
except KeyError: except KeyError:
pass pass
print ("Remaining edges : %d node : %d" % (graph.edgeCount(),len(graph)), if sys.stderr.isatty():
end='\r', print ("Remaining edges : %d node : %d" % (graph.edgeCount(),len(graph)),
file=sys.stderr) end='\r',
file=sys.stderr)
return cd return cd
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment