Skip to content

Commit

Permalink
slightly safer fix
Browse files Browse the repository at this point in the history
  • Loading branch information
VarunAnanth2003 committed Mar 13, 2024
1 parent 6525292 commit b10186f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
2 changes: 1 addition & 1 deletion casanovo/casanovo.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ def create_mgf_from_tide(
# No need to do anything if the scan is not found in the scan map
pass
try:
mgf.write(all_spec, output_file)
mgf.write(all_spec, output_file, file_mode="w")
logger.info("Annotated .mgf file written to %s.", output_file)
except Exception as e:
print(
Expand Down
41 changes: 24 additions & 17 deletions casanovo/denovo/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1043,24 +1043,31 @@ def on_predict_epoch_end(self, results) -> None:
)
)
# Write rows
for group in results[0]:
for batch in group:
for index, t_or_d, peptide, score, per_aa_scores in list(
zip(*batch)
):
# Remove scores of 0 (padding)
per_aa_scores = per_aa_scores.numpy()
per_aa_scores = list(per_aa_scores[per_aa_scores != 0])
score = score.numpy()
csv_writer.writerow(
(
index,
peptide,
bool(t_or_d),
score,
per_aa_scores,
for g1 in results:
for batch in g1:
for pairs in batch:
for (
index,
t_or_d,
peptide,
score,
per_aa_scores,
) in list(zip(*pairs)):
# Remove scores of 0 (padding)
per_aa_scores = per_aa_scores.numpy()
per_aa_scores = list(
per_aa_scores[per_aa_scores != 0]
)
score = score.numpy()
csv_writer.writerow(
(
index,
peptide,
bool(t_or_d),
score,
per_aa_scores,
)
)
)
out_f.close()


Expand Down

0 comments on commit b10186f

Please sign in to comment.