Commit a4818eaf by Eric Coissac

Patch logging from stderr to logger in scaffold

parent cf3897ec
......@@ -30,6 +30,11 @@ from time import time
import math
from functools import reduce
def logOrPrint(logger,message,level='info'):
if logger is not None:
getattr(logger, level)(message)
else:
print(message,file=sys.stderr)
def cutLowCoverage(self,mincov,terminal=True):
'''
......@@ -300,7 +305,7 @@ def genesincontig(cg,index,matches):
def scaffold(self,assgraph,minlink=5,back=200,addConnectedLink=False):
def scaffold(self,assgraph,minlink=5,back=200,addConnectedLink=False,forcedLink=set(),logger=None):
'''
Add relationships between edges of the assembling graph related to the
par ended links.
......@@ -355,15 +360,25 @@ def scaffold(self,assgraph,minlink=5,back=200,addConnectedLink=False):
if connected and addConnectedLink:
if linkedby >= minlink:
s.append(('l',et[e1][1],ei[e2][0],linkedby,etid[e1], eiid[e2],"#00FF00",ml,sl,delta,first,last))
print("%d -> %d connection asserted by %d pair ended links" % (etid[e1], eiid[e2],linkedby),
file=sys.stderr)
logOrPrint(logger,
"%d -> %d connection asserted by %d pair ended links" % (etid[e1], eiid[e2],linkedby))
else:
print("%d -> %d connection not asserted by pair ended link" % (etid[e1], eiid[e2]),
file=sys.stderr)
if not connected and linkedby >= minlink:
s.append(('s',et[e1][1],ei[e2][0],linkedby,etid[e1], eiid[e2],"#FF0000",ml,sl,delta,first,last))
print("%d -> %d scaffolded by %d pair ended links" % (etid[e1], eiid[e2],linkedby),
file=sys.stderr)
logOrPrint(logger,
"%d -> %d connection not asserted by pair ended link" % (etid[e1], eiid[e2]))
elif not connected and (etid[e1], eiid[e2]) in forcedLink:
s.append(('f',et[e1][1],ei[e2][0],linkedby,etid[e1], eiid[e2],"#FF0000",ml,sl,delta,first,last))
if linkedby > 0:
logOrPrint(logger,
"%d -> %d forced but supported by %d pair ended links" % (etid[e1], eiid[e2],linkedby))
else:
logOrPrint(logger,
"%d -> %d forced and not supported by pair ended links" % (etid[e1], eiid[e2]))
elif not connected and linkedby >= minlink:
s.append(('s',et[e1][1],ei[e2][0],linkedby,etid[e1], eiid[e2],"#FF6600",ml,sl,delta,first,last))
logOrPrint(logger,
"%d -> %d scaffolded by %d pair ended links" % (etid[e1], eiid[e2],linkedby))
nstemid={}
for kind,x,y,z,s1,s2,color,ml,sl,delta,first,last in s:
if (abs(x) > abs(y)):
......@@ -409,6 +424,23 @@ def scaffold(self,assgraph,minlink=5,back=200,addConnectedLink=False):
attr['sequence']=b"N" * attr['length']
attr['path']=[first] + [0] * (attr['length']-1) + [last]
attr['class']='scaffold:paired-end'
elif kind=="f":
attr['label']="%d : Forced [%d] %d -> %d" % (nid,z,s1,s2)
attr['length']= 10
attr['first']=first
attr['last']=last
attr['weight']=0
attr['pairendlink']=z
attr['ingene']=0
attr['graphics']={'width':z // 10.,
'arrow':'last',
'fill':color
}
attr['stemid']=nid
attr['sequence']=b"N" * attr['length']
attr['path']=[first] + [0] * (attr['length']-1) + [last]
attr['class']='scaffold:forced'
else:
attr['class']='internal'
......
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