Skip to content

Commit

Permalink
fix: add max retries flag
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysnewell committed Nov 16, 2023
1 parent e0704c3 commit bc67150
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 31 deletions.
2 changes: 1 addition & 1 deletion flight/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.6.1"
__version__ = "1.6.2"
67 changes: 38 additions & 29 deletions flight/flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,15 @@ def main():
default=False,
)

refine_options.add_argument(
'--max_retries',
help='The maximum number of times to attempt to refine a bin',
dest='max_retries',
required=False,
type=int,
default=5
)

refine_options.set_defaults(func=refine)

filter_options = subparsers.add_parser(
Expand Down Expand Up @@ -429,31 +438,31 @@ def main():
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Parsing input ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
if (len(sys.argv) == 2 or len(sys.argv) == 1 or sys.argv[1] == '-h'
or sys.argv[1] == '--help'):
phelp()
# if (len(sys.argv) == 2 or len(sys.argv) == 1 or sys.argv[1] == '-h'
# or sys.argv[1] == '--help'):
# phelp()
# else:
args = main_parser.parse_args()
time = datetime.datetime.now().strftime('%H:%M:%S %d-%m-%Y')

if args.log:
if os.path.isfile(args.log):
raise Exception("File %s exists" % args.log)
logging.basicConfig(
filename=args.log,
level=debug[args.verbosity],
format='%(asctime)s %(levelname)s: %(message)s',
datefmt='%m/%d/%Y %I:%M:%S %p')
else:
args = main_parser.parse_args()
time = datetime.datetime.now().strftime('%H:%M:%S %d-%m-%Y')

if args.log:
if os.path.isfile(args.log):
raise Exception("File %s exists" % args.log)
logging.basicConfig(
filename=args.log,
level=debug[args.verbosity],
format='%(asctime)s %(levelname)s: %(message)s',
datefmt='%m/%d/%Y %I:%M:%S %p')
else:
logging.basicConfig(
level=debug[args.verbosity],
format='%(asctime)s %(levelname)s: %(message)s',
datefmt='%m/%d/%Y %I:%M:%S %p')
logging.basicConfig(
level=debug[args.verbosity],
format='%(asctime)s %(levelname)s: %(message)s',
datefmt='%m/%d/%Y %I:%M:%S %p')

logging.info("Time - %s" % (time))
logging.info("Time - %s" % (time))


args.func(args)
args.func(args)


def fit(args):
Expand Down Expand Up @@ -609,16 +618,16 @@ def write_contig(contig, assembly, f):
f.write(fasta)


def phelp():
print("""
Usage:
flight [SUBCOMMAND] ..
# def phelp():
# print("""
# Usage:
# flight [SUBCOMMAND] ..

Subcommands:
bin - Bin sets of metagenomic contigs into MAGs
fit - Genotype variants into metagenomic strains *For use with Lorikeet*
# Subcommands:
# bin - Bin sets of metagenomic contigs into MAGs
# fit - Genotype variants into metagenomic strains *For use with Lorikeet*

""")
# """)


def str2bool(v):
Expand Down
2 changes: 1 addition & 1 deletion flight/rosella/rosella.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ def perform_refining(self, args):
logging.info("Refining bins...")
x_min, x_max, y_min, y_max = 20, 20, 20, 20 # default plotting margins

self.slow_refine(plots, 0, 10, x_min, x_max, y_min, y_max, False,
self.slow_refine(plots, 0, args.max_retries, x_min, x_max, y_min, y_max, False,
float(args.min_completeness), float(args.max_contamination),
0, args.contaminated_only, True, False)
self.big_contig_filter(plots, 0, 3, x_min, x_max, y_min, y_max)
Expand Down

0 comments on commit bc67150

Please sign in to comment.