Skip to content

Commit 7b2fecd

Browse files
committed
fix bam stats again
1 parent c4fca78 commit 7b2fecd

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

bin/generate_alignment_report.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ def generate_bam_stats(bam_file: str) -> dict:
119119
"mean_aln_length": mean_aln_length if mean_aln_length > 0 else 0,
120120
"forward_proportion": forward_proportion if forward_proportion > 0 else 0,
121121
"uniquely_mapped_reads": stats["unique_mappers"],
122+
"primary_alignments": stats["primary_alignments"],
123+
"mean_read_length": round(np.mean(stats["read_lengths"]), 2),
124+
"mean_alignment_proportion": round(
125+
np.mean(stats["alignment_proportions"]), 2
126+
),
122127
}
123128

124129
return out_stats
@@ -246,16 +251,6 @@ def alignment_stats(depth_array: np.ndarray, coverage_stats: dict) -> dict:
246251
"mapped_bases": int(
247252
int(coverage_stats["endpos"]) * float(coverage_stats["meandepth"])
248253
),
249-
"mean_read_length": (
250-
int(np.mean(coverage_stats["read_lengths"]))
251-
if coverage_stats["read_lengths"]
252-
else 0
253-
),
254-
"mean_alignment_proportion": (
255-
float(np.mean(coverage_stats["alignment_proportions"]))
256-
if coverage_stats["alignment_proportions"]
257-
else 0.0
258-
),
259254
}
260255

261256
return stats

0 commit comments

Comments
 (0)