Skip to content

Commit

Permalink
Merge pull request #10 from nebiolabs/feature/#9-more_logging
Browse files Browse the repository at this point in the history
Adds logging based on historic troubleshooting incidents. Could be ex…
  • Loading branch information
jakemiller13 authored Feb 5, 2024
2 parents 75ff0fd + 13ccfc2 commit 6411945
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
15 changes: 14 additions & 1 deletion fatools/lib/fautil/cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ def init_argparser(parser=None):


def main(args):
cerr('***** Entering main in FATools *****')

if args.verbose != 0:
set_verbosity(args.verbose)
Expand Down Expand Up @@ -203,6 +204,7 @@ def main(args):


def do_facmds(args, fsa_list, _params, dbh=None):
cerr('***** Entering do_facmds in FATools *****')

if args.ladder_rfu_threshold >= 0:
_params.ladder.min_rfu = args.ladder_rfu_threshold
Expand Down Expand Up @@ -286,12 +288,16 @@ def do_align( args, fsa_list, _params, f_bad_files, dbh ):
fsa.align(_params)
good_fsa.append( (fsa, fsa_index) )
except LadderMismatchException:
cerr('***** LadderMismatchException: {} *****'.format(fsa))

f_bad_files.write(("LadderMismatch: %s\n") % fsa.filename)


cerr('***** good_fsas: {} *****'.format(good_fsa))
return good_fsa


def do_call( args, fsa_list, params, dbh ):
cerr('***** Entering do_call *****')

cerr('I: Calling non-ladder peaks...')

Expand Down Expand Up @@ -319,6 +325,7 @@ def do_normalize( args, fsa_list, params ):
panel = Panel.get_panel(args.panel)

ladder_means = panel.get_ladder_area_means(fsa_list)
cerr('***** ladder_means: {} *****'.format(ladder_means))

# normalize areas for each FSA
for (fsa, fsa_index) in fsa_list:
Expand Down Expand Up @@ -641,6 +648,8 @@ def open_fsa( args, _params ):
os.makedirs('.fatools_caches/channels')

if args.file:
cerr('***** Reading args.file *****')

for fsa_filename in args.file.split(','):
fsa_filename = fsa_filename.strip()

Expand All @@ -655,6 +664,7 @@ def open_fsa( args, _params ):
index += 1

elif args.infile:
cerr('***** Reading args.infile *****')

with open(args.infile) as f:
buf, delim = detect_buffer( f.read() )
Expand Down Expand Up @@ -691,6 +701,8 @@ def open_fsa( args, _params ):
index += 1

elif args.indir:
cerr('***** Reading args.indir *****')

import glob
for fsa_filename in sorted(glob.glob(args.indir+"/*.fsa")):

Expand All @@ -700,6 +712,7 @@ def open_fsa( args, _params ):
fsa_list.append( (fsa, str(index)) )
index += 1

cerr('***** fsa_list: {} *****'.format(fsa_list))
return fsa_list


Expand Down
13 changes: 12 additions & 1 deletion fatools/lib/fautil/mixin2.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ def assign(self):
self.marker = marker


def get_alleles(self, broad_peaks_only=True):
def get_alleles(self, broad_peaks_only=True):
cerr('***** Entering ChannelMixin.get_alleles *****')

if self.status == const.channelstatus.reseted:
# create alleles first
raise RuntimeError('E: channel needs to be scanned first')
Expand All @@ -73,6 +75,7 @@ def get_alleles(self, broad_peaks_only=True):

# ChannelMixIn scan method
def scan(self, parameters):
cerr('***** Entering ChannelMixin.scan *****')

if self.status != const.channelstatus.reseted:
return
Expand All @@ -81,6 +84,7 @@ def scan(self, parameters):


def preannotate(self, parameters):
cerr('***** Entering ChannelMixin.preannotate *****')

params = parameters.ladder if self.is_ladder() else parameters.nonladder

Expand All @@ -90,6 +94,8 @@ def preannotate(self, parameters):
# ChannelMixIn align method
def align(self, parameters, ladder=None, anchor_pairs=None, saturated_peak_rtimes=[]):
# sanity checks
cerr('***** Entering ChannelMixin.align *****')

if self.marker.code != 'ladder':
raise RuntimeError('E: align() must be performed on ladder channel!')

Expand Down Expand Up @@ -277,6 +283,7 @@ def create_channels(self, params):

# FSAMixIn scan method
def scan(self, parameters):
cerr('***** Entering FSAMixIn.scan *****')

if self.scan_done: return

Expand All @@ -291,6 +298,7 @@ def scan(self, parameters):

# FSAMixIn align method
def align(self, parameters=None):
cerr('***** Entering FSAMixIn.align *****')

self.scan(parameters)

Expand All @@ -299,6 +307,7 @@ def align(self, parameters=None):

# FSAMixIn call method
def call(self, parameters):
cerr('***** Entering FSAMixIn.call *****')

if self.call_done: return

Expand Down Expand Up @@ -335,6 +344,7 @@ def get_ladder_channel(self):

for c in self.channels:
if c.marker.code == 'ladder':
cerr('***** get_ladder_channel: {} *****'.format(c))
return c
raise RuntimeError('E: ladder channel not found')

Expand Down Expand Up @@ -442,6 +452,7 @@ def get_marker(self, dye):


def get_ladder(self):
cerr('***** ladder: {} *****'.format(const.ladders[ self.data['ladder']]))
return const.ladders[ self.data['ladder']]


Expand Down

0 comments on commit 6411945

Please sign in to comment.