Skip to content

Commit

Permalink
pep8 issues, indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jethror1 committed Dec 4, 2020
1 parent ff46a7f commit cfd88c0
Showing 1 changed file with 58 additions and 57 deletions.
115 changes: 58 additions & 57 deletions bin/coverage_report_single.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def read_exon_stats(self, exon_stats):
cov_stats["chrom"] = cov_stats["chrom"].apply(
lambda x: str(x).replace("chr", "")
)

return cov_stats


Expand All @@ -80,14 +80,14 @@ def read_gene_stats(self, gene_stats):
cov_summary = pd.read_csv(
gene_file, sep="\t", comment='#', dtype=dtypes
)

return cov_summary


def read_raw_coverage(self, raw_coverage):
"""
Read in raw coverage data (annotated bed file) from single stats
Args:
- raw_coverage (file): file of annotated bed file
Returns:
Expand All @@ -113,7 +113,7 @@ def read_raw_coverage(self, raw_coverage):
raw_coverage["chrom"] = raw_coverage["chrom"].apply(
lambda x: str(x).replace("chr", "")
)

return raw_coverage


Expand Down Expand Up @@ -190,7 +190,7 @@ def read_bootstrap(self):
))
with open(bs) as bs:
bootstrap = bs.read()

return bootstrap


Expand All @@ -209,7 +209,7 @@ def read_template(self):

with open(single_template, 'r') as template:
html_template = template.read()

return html_template


Expand Down Expand Up @@ -247,7 +247,7 @@ def get_build_and_stats(self, gene_stats):
if "build" not in locals():
# build no. not included in gene_stats file
build = ""

return flagstat, build


Expand All @@ -274,7 +274,7 @@ def get_panel_name(self, panel):
</li>".format(panel_name)
else:
panel = ""

return panel


Expand Down Expand Up @@ -1443,6 +1443,7 @@ def generate_report(self, cov_stats, cov_summary, snps_low_cov,
"""
print("Generating report")
styling = styleTables()
calculate = calculateValues()

# format threshold val & select threshold columns
threshold = str(args.threshold) + "x"
Expand Down Expand Up @@ -1478,7 +1479,7 @@ def generate_report(self, cov_stats, cov_summary, snps_low_cov,
fully_covered_genes = total_genes - gene_issues

total_snps, snps_pct_covered, snps_pct_not_covered,\
snps_pct_out_panel = self.calculate_snp_vals(
snps_pct_out_panel = calculate.calculate_snp_vals(
snps_covered, snps_not_covered, snps_out_panel
)

Expand Down Expand Up @@ -1614,58 +1615,58 @@ def write_report(self, html_string, output_name):

def load_files(
threshold, exon_stats, gene_stats, raw_coverage, snp_vcfs, panel):
"""
Load in raw coverage data, coverage stats file and template.
Args:
- threshold (int): threshold value passed from parse_args
- exon_stats (file): exon stats file (from args;
generated by coverage_stats_single.py)
- gene_stats (file): gene stats file (from args;
generated by coverage_stats_single.py)
- raw_coverage (file): from args; bp coverage file used as
input for coverage_stats_single.py
- snp_vcfs (list): VCFs of SNPs passed from args
- panel (file): panel bed file used for annotation, used to
display panel name in report if passed
"""
Load in raw coverage data, coverage stats file and template.
Args:
- threshold (int): threshold value passed from parse_args
- exon_stats (file): exon stats file (from args;
generated by coverage_stats_single.py)
- gene_stats (file): gene stats file (from args;
generated by coverage_stats_single.py)
- raw_coverage (file): from args; bp coverage file used as
input for coverage_stats_single.py
- snp_vcfs (list): VCFs of SNPs passed from args
- panel (file): panel bed file used for annotation, used to
display panel name in report if passed
Returns:
- cov_stats (df): df of coverage stats for each exon
- cov_summary (df): df of gene level coverage
- raw_coverage (df): raw bp coverage for each exon
- html_template (str): string of HTML report template
- flagstat (dict): flagstat metrics, from gene_stats header
- build (str): ref build used, from gene_stats header
- panel (str): panes(s) / gene(s) included in report
- vcfs (str): list of vcf names used for SNP analysis
- version (str): version of Athena, used to add to report
"""
print("Reading in files")

# class with functions for loading req. data in
load = getData()

# read in required files
cov_stats = load.read_exon_stats(exon_stats)
cov_summary = load.read_gene_stats(gene_stats)
raw_coverage = load.read_raw_coverage(raw_coverage)
bootstrap = load.read_bootstrap()
html_template = load.read_template()
low_raw_cov = load.low_coverage_regions(
cov_stats, raw_coverage, threshold
)
Returns:
- cov_stats (df): df of coverage stats for each exon
- cov_summary (df): df of gene level coverage
- raw_coverage (df): raw bp coverage for each exon
- html_template (str): string of HTML report template
- flagstat (dict): flagstat metrics, from gene_stats header
- build (str): ref build used, from gene_stats header
- panel (str): panes(s) / gene(s) included in report
- vcfs (str): list of vcf names used for SNP analysis
- version (str): version of Athena, used to add to report
"""
print("Reading in files")

# class with functions for loading req. data in
load = getData()

# read in required files
cov_stats = load.read_exon_stats(exon_stats)
cov_summary = load.read_gene_stats(gene_stats)
raw_coverage = load.read_raw_coverage(raw_coverage)
bootstrap = load.read_bootstrap()
html_template = load.read_template()
low_raw_cov = load.low_coverage_regions(
cov_stats, raw_coverage, threshold
)

# get other required attributes
flagstat, build = load.get_build_and_stats(gene_stats)
version = load.get_athena_ver()
panel = load.get_panel_name(panel)
vcfs = load.get_snp_vcfs(snp_vcfs)
# get other required attributes
flagstat, build = load.get_build_and_stats(gene_stats)
version = load.get_athena_ver()
panel = load.get_panel_name(panel)
vcfs = load.get_snp_vcfs(snp_vcfs)

# check if given low coverage threshold is valid
threshold = load.check_threshold(threshold, cov_stats, cov_summary)
# check if given low coverage threshold is valid
threshold = load.check_threshold(threshold, cov_stats, cov_summary)

return cov_stats, cov_summary, raw_coverage, low_raw_cov,\
html_template, flagstat, build, panel, vcfs, bootstrap, version
return cov_stats, cov_summary, raw_coverage, low_raw_cov,\
html_template, flagstat, build, panel, vcfs, bootstrap, version


def parse_args():
Expand Down

0 comments on commit cfd88c0

Please sign in to comment.