• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

sequana / sequana / 19136907997

06 Nov 2025 12:56PM UTC coverage: 68.835% (-0.4%) from 69.186%
19136907997

push

github

web-flow
Merge pull request #875 from cokelaer/dev

update HTML variant calling + others

157 of 332 new or added lines in 14 files covered. (47.29%)

5 existing lines in 3 files now uncovered.

14551 of 21139 relevant lines covered (68.83%)

2.07 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

51.22
/sequana/scripts/main/html_report.py
1
#  This file is part of Sequana software
2
#
3
#  Copyright (c) 2016-2020 - Sequana Development Team
4
#
5
#  Distributed under the terms of the 3-clause BSD license.
6
#  The full license is in the LICENSE file, distributed with this software.
7
#
8
#  website: https://github.com/sequana/sequana
9
#  documentation: http://sequana.readthedocs.io
10
#
11
##############################################################################
12
import sys
3✔
13

14
import colorlog
3✔
15
import rich_click as click
3✔
16

17
from sequana.scripts.utils import CONTEXT_SETTINGS
3✔
18

19
logger = colorlog.getLogger(__name__)
3✔
20

21

22
groups = [
3✔
23
    {
24
        "name": "VCF options",
25
        "options": [
26
            "--freebayes-score",
27
            "--strand-ratio",
28
            "--frequency",
29
            "--forward-depth",
30
            "--keep-polymorphic",
31
            "--reverse-depth",
32
            "--min-depth",
33
            "--output-vcf-file",
34
            "--output-csv-file",
35
        ],
36
    },
37
    {
38
        "name": "General",
39
        "options": ["--output-directory"],
40
    },
41
]
42

43
click.rich_click.OPTION_GROUPS["html-report"] = groups.copy()
3✔
44

45

46
# not the hyphen html-report (not html_report). this is a 'bug/feature'
47
# @click.command(context_settings=CONTEXT_SETTINGS)
48
@click.command(context_settings=CONTEXT_SETTINGS)
3✔
49
@click.argument("name", type=click.Path(exists=True))
3✔
50
@click.option("--output-directory", default=".", show_default=True)
3✔
51
@click.option(
3✔
52
    "--output-vcf-file",
53
    "output_vcf_file",
54
    required=False,
55
    type=click.Path(),
56
    show_default=True,
57
    default="sequana.filter.vcf",
58
    help="Path to output VCF file.",
59
)
60
@click.option(
3✔
61
    "--output-csv-file",
62
    "output_csv_file",
63
    required=False,
64
    type=click.Path(),
65
    show_default=True,
66
    default="sequana.filter.csv",
67
    help="Path to output CSV file.",
68
)
69
@click.option(
3✔
70
    "--freebayes-score",
71
    "freebayes_score",
72
    default=20,
73
    show_default=True,
74
    type=float,
75
    help="Freebayes score threshold.",
76
)
77
@click.option(
3✔
78
    "--strand-ratio",
79
    "strand_ratio",
80
    default=0.2,
81
    show_default=True,
82
    type=float,
83
    help="Minimum strand ratio.",
84
)
85
@click.option(
3✔
86
    "--frequency",
87
    "frequency",
88
    default=0.1,
89
    show_default=True,
90
    type=float,
91
    help="Minimum allele frequency.",
92
)
93
@click.option(
3✔
94
    "--min-depth",
95
    default=10,
96
    show_default=True,
97
)
98
@click.option(
3✔
99
    "--forward-depth",
100
    default=3,
101
    show_default=True,
102
)
103
@click.option(
3✔
104
    "--reverse-depth",
105
    default=3,
106
    show_default=True,
107
)
108
@click.option(
3✔
109
    "--keep-polymorphic",
110
    default=True,
111
    show_default=True,
112
)
113
def html_report(**kwargs):
3✔
114
    """Create a HTML report for various type of data set
115

116
    # VCF
117

118
    The VCF module takes an input VCF file and filter it before creating an HTML report.
119
    The options are related to the variant quality. We assume that the VCF file was
120
    created with sequana_variant_calling pipeline and so relied on freebayes software.
121
    If so, you can provide a freebayes minimal score, remove variants below a given
122
    frequency (--frequency), etc (please see --help for other parameters
123

124

125

126

127
    """
NEW
128
    filename = kwargs["name"]
×
NEW
129
    if filename.endswith("fastq.gz") or filename.endswith(".fastq"):
×
NEW
130
        module = "fastq"
×
NEW
131
    elif filename.endswith("vcf"):
×
NEW
132
        module = "vcf"
×
133
    else:
NEW
134
        logger.error("Only extensions vcf is accepted for now")
×
NEW
135
        sys.exit(1)
×
136

NEW
137
    if module == "vcf":
×
NEW
138
        from sequana.freebayes_vcf_filter import VCF_freebayes
×
NEW
139
        from sequana.modules_report.variant_calling import VariantCallingModule
×
NEW
140
        from sequana.utils import config
×
141

142
        # use the sample name based on output HTML file otherwise, user can provide one
NEW
143
        report_dir = kwargs["output_directory"]
×
NEW
144
        config.output_dir = report_dir
×
NEW
145
        params = {
×
146
            "freebayes_score": kwargs["freebayes_score"],
147
            "frequency": kwargs["frequency"],
148
            "min_depth": kwargs["min_depth"],
149
            "forward_depth": kwargs["forward_depth"],
150
            "reverse_depth": kwargs["reverse_depth"],
151
            "strand_ratio": kwargs["strand_ratio"],
152
            "keep_polymorphic": kwargs["keep_polymorphic"],
153
        }
154

NEW
155
        v = VCF_freebayes(filename)
×
NEW
156
        filter_v = v.filter_vcf(params)
×
NEW
157
        filter_v.to_csv(kwargs["output_csv_file"])
×
NEW
158
        filter_v.to_vcf(kwargs["output_vcf_file"])
×
159

160
        # the HTML report
NEW
161
        VariantCallingModule(filter_v)
×
162

163

164
# Make the script runnable
165
if __name__ == "__main__":
3✔
NEW
166
    html_report()
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc