Skip to content

Commit

Permalink
MAINT: code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Vini2 committed Aug 15, 2024
1 parent 74924ae commit 96d00fd
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 24 deletions.
6 changes: 5 additions & 1 deletion src/gbintk/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,11 @@ def visualise(
)
logger.info("Running Visualisation for binning and refinement results...")

from gbintk.support import visualise_result_MEGAHIT, visualise_result_SPAdes, visualise_result_Flye
from gbintk.support import (
visualise_result_Flye,
visualise_result_MEGAHIT,
visualise_result_SPAdes,
)

# Make args class
class VizArgsObj:
Expand Down
8 changes: 4 additions & 4 deletions src/gbintk/support/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def run(args):

all_ground_truth_bins_list = []

with open(ground_truth_file) as csvfile:
with open(ground_truth_file, mode="r") as csvfile:
readCSV = csv.reader(csvfile, delimiter=delimiter)
for row in readCSV:
all_ground_truth_bins_list.append(row[1])
Expand All @@ -81,7 +81,7 @@ def run(args):
ground_truth_count = 0
ground_truth_bins_1 = {}

with open(ground_truth_file) as contig_bins:
with open(ground_truth_file, mode="r") as contig_bins:
readCSV = csv.reader(contig_bins, delimiter=delimiter)

for row in readCSV:
Expand All @@ -101,7 +101,7 @@ def run(args):

all_bins_list = []

with open(binned_file) as csvfile:
with open(binned_file, mode="r") as csvfile:
readCSV = csv.reader(csvfile, delimiter=delimiter)

for row in readCSV:
Expand All @@ -121,7 +121,7 @@ def run(args):
binned_count = 0
binned_contigs = []

with open(binned_file) as contig_bins:
with open(binned_file, mode="r") as contig_bins:
readCSV = csv.reader(contig_bins, delimiter=delimiter)
for row in readCSV:
binned_count += 1
Expand Down
15 changes: 6 additions & 9 deletions src/gbintk/support/visualise_result_Flye.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ def run(args):
logger.info(f"Size of the margin: {margin} pt")
logger.info(f"Delimiter: {delimiter}")


# Get the number of bins from the initial binning result
# ---------------------------------------------------

Expand All @@ -124,7 +123,6 @@ def run(args):
logger.info("Exiting visualiser... Bye...!")
sys.exit(1)


logger.info("Constructing the assembly graph...")

# Get contig names
Expand Down Expand Up @@ -303,7 +301,6 @@ def run(args):

logger.info(f"Total number of edges in the assembly graph: {len(edge_list)}")


# Get initial binning result
# ----------------------------

Expand All @@ -330,7 +327,6 @@ def run(args):
logger.info("Exiting visualiser... Bye...!")
sys.exit(1)


# Get list of colours according to number of bins
# -------------------------------------------------

Expand Down Expand Up @@ -361,11 +357,12 @@ def run(args):
"#000000",
]


# Visualise the initial assembly graph
# --------------------------------------

logger.info("Drawing and saving the assembly graph with the initial binning result...")
logger.info(
"Drawing and saving the assembly graph with the initial binning result..."
)

initial_out_fig_name = f"{output_path}{prefix}initial_binning_result.{image_type}"

Expand Down Expand Up @@ -405,7 +402,6 @@ def run(args):
# Plot the graph
plot(assembly_graph, initial_out_fig_name, **visual_style)


# Get the final GraphBin binning result
# ---------------------------------------

Expand All @@ -432,15 +428,16 @@ def run(args):
logger.info("Exiting visualiseResult... Bye...!")
sys.exit(1)


# Visualise the final assembly graph
# ------------------------------------

print(
"Drawing and saving the assembly graph with the final GraphBin binning result..."
)

final_out_fig_name = f"{output_path}{prefix}final_GraphBin_binning_result.{image_type}"
final_out_fig_name = (
f"{output_path}{prefix}final_GraphBin_binning_result.{image_type}"
)

node_colours = []

Expand Down
8 changes: 4 additions & 4 deletions src/gbintk/support/visualise_result_MEGAHIT.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def run(args):
all_bins_list = []
n_bins = 0

with open(initial_binning_result) as csvfile:
with open(initial_binning_result, mode="r") as csvfile:
readCSV = csv.reader(csvfile, delimiter=delimiter)
for row in readCSV:
all_bins_list.append(row[1])
Expand Down Expand Up @@ -149,7 +149,7 @@ def run(args):

try:
# Get links from .gfa file
with open(assembly_graph_file) as file:
with open(assembly_graph_file, mode="r") as file:
for line in file.readlines():
line = line.strip()

Expand Down Expand Up @@ -248,7 +248,7 @@ def run(args):
bins = [[] for x in range(n_bins)]

try:
with open(initial_binning_result) as contig_bins:
with open(initial_binning_result, mode="r") as contig_bins:
readCSV = csv.reader(contig_bins, delimiter=delimiter)
for row in readCSV:
contig_num = contigs_map_rev[int(graph_to_contig_map_rev[row[0]])]
Expand Down Expand Up @@ -353,7 +353,7 @@ def run(args):
bins = [[] for x in range(n_bins)]

try:
with open(final_binning_result) as contig_bins:
with open(final_binning_result, mode="r") as contig_bins:
readCSV = csv.reader(contig_bins, delimiter=delimiter)
for row in readCSV:
contig_num = contigs_map_rev[int(graph_to_contig_map_rev[row[0]])]
Expand Down
12 changes: 6 additions & 6 deletions src/gbintk/support/visualise_result_SPAdes.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def run(args):
all_bins_list = []
n_bins = 0

with open(initial_binning_result) as csvfile:
with open(initial_binning_result, mode="r") as csvfile:
readCSV = csv.reader(csvfile, delimiter=delimiter)
for row in readCSV:
all_bins_list.append(row[1])
Expand Down Expand Up @@ -137,7 +137,7 @@ def run(args):
current_contig_num = ""

try:
with open(contig_paths) as file:
with open(contig_paths, mode="r") as file:
name = file.readline()
path = file.readline()

Expand Down Expand Up @@ -189,7 +189,7 @@ def run(args):

try:
# Get links from assembly_graph_with_scaffolds.gfa
with open(assembly_graph_file) as file:
with open(assembly_graph_file, mode="r") as file:
for line in file.readlines():
line = line.strip()

Expand Down Expand Up @@ -272,7 +272,7 @@ def run(args):
try:
all_bins_list = []

with open(initial_binning_result) as csvfile:
with open(initial_binning_result, mode="r") as csvfile:
readCSV = csv.reader(csvfile, delimiter=delimiter)
for row in readCSV:
all_bins_list.append(row[1])
Expand All @@ -297,7 +297,7 @@ def run(args):
bins = [[] for x in range(n_bins)]

try:
with open(initial_binning_result) as contig_bins:
with open(initial_binning_result, mode="r") as contig_bins:
readCSV = csv.reader(contig_bins, delimiter=delimiter)
for row in readCSV:
start = "NODE_"
Expand Down Expand Up @@ -402,7 +402,7 @@ def run(args):
bins = [[] for x in range(n_bins)]

try:
with open(final_binning_result) as contig_bins:
with open(final_binning_result, mode="r") as contig_bins:
readCSV = csv.reader(contig_bins, delimiter=delimiter)
for row in readCSV:
if row[1] != "unbinned":
Expand Down

0 comments on commit 96d00fd

Please sign in to comment.