From 32e5b465692388c2592ff946b19ee059fcf0f3ad Mon Sep 17 00:00:00 2001 From: Jonas Fuchs <78491186+jonas-fuchs@users.noreply.github.com> Date: Wed, 7 Aug 2024 09:55:14 +0200 Subject: [PATCH] Fix stats (#20) * fixed bam stats bug * updated version --- bamdash/__init__.py | 2 +- bamdash/command.py | 2 +- bamdash/scripts/data.py | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/bamdash/__init__.py b/bamdash/__init__.py index 4f4a19a..f9abe23 100644 --- a/bamdash/__init__.py +++ b/bamdash/__init__.py @@ -1,3 +1,3 @@ """interactively visualize coverage and tracks""" _program = "bamdash" -__version__ = "0.3" +__version__ = "0.3.1" diff --git a/bamdash/command.py b/bamdash/command.py index ad7d244..de007e4 100644 --- a/bamdash/command.py +++ b/bamdash/command.py @@ -300,7 +300,7 @@ def main(sysargs=sys.argv[1:]): # dump track data vcf_track_count, bed_track_count, gb_track_count = 0, 0, 0 if args.dump: - pd.DataFrame.from_dict(stat_dict, orient="index").to_csv("bam_stats.tabular", sep="\t", header=False, index=True) + pd.DataFrame.from_dict(stat_dict, orient="index").to_csv(f"{args.reference}_bam_stats.tabular", sep="\t", header=False, index=True) if track_data: for track in track_data: if track[1] == "vcf": diff --git a/bamdash/scripts/data.py b/bamdash/scripts/data.py index 28163d4..47cef3d 100644 --- a/bamdash/scripts/data.py +++ b/bamdash/scripts/data.py @@ -51,6 +51,9 @@ def make_title_string(parsed_bam, coverage_df, reference, min_cov): stat_dict = {} # get bam stats for correct chrom bam_stats = parsed_bam.get_index_statistics()[0] + for bam_stats in parsed_bam.get_index_statistics(): + if bam_stats[0] == reference: + break # pop dict stat_dict["reference"] = bam_stats[0] stat_dict["reference length (bp)"] = parsed_bam.get_reference_length(reference)