Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for old guppy API and mod calling newline bug #27

Merged
merged 3 commits into from
Nov 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions src/buttery_eel.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,11 @@ def submit_read(args, iq, rq, address, config, params, N):
time.sleep(client.throttle)
continue
else:
model_id = ".".join(args.config.split(".")[:-1])
for calls in bcalled:
done += 1
if not isinstance(calls, list):
calls = [calls]
split_reads = False
if len(calls) > 1:
split_reads = True
Expand All @@ -530,7 +533,6 @@ def submit_read(args, iq, rq, address, config, params, N):
# print("{}: {}".format(j, call[i][j]))
# else:
# print("{}: {}".format(i, call[i]))
# sys.exit()
try:
bcalled_read = {}
bcalled_read["sam_record"] = ""
Expand All @@ -542,18 +544,28 @@ def submit_read(args, iq, rq, address, config, params, N):
bcalled_read["read_id"] = read_id
bcalled_read["read_qscore"] = call['metadata']['mean_qscore']
bcalled_read["int_read_qscore"] = int(call['metadata']['mean_qscore'])
bcalled_read["header"] = "@{} parent_read_id={} model_version_id={} mean_qscore={}".format(bcalled_read["read_id"], bcalled_read["parent_read_id"], call['metadata']['model_version_id'], bcalled_read["int_read_qscore"])
bcalled_read["header"] = "@{} parent_read_id={} model_version_id={} mean_qscore={}".format(bcalled_read["read_id"], bcalled_read["parent_read_id"], call['metadata'].get('model_version_id', model_id), bcalled_read["int_read_qscore"])
bcalled_read["sequence"] = call['datasets']['sequence']
except Exception as error:
# handle the exception
print("An exception occurred in stage 1:", type(error).__name__, "-", error)
sys.exit(1)
try:
if len(bcalled_read["sequence"]) == 0:
print("read_id: {} has a sequence length of zero, skipping".format(read_id))
continue
bcalled_read["qscore"] = call['datasets']['qstring']
if args.moves_out:
bcalled_read["move_table"] = call['datasets']['movement']
bcalled_read["model_stride"] = call['metadata']['model_stride']
if args.call_mods:
try:
bcalled_read["sam_record"] = call['metadata']['alignment_sam_record']
except:
# TODO: add warning that mods model not being used, and exit
except Exception as error:
# handle the exception
print("An exception occurred getting sam_record/alignment_sam_record for {}:", read_id, type(error).__name__, "-", error)
bcalled_read["sam_record"] = ""
continue
if args.do_read_splitting:
bcalled_read["num_samples"] = None
bcalled_read["trimmed_samples"] = None
Expand All @@ -564,6 +576,11 @@ def submit_read(args, iq, rq, address, config, params, N):
bcalled_read["num_samples"] = trimmed_duration + bcalled_read["trimmed_samples"]
if bcalled_read["num_samples"] != raw_num_samples:
print("WARNING: {} ns:i:{} != raw_num_samples:{}".format(bcalled_read["read_id"], bcalled_read["num_samples"], raw_num_samples))
except Exception as error:
# handle the exception
print("An exception occurred in stage 2:", type(error).__name__, "-", error)
sys.exit(1)
try:
if SPLIT_PASS:
if bcalled_read["read_qscore"] >= qs_cutoff:
# pass
Expand All @@ -584,7 +601,7 @@ def submit_read(args, iq, rq, address, config, params, N):

# create summary data
if args.seq_sum:
minknow_events = call['metadata']['num_minknow_events']
minknow_events = call['metadata'].get('num_minknow_events', ".")
sample_rate = float(read_store[read_id]["sampling_rate"])
duration = round(float(call['metadata']['duration'] / sample_rate), 6)
num_events = call['metadata']['num_events']
Expand Down Expand Up @@ -621,7 +638,7 @@ def submit_read(args, iq, rq, address, config, params, N):
bcalled_list.append(bcalled_read)
except Exception as error:
# handle the exception
print("An exception occurred:", type(error).__name__, "-", error)
print("An exception occurred in stage 3:", type(error).__name__, "-", error)
sys.exit(1)


Expand Down