Skip to content

Commit 6eb8b6e

Browse files
committed
DEV: Major code refactoring and fix #17
1 parent d9307c3 commit 6eb8b6e

File tree

4 files changed

+628
-459
lines changed

4 files changed

+628
-459
lines changed

graphbin2

Lines changed: 53 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,36 @@ __email__ = "[email protected]"
1818
__status__ = "Stable Release"
1919

2020

21+
class ArgsObj:
22+
def __init__(
23+
self,
24+
assembler,
25+
graph,
26+
contigs,
27+
paths,
28+
abundance,
29+
binned,
30+
output,
31+
prefix,
32+
depth,
33+
threshold,
34+
delimiter,
35+
nthreads
36+
):
37+
self.assembler = assembler
38+
self.graph = graph
39+
self.contigs = contigs
40+
self.paths = paths
41+
self.abundance = abundance
42+
self.binned = binned
43+
self.output = output
44+
self.prefix = prefix
45+
self.depth = depth
46+
self.threshold = threshold
47+
self.delimiter = delimiter
48+
self.nthreads = nthreads
49+
50+
2151
@click.command()
2252
@click.option(
2353
"--assembler",
@@ -99,6 +129,7 @@ __status__ = "Stable Release"
99129
show_default=True,
100130
required=False,
101131
)
132+
@click.version_option(__version__, "-v", "--version", is_flag=True)
102133
def main(
103134
assembler,
104135
graph,
@@ -116,6 +147,9 @@ def main(
116147

117148
"""
118149
GraphBin2: Refined and Overlapped Binning of Metagenomic Contigs Using Assembly Graphs
150+
GraphBin2 is a tool which refines the binning results obtained from existing tools and, is able to
151+
assign contigs to multiple bins. GraphBin2 uses the connectivity and coverage information from
152+
assembly graphs to adjust existing binning results on contigs and to infer contigs shared by multiple species.
119153
"""
120154

121155
assembly_graph_file = graph
@@ -215,54 +249,33 @@ def main(
215249

216250
logger.info("GraphBin2 started")
217251

252+
# Make args object
253+
args = ArgsObj(
254+
assembler,
255+
graph,
256+
contigs,
257+
paths,
258+
abundance,
259+
binned,
260+
output,
261+
prefix,
262+
depth,
263+
threshold,
264+
delimiter,
265+
nthreads
266+
)
267+
218268

219269
# Run GraphBin2
220270
#---------------------------------------------------
221271
if assembler.lower() == "spades":
222-
cmdGraphBin2 = """python "{0}/src/graphbin2_SPAdes.py" --graph "{1}" --contigs "{2}" --paths "{3}" --binned "{4}" --output "{5}" --prefix "{6}" --depth "{7}" --threshold "{8}" --delimiter "{9}" --nthreads "{10}" """.format(
223-
os.path.dirname(__file__),
224-
assembly_graph_file,
225-
contigs,
226-
contig_paths,
227-
contig_bins_file,
228-
output_path,
229-
prefix,
230-
depth,
231-
threshold,
232-
delimiter,
233-
nthreads)
272+
graphbin2_SPAdes.main(args)
234273

235274
elif assembler.lower() == "sga":
236-
cmdGraphBin2 = """python "{0}/src/graphbin2_SGA.py" --graph "{1}" --contigs "{2}" --binned "{3}" --abundance "{4}" --output "{5}" --prefix "{6}" --depth "{7}" --threshold "{8}" --delimiter "{9}" --nthreads "{10}" """.format(
237-
os.path.dirname(__file__),
238-
assembly_graph_file,
239-
contigs,
240-
contig_bins_file,
241-
abundance,
242-
output_path,
243-
prefix,
244-
depth,
245-
threshold,
246-
delimiter,
247-
nthreads)
275+
graphbin2_SGA.main(args)
248276

249277
elif assembler.lower() == "flye":
250-
cmdGraphBin2 = """python "{0}/src/graphbin2_Flye.py" --graph "{1}" --contigs "{2}" --paths "{3}" --binned "{4}" --abundance "{5}" --output "{6}" --prefix "{7}" --depth "{8}" --threshold "{9}" --delimiter "{10}" --nthreads "{11}" """.format(
251-
os.path.dirname(__file__),
252-
assembly_graph_file,
253-
contigs,
254-
contig_paths,
255-
contig_bins_file,
256-
abundance,
257-
output_path,
258-
prefix,
259-
depth,
260-
threshold,
261-
delimiter,
262-
nthreads)
263-
264-
265-
os.system(cmdGraphBin2)
278+
graphbin2_Flye.main(args)
266279

267280

268281
if __name__ == "__main__":

0 commit comments

Comments
 (0)