-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from alienzj/modular
Modular
- Loading branch information
Showing
20 changed files
with
3,465 additions
and
3,585 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
include *.md | ||
include LICENSE | ||
|
||
include bin/graphbin | ||
|
||
recursive-include graphbin/ * | ||
recursive-include graphbin/bidirectionalmap * | ||
recursive-include graphbin/labelpropagation * | ||
|
||
global-exclude graphbin/ *.pyc | ||
global-exclude graphbin/__pycache__ *.pyc | ||
global-exclude graphbin/bidirectionalmap *.pyc | ||
global-exclude graphbin/bidirectionalmap/__pycache__ *.pyc | ||
global-exclude graphbin/labelpropagation *.pyc | ||
global-exclude graphbin/labelpropagation/__pycache__ *.pyc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
#!/usr/bin/env python3 | ||
|
||
"""graphbin: Refined binning of metagenomic contigs using assembly graphs.""" | ||
|
||
import argparse | ||
import os | ||
import sys | ||
|
||
from graphbin import ( | ||
graphbin_Options, | ||
graphbin_Canu, | ||
graphbin_Flye, | ||
graphbin_MEGAHIT, | ||
graphbin_Miniasm, | ||
graphbin_SGA, | ||
graphbin_SPAdes, | ||
) | ||
|
||
__author__ = "Vijini Mallawaarachchi, Anuradha Wickramarachchi, and Yu Lin" | ||
__copyright__ = "Copyright 2020, GraphBin Project" | ||
__credits__ = "Benjamin Kaehler and Gavin Huttley" | ||
__license__ = "GPL" | ||
__version__ = "1.1" | ||
__maintainer__ = "Vijini Mallawaarachchi" | ||
__email__ = "[email protected]" | ||
__status__ = "Stable Release" | ||
|
||
|
||
def run(args): | ||
RUNNER = { | ||
"canu": graphbin_Canu.run, | ||
"flye": graphbin_Flye.run, | ||
"megahit": graphbin_MEGAHIT.run, | ||
"miniasm": graphbin_Miniasm.run, | ||
"sga": graphbin_SGA.run, | ||
"spades": graphbin_SPAdes.run, | ||
} | ||
RUNNER[args.assembler](args) | ||
|
||
|
||
def main(): | ||
parser = graphbin_Options.PARSER | ||
parser.add_argument( | ||
"--assembler", | ||
type=str, | ||
help="name of the assembler used (SPAdes, SGA or MEGAHIT). GraphBin supports Flye, Canu and Miniasm long-read assemblies as well.", | ||
) | ||
parser.add_argument( | ||
"--paths", | ||
default=None, | ||
required=False, | ||
help="path to the contigs.paths file, only SPAdes need", | ||
) | ||
|
||
args = parser.parse_args() | ||
|
||
if args.version: | ||
print("GraphBin version %s" % __version__) | ||
sys.exit(0) | ||
|
||
# Validation of inputs | ||
# --------------------------------------------------- | ||
# Check assembler type | ||
if not ( | ||
args.assembler.lower() == "spades" | ||
or args.assembler.lower() == "sga" | ||
or args.assembler.lower() == "megahit" | ||
or args.assembler.lower() == "flye" | ||
or args.assembler.lower() == "canu" | ||
or args.assembler.lower() == "miniasm" | ||
): | ||
print( | ||
"\nPlease make sure to provide the correct assembler type (SPAdes, SGA or MEGAHIT). GraphBin supports Flye, Canu and Miniasm long-read assemblies as well." | ||
) | ||
print("Exiting GraphBin...\nBye...!\n") | ||
sys.exit(1) | ||
|
||
# Check assembly graph file | ||
if not os.path.isfile(args.graph): | ||
print("\nFailed to open the assembly graph file.") | ||
print("Exiting GraphBin...\nBye...!\n") | ||
sys.exit(1) | ||
|
||
# Check if paths files is provided when the assembler type is SPAdes | ||
if args.assembler.lower() == "spades" and args.paths is None: | ||
print("\nPlease make sure to provide the path to the contigs.paths file.") | ||
print("Exiting GraphBin...\nBye...!\n") | ||
sys.exit(1) | ||
|
||
# Check contigs.paths file for SPAdes | ||
if args.assembler.lower() == "spades" and not os.path.isfile(args.paths): | ||
print("\nFailed to open the contigs.paths file.") | ||
print("Exiting GraphBin...\nBye...!\n") | ||
sys.exit(1) | ||
|
||
# Check the file with the initial binning output | ||
if not os.path.isfile(args.binned): | ||
print("\nFailed to open the file with the initial binning output.") | ||
print("Exiting GraphBin...\nBye...!\n") | ||
sys.exit(1) | ||
|
||
# Handle for missing trailing forwardslash in output folder path | ||
if args.output[-1:] != "/": | ||
args.output = args.output + "/" | ||
|
||
# Create output folder if it does not exist | ||
os.makedirs(args.output, exist_ok=True) | ||
|
||
# Validate prefix | ||
if args.prefix != "": | ||
if not args.prefix.endswith("_"): | ||
args.prefix = args.prefix + "_" | ||
|
||
# Validate max_iteration | ||
if args.max_iteration <= 0: | ||
print("\nPlease enter a valid number for max_iteration") | ||
print("Exiting GraphBin...\nBye...!\n") | ||
sys.exit(1) | ||
|
||
# Validate diff_threshold | ||
if args.diff_threshold < 0: | ||
print("\nPlease enter a valid number for diff_threshold") | ||
print("Exiting GraphBin...\nBye...!\n") | ||
sys.exit(1) | ||
|
||
# Run GraphBin | ||
# --------------------------------------------------- | ||
run(args) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
Oops, something went wrong.