Skip to content

Commit

Permalink
Minor refactors and fixing error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Vini2 committed Jul 18, 2020
1 parent a432719 commit 3ebfb46
Show file tree
Hide file tree
Showing 18 changed files with 53 additions and 190 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*/**/__pycache__/
*.py[cod]
*$py.class

Expand Down
Empty file added __init__.py
Empty file.
27 changes: 19 additions & 8 deletions bin/graphbin → graphbin
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import argparse
import os
import sys

from graphbin import (
from graphbin_utils import (
graphbin_Options,
graphbin_Canu,
graphbin_Flye,
Expand Down Expand Up @@ -44,6 +44,7 @@ def main():
"--assembler",
type=str,
help="name of the assembler used (SPAdes, SGA or MEGAHIT). GraphBin supports Flye, Canu and Miniasm long-read assemblies as well.",
default=""
)
parser.add_argument(
"--paths",
Expand All @@ -61,6 +62,9 @@ def main():
# Validation of inputs
# ---------------------------------------------------
# Check assembler type
if len(sys.argv)==1:
parser.print_help(sys.stderr)
sys.exit(1)
if not (
args.assembler.lower() == "spades"
or args.assembler.lower() == "sga"
Expand All @@ -72,31 +76,36 @@ def main():
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")

print("\nExiting 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")

print("\nExiting 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")

print("\nExiting 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")

print("\nExiting 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")

print("\nExiting GraphBin...\nBye...!\n")
sys.exit(1)

# Handle for missing trailing forwardslash in output folder path
Expand All @@ -114,13 +123,15 @@ def main():
# Validate max_iteration
if args.max_iteration <= 0:
print("\nPlease enter a valid number for max_iteration")
print("Exiting GraphBin...\nBye...!\n")

print("\nExiting 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")

print("\nExiting GraphBin...\nBye...!\n")
sys.exit(1)

# Run GraphBin
Expand Down
Empty file added graphbin_utils/__init__.py
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

"""
This code is used from the source found at
Expand Down
8 changes: 4 additions & 4 deletions graphbin/graphbin_Canu.py → graphbin_utils/graphbin_Canu.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
import logging

from igraph import *
from graphbin.labelpropagation.labelprop import LabelProp
from graphbin.bidirectionalmap.bidirectionalmap import BidirectionalMap
from graphbin.graphbin_Func import getClosestLabelledVertices
from graphbin.graphbin_Options import PARSER
from graphbin_utils.labelpropagation.labelprop import LabelProp
from graphbin_utils.bidirectionalmap.bidirectionalmap import BidirectionalMap
from graphbin_utils.graphbin_Func import getClosestLabelledVertices
from graphbin_utils.graphbin_Options import PARSER

# Sample command
# -------------------------------------------------------------------
Expand Down
8 changes: 4 additions & 4 deletions graphbin/graphbin_Flye.py → graphbin_utils/graphbin_Flye.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
import logging

from igraph import *
from graphbin.labelpropagation.labelprop import LabelProp
from graphbin.bidirectionalmap.bidirectionalmap import BidirectionalMap
from graphbin.graphbin_Func import getClosestLabelledVertices
from graphbin.graphbin_Options import PARSER
from graphbin_utils.labelpropagation.labelprop import LabelProp
from graphbin_utils.bidirectionalmap.bidirectionalmap import BidirectionalMap
from graphbin_utils.graphbin_Func import getClosestLabelledVertices
from graphbin_utils.graphbin_Options import PARSER


# Sample command
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
import logging

from igraph import *
from graphbin.labelpropagation.labelprop import LabelProp
from graphbin.bidirectionalmap.bidirectionalmap import BidirectionalMap
from graphbin.graphbin_Func import getClosestLabelledVertices
from graphbin.graphbin_Options import PARSER
from graphbin_utils.labelpropagation.labelprop import LabelProp
from graphbin_utils.bidirectionalmap.bidirectionalmap import BidirectionalMap
from graphbin_utils.graphbin_Func import getClosestLabelledVertices
from graphbin_utils.graphbin_Options import PARSER

# Sample command
# -------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
import logging

from igraph import *
from graphbin.labelpropagation.labelprop import LabelProp
from graphbin.bidirectionalmap.bidirectionalmap import BidirectionalMap
from graphbin.graphbin_Func import getClosestLabelledVertices
from graphbin.graphbin_Options import PARSER
from graphbin_utils.labelpropagation.labelprop import LabelProp
from graphbin_utils.bidirectionalmap.bidirectionalmap import BidirectionalMap
from graphbin_utils.graphbin_Func import getClosestLabelledVertices
from graphbin_utils.graphbin_Options import PARSER


# Sample command
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions graphbin/graphbin_SGA.py → graphbin_utils/graphbin_SGA.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
import logging

from igraph import *
from graphbin.labelpropagation.labelprop import LabelProp
from graphbin.bidirectionalmap.bidirectionalmap import BidirectionalMap
from graphbin.graphbin_Func import getClosestLabelledVertices
from graphbin.graphbin_Options import PARSER
from graphbin_utils.labelpropagation.labelprop import LabelProp
from graphbin_utils.bidirectionalmap.bidirectionalmap import BidirectionalMap
from graphbin_utils.graphbin_Func import getClosestLabelledVertices
from graphbin_utils.graphbin_Options import PARSER


# Sample command
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
from igraph import *
from collections import defaultdict

from graphbin.labelpropagation.labelprop import LabelProp
from graphbin.bidirectionalmap.bidirectionalmap import BidirectionalMap
from graphbin.graphbin_Func import getClosestLabelledVertices
from graphbin.graphbin_Options import PARSER
from graphbin_utils.labelpropagation.labelprop import LabelProp
from graphbin_utils.bidirectionalmap.bidirectionalmap import BidirectionalMap
from graphbin_utils.graphbin_Func import getClosestLabelledVertices
from graphbin_utils.graphbin_Options import PARSER

# Sample command
# -------------------------------------------------------------------
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

"""
This code has been modified from the source found at https://github.com/ZwEin27/python-labelpropagation
Expand Down
14 changes: 7 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#!/usr/bin/env python3

import os
from setuptools import setup
from setuptools import setup, find_packages

with open("README.md") as f:
long_description = f.read()

packages = ["graphbin"]
packages = find_packages()
package_data = {
"graphbin": [
"graphbin/*.py",
"graphbin/bidirectionalmap/*.py",
"graphbin/labelpropagation/*.py",
"graphbin_utils": [
"graphbin_utils/*.py",
"graphbin_utils/bidirectionalmap/*.py",
"graphbin_utils/labelpropagation/*.py",
]
}
data_files = [(".", ["LICENSE", "README.md"])]
Expand All @@ -25,7 +25,7 @@
package_data=package_data,
data_files=data_files,
include_package_data=True,
scripts=['bin/graphbin'],
scripts=['graphbin'],
url='https://github.com/Vini2/graphbin',
license='GPLv2',
long_description_content_type="text/markdown",
Expand Down
149 changes: 0 additions & 149 deletions test_data/ES_metaSPAdes/maxbin_graphbin_output.csv

This file was deleted.

0 comments on commit 3ebfb46

Please sign in to comment.