Commit 678d54be by Eric Coissac

Use logger instead of direct print to stderr

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