Commit ec2c66d4 by Eric Coissac

Finalize the interface with the user

parent bf597793
......@@ -8,10 +8,12 @@ from orgasm.tango import restoreGraph, estimateFragmentLength, genesincontig,\
scaffold, pairEndedConnected
from orgasm.version import version
import pathlib
import sys
__title__="Build a graph file from the assembling graph"
default_config = {
default_config = { 'format': 'gml'
}
def addOptions(parser):
......@@ -22,7 +24,29 @@ def addOptions(parser):
nargs='?',
default=None,
help='output prefix' )
parser.add_argument('--gml', dest='graph:format',
action='store_const',
const='gml',
default=None,
help="Write the assembling graph in gml format [default]")
parser.add_argument('--gml-path', dest='graph:format',
action='store_const',
const='gmlpath',
default=None,
help="Write the assembling graph in gml format with "
"the indication of the last exported sequence path")
parser.add_argument('--lastgraph', dest='graph:format',
action='store_const',
const='lastgraph',
default=None,
help="Write the assembling graph in lastgraph format (Velvet). "
"This format is readable by the Bandage visualizer")
parser.add_argument('--back', dest='orgasm:back',
metavar='<insert size>',
type=int,
......@@ -36,7 +60,6 @@ def addOptions(parser):
def compactGraph2lastgraph(asm,paths=[],minlink=5,back=250):
#FASTG:begin;
#FASTG:version=1.0:assembly_name=”tiny example”;
cg = asm.compactAssembling(verbose=False)
genesincontig(cg,asm.index,asm.seeds)
......@@ -165,32 +188,48 @@ def compactGraph2gfa(cg,paths=[]):
print(begins)
print(ends)
def cat(filename):
with open(filename,'r') as f:
for line in f:
print(line)
def run(config):
logger=config['orgasm']['logger']
output = getOutput(config)
r = getIndex(config)
ecoverage,seeds,newprobes = getSeeds(r,config) # @UnusedVariable
asm = restoreGraph(output+'.oax',r,seeds)
logger.info("Evaluate fragment length")
if not pathlib.Path(output+'.gml').is_file():
logger.error("No assembly graph available")
sys.exit(1)
if config['graph']['format']=='gml':
cat(output+'.gml')
elif config['graph']['format']=='gmlpath':
if pathlib.Path(output+'.path.gml').is_file():
cat(output+'.path.gml')
else:
cat(output+'.gml')
elif config['graph']['format']=='lastgraph':
r = getIndex(config)
ecoverage,seeds,newprobes = getSeeds(r,config) # @UnusedVariable
asm = restoreGraph(output+'.oax',r,seeds)
meanlength,sdlength = estimateFragmentLength(asm)
logger.info("Evaluate fragment length")
meanlength,sdlength = estimateFragmentLength(asm)
if meanlength is not None:
logger.info("Fragment length estimated : %f pb (sd: %f)" % (meanlength,sdlength))
if meanlength is not None:
logger.info("Fragment length estimated : %f pb (sd: %f)" % (meanlength,sdlength))
if config['orgasm']['back'] is not None:
back = config['orgasm']['back']
elif config['orgasm']['back'] is None and meanlength is not None:
back = int(meanlength + 4 * sdlength)
if back > 500:
back=500
else:
back = 300
compactGraph2lastgraph(asm)
if config['orgasm']['back'] is not None:
back = config['orgasm']['back']
elif config['orgasm']['back'] is None and meanlength is not None:
back = int(meanlength + 4 * sdlength)
if back > 500:
back=500
else:
back = 300
compactGraph2lastgraph(asm)
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