Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --version to every entry point #456

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from sqlalchemy.orm import Session
from sqlalchemy import and_, select

import ensembl.io.genomio
from ensembl.core.models import Gene, Transcript, ObjectXref, Xref
from ensembl.io.genomio.utils import get_json
from ensembl.utils.argparse import ArgumentParser
Expand Down Expand Up @@ -249,6 +250,7 @@ def main() -> None:
parser.add_argument(
"--match_xrefs", action="store_true", help="Use xref IDs to match features if IDs do not work"
)
parser.add_argument("--version", action="version", version=ensembl.io.genomio.__version__)
parser.add_log_arguments(add_log_file=True)
args = parser.parse_args()
init_logging_with_args(args)
Expand Down
2 changes: 2 additions & 0 deletions src/python/ensembl/io/genomio/assembly/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import time
from typing import Dict, Optional

import ensembl.io.genomio
from ensembl.utils.argparse import ArgumentParser
from ensembl.utils.logging import init_logging_with_args

Expand Down Expand Up @@ -333,6 +334,7 @@ def main() -> None:
parser.add_argument_dst_path(
"--download_dir", default=Path.cwd(), help="Folder where the data will be downloaded"
)
parser.add_argument("--version", action="version", version=ensembl.io.genomio.__version__)
parser.add_log_arguments()
args = parser.parse_args()
init_logging_with_args(args)
Expand Down
2 changes: 2 additions & 0 deletions src/python/ensembl/io/genomio/assembly/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from sqlalchemy.engine import URL
from sqlalchemy import text

import ensembl.io.genomio
from ensembl.io.genomio.utils.json_utils import print_json
from ensembl.utils import StrPath
from ensembl.utils.argparse import ArgumentParser
Expand Down Expand Up @@ -346,6 +347,7 @@ def generate_report_tsv(
def main() -> None:
"""Module's entry-point."""
parser = ArgumentParser(description=__doc__)
parser.add_argument("--version", action="version", version=ensembl.io.genomio.__version__)
# Create parser with common arguments to be used by both subparsers
base_parser = ArgumentParser(add_help=False)
base_parser.add_argument_dst_path(
Expand Down
6 changes: 4 additions & 2 deletions src/python/ensembl/io/genomio/database/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

from sqlalchemy.engine import URL

import ensembl.io.genomio
from ensembl.utils.argparse import ArgumentParser
from ensembl.utils.logging import init_logging_with_args
from .core_server import CoreServer
Expand Down Expand Up @@ -136,7 +137,7 @@ def parse_args(arg_list: list[str] | None) -> argparse.Namespace:
# Add filter arguments
parser.add_argument("--prefix", default="", help="Prefix to filter the databases")
parser.add_argument("--build", type=int, default=None, help="Build to filter the databases")
parser.add_argument("--version", type=int, default=None, help="EnsEMBL version to filter the databases")
parser.add_argument("--release", type=int, default=None, help="EnsEMBL release to filter the databases")
parser.add_argument("--db_regex", default="", help="Regular expression to match database names against")
parser.add_argument_src_path("--db_list", help="File with one database per line to load")
# Add flags
Expand All @@ -145,6 +146,7 @@ def parse_args(arg_list: list[str] | None) -> argparse.Namespace:
action="store_true",
help="Enable BRC mode, i.e. use organism_abbrev for species, component for division",
)
parser.add_argument("--version", action="version", version=ensembl.io.genomio.__version__)
parser.add_log_arguments()
return parser.parse_args(arg_list)

Expand All @@ -163,7 +165,7 @@ def main(arg_list: list[str] | None = None) -> None:
server_url=args.url,
prefix=args.prefix,
build=args.build,
version=args.version,
version=args.release,
db_regex=args.db_regex,
db_list=args.db_list,
brc_mode=args.brc_mode,
Expand Down
2 changes: 2 additions & 0 deletions src/python/ensembl/io/genomio/database/meta_getter.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

from sqlalchemy.engine import URL

import ensembl.io.genomio
from ensembl.utils.argparse import ArgumentParser
from ensembl.utils import StrPath
from ensembl.utils.logging import init_logging_with_args
Expand Down Expand Up @@ -95,6 +96,7 @@ def parse_args(arg_list: list[str] | None) -> argparse.Namespace:
parser.add_argument_src_path(
"--meta_keys_list", help="Input File | List with >=2 meta_keys to query target database."
)
parser.add_argument("--version", action="version", version=ensembl.io.genomio.__version__)
parser.add_log_arguments(add_log_file=False)
return parser.parse_args(arg_list)

Expand Down
2 changes: 2 additions & 0 deletions src/python/ensembl/io/genomio/events/dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from sqlalchemy import select, and_, or_
from sqlalchemy.orm import Session

import ensembl.io.genomio
from ensembl.core.models import MappingSession, StableIdEvent
from ensembl.io.genomio.database import DBConnectionLite
from ensembl.utils.argparse import ArgumentParser
Expand Down Expand Up @@ -541,6 +542,7 @@ def main() -> None:
)
parser.add_server_arguments(include_database=True)
parser.add_argument_dst_path("--output_file", required=True, help="Output file")
parser.add_argument("--version", action="version", version=ensembl.io.genomio.__version__)
parser.add_log_arguments(add_log_file=True)
args = parser.parse_args()
init_logging_with_args(args)
Expand Down
2 changes: 2 additions & 0 deletions src/python/ensembl/io/genomio/events/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import re
from typing import Dict, List

import ensembl.io.genomio
from ensembl.io.genomio.events.load import EventCollection
from ensembl.utils.argparse import ArgumentParser
from ensembl.utils.logging import init_logging_with_args
Expand Down Expand Up @@ -79,6 +80,7 @@ def main() -> None:
parser.add_argument("--release_name", required=True, metavar="NAME", help="Release name for all events")
parser.add_argument("--release_date", required=True, metavar="DATE", help="Release date for all events")
parser.add_argument_dst_path("--output_file", required=True, help="Output formatted event file")
parser.add_argument("--version", action="version", version=ensembl.io.genomio.__version__)
parser.add_log_arguments()
args = parser.parse_args()
init_logging_with_args(args)
Expand Down
2 changes: 2 additions & 0 deletions src/python/ensembl/io/genomio/events/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

from sqlalchemy.orm import Session

import ensembl.io.genomio
from ensembl.io.genomio.database import DBConnectionLite
from ensembl.core.models import MappingSession, StableIdEvent
from ensembl.utils.argparse import ArgumentParser
Expand Down Expand Up @@ -243,6 +244,7 @@ def main() -> None:
),
)
parser.add_argument("--update", action="store_true", help="Make changes to the database")
parser.add_argument("--version", action="version", version=ensembl.io.genomio.__version__)
parser.add_log_arguments(add_log_file=True)
args = parser.parse_args()
init_logging_with_args(args)
Expand Down
3 changes: 2 additions & 1 deletion src/python/ensembl/io/genomio/fasta/chunk.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from Bio.Seq import Seq
from Bio.SeqRecord import SeqRecord

import ensembl.io.genomio
from ensembl.utils.archive import open_gz_file
from ensembl.utils.argparse import ArgumentParser
from ensembl.utils.logging import init_logging_with_args
Expand Down Expand Up @@ -386,7 +387,7 @@ def main() -> None:
action="store_true",
help="Append zero-based offset to chunk name ('_off_{offset}').",
)

parser.add_argument("--version", action="version", version=ensembl.io.genomio.__version__)
parser.add_log_arguments(add_log_file=True)
args = parser.parse_args()
init_logging_with_args(args)
Expand Down
2 changes: 2 additions & 0 deletions src/python/ensembl/io/genomio/fasta/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

from Bio import SeqIO

import ensembl.io.genomio
from ensembl.utils.archive import open_gz_file
from ensembl.utils.argparse import ArgumentParser
from ensembl.utils.logging import init_logging_with_args
Expand Down Expand Up @@ -99,6 +100,7 @@ def main() -> None:
parser.add_argument_src_path("--genbank_infile", help="Input GenBank GBFF file")
parser.add_argument_dst_path("--fasta_outfile", required=True, help="Output FASTA file")
parser.add_argument("--peptide_mode", action="store_true", help="Process proteins instead of DNA")
parser.add_argument("--version", action="version", version=ensembl.io.genomio.__version__)
parser.add_log_arguments(add_log_file=True)
args = parser.parse_args()
init_logging_with_args(args)
Expand Down
2 changes: 2 additions & 0 deletions src/python/ensembl/io/genomio/genbank/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import requests

import ensembl.io.genomio
from ensembl.utils.argparse import ArgumentParser
from ensembl.utils.logging import init_logging_with_args

Expand Down Expand Up @@ -70,6 +71,7 @@ def main() -> None:
parser = ArgumentParser(description="Download a sequence from GenBank.")
parser.add_argument("--accession", required=True, help="Sequence accession")
parser.add_argument_dst_path("--output_file", required=True, help="Output GenBank file")
parser.add_argument("--version", action="version", version=ensembl.io.genomio.__version__)
parser.add_log_arguments()
args = parser.parse_args()
init_logging_with_args(args)
Expand Down
2 changes: 2 additions & 0 deletions src/python/ensembl/io/genomio/genbank/extract_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
from Bio.SeqRecord import SeqRecord
from Bio.SeqFeature import SeqFeature

import ensembl.io.genomio
from ensembl.utils.argparse import ArgumentParser
from ensembl.utils.logging import init_logging_with_args

Expand Down Expand Up @@ -526,6 +527,7 @@ def main() -> None:
parser.add_argument_dst_path(
"--out_dir", default=Path.cwd(), help="output folder where the generated files will be stored"
)
parser.add_argument("--version", action="version", version=ensembl.io.genomio.__version__)
parser.add_log_arguments(add_log_file=True)
args = parser.parse_args()
init_logging_with_args(args)
Expand Down
2 changes: 2 additions & 0 deletions src/python/ensembl/io/genomio/genome_metadata/dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from sqlalchemy.engine import URL

from ensembl.core.models import Meta
import ensembl.io.genomio
from ensembl.io.genomio.utils.json_utils import get_json
from ensembl.io.genomio.database import DBConnectionLite
from ensembl.utils.argparse import ArgumentParser
Expand Down Expand Up @@ -289,6 +290,7 @@ def parse_args(arg_list: list[str] | None) -> argparse.Namespace:
help="Perform assembly and genebuild 'version' metadata checks & update if needed.",
)
parser.add_argument("--append_db", action="store_true", help="Append core database name to output JSON.")
parser.add_argument("--version", action="version", version=ensembl.io.genomio.__version__)
parser.add_log_arguments(add_log_file=True)
return parser.parse_args(arg_list)

Expand Down
2 changes: 2 additions & 0 deletions src/python/ensembl/io/genomio/genome_metadata/extend.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

from Bio import SeqIO

import ensembl.io.genomio
from ensembl.io.genomio.utils import get_json, print_json
from ensembl.utils.archive import open_gz_file
from ensembl.utils.argparse import ArgumentParser
Expand Down Expand Up @@ -163,6 +164,7 @@ def main() -> None:
)
parser.add_argument_src_path("--report_file", help="INSDC/RefSeq sequences report file")
parser.add_argument_src_path("--genbank_file", help="INSDC/RefSeq GBFF file")
parser.add_argument("--version", action="version", version=ensembl.io.genomio.__version__)
parser.add_log_arguments()
args = parser.parse_args()
init_logging_with_args(args)
Expand Down
2 changes: 2 additions & 0 deletions src/python/ensembl/io/genomio/genome_metadata/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from os import PathLike
from typing import Dict

import ensembl.io.genomio
from ensembl.io.genomio.utils import get_json, print_json
from ensembl.utils.argparse import ArgumentParser
from ensembl.utils.logging import init_logging_with_args
Expand Down Expand Up @@ -199,6 +200,7 @@ def main() -> None:
parser.add_argument_src_path(
"--ncbi_meta", required=True, help="JSON file from NCBI datasets for this genome."
)
parser.add_argument("--version", action="version", version=ensembl.io.genomio.__version__)
parser.add_log_arguments()
args = parser.parse_args()
init_logging_with_args(args)
Expand Down
2 changes: 2 additions & 0 deletions src/python/ensembl/io/genomio/genome_stats/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import re
from typing import Any, Dict

import ensembl.io.genomio
from ensembl.io.genomio.utils import get_json
from ensembl.utils.argparse import ArgumentParser
from ensembl.utils.logging import init_logging_with_args
Expand Down Expand Up @@ -222,6 +223,7 @@ def main() -> None:
)
parser.add_argument_src_path("--ncbi_stats", required=True, help="NCBI dataset stats JSON file")
parser.add_argument_src_path("--core_stats", required=True, help="core database stats JSON file")
parser.add_argument("--version", action="version", version=ensembl.io.genomio.__version__)
parser.add_log_arguments(add_log_file=True)
args = parser.parse_args()

Expand Down
2 changes: 2 additions & 0 deletions src/python/ensembl/io/genomio/genome_stats/dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from sqlalchemy.orm import Session

from ensembl.core.models import SeqRegionAttrib, AttribType, Gene, Transcript
import ensembl.io.genomio
from ensembl.io.genomio.database import DBConnectionLite
from ensembl.utils.argparse import ArgumentParser
from ensembl.utils.database import StrURL
Expand Down Expand Up @@ -149,6 +150,7 @@ def main() -> None:
"""Main script entry-point."""
parser = ArgumentParser(description=__doc__)
parser.add_server_arguments(include_database=True)
parser.add_argument("--version", action="version", version=ensembl.io.genomio.__version__)
parser.add_log_arguments(add_log_file=True)
args = parser.parse_args()
init_logging_with_args(args)
Expand Down
6 changes: 3 additions & 3 deletions src/python/ensembl/io/genomio/gff3/overlaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from Bio.SeqRecord import SeqRecord
from intervaltree import Interval, IntervalTree

import ensembl.io.genomio
from ensembl.io.genomio.utils import print_json
from ensembl.utils.argparse import ArgumentParser
from ensembl.utils.logging import init_logging_with_args
Expand Down Expand Up @@ -182,15 +183,14 @@ def get_intervals(record: SeqRecord, genes_dict: dict, seq_dict: dict, seq_name:
def main() -> None:
"""Module entry-point."""
parser = ArgumentParser(description=__doc__)
parser.add_argument("--version", action="version", version=ensembl.io.genomio.__version__)
# Create parser with common arguments to be used by both subparsers
base_parser = ArgumentParser(add_help=False)
base_parser.add_argument_src_path("--input_gff", required=True, help="path of GFF3 file to process")
base_parser.add_log_arguments(add_log_file=True)
# Add subparsers with their parent being the base parser with the common arguments
subparsers = parser.add_subparsers(title="Parse GFF3 and ", required=True, dest="subcommand")
gff3_stats_parser = subparsers.add_parser( # pylint: disable=unused-variable
"stats", parents=[base_parser], help="Provide summary of feature types"
)
_ = subparsers.add_parser("stats", parents=[base_parser], help="Provide summary of feature types")
overlaps_parser = subparsers.add_parser("overlaps", parents=[base_parser], help="Find feature overlaps")
overlaps_parser.add_argument_dst_path(
"--output_file", default="feature_overlaps.txt", help="path of output file"
Expand Down
2 changes: 2 additions & 0 deletions src/python/ensembl/io/genomio/gff3/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import logging
from pathlib import Path

import ensembl.io.genomio
from ensembl.utils.argparse import ArgumentParser
from ensembl.utils.logging import init_logging_with_args

Expand All @@ -44,6 +45,7 @@ def main() -> None:
default=Path("functional_annotation.json"),
help="Output functional annotation JSON file",
)
parser.add_argument("--version", action="version", version=ensembl.io.genomio.__version__)
parser.add_log_arguments(add_log_file=True)
args = parser.parse_args()
init_logging_with_args(args)
Expand Down
2 changes: 2 additions & 0 deletions src/python/ensembl/io/genomio/manifest/check_integrity.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import re
from typing import Any

import ensembl.io.genomio
from ensembl.io.genomio.manifest.manifest_stats import InvalidIntegrityError, ManifestStats
from ensembl.utils.argparse import ArgumentParser
from ensembl.utils.logging import init_logging_with_args
Expand Down Expand Up @@ -389,6 +390,7 @@ def main() -> None:
parser.add_argument(
"--no_fail", action="store_true", help="In case of errors, don't fail but print errors to stdout."
)
parser.add_argument("--version", action="version", version=ensembl.io.genomio.__version__)
parser.add_log_arguments(add_log_file=True)
args = parser.parse_args()
init_logging_with_args(args)
Expand Down
2 changes: 2 additions & 0 deletions src/python/ensembl/io/genomio/manifest/compute_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

from BCBio import GFF

import ensembl.io.genomio
from ensembl.utils import StrPath
from ensembl.utils.archive import open_gz_file
from ensembl.utils.argparse import ArgumentParser
Expand Down Expand Up @@ -418,6 +419,7 @@ def main() -> None:
parser.add_argument("--accession", help="Sequence accession ID to compare stats with NCBI")
parser.add_argument("--datasets_bin", help="Datasets bin status")
parser.add_argument_dst_path("--stats_file", help="Output file with the stats")
parser.add_argument("--version", action="version", version=ensembl.io.genomio.__version__)
parser.add_log_arguments()
args = parser.parse_args()
init_logging_with_args(args)
Expand Down
2 changes: 2 additions & 0 deletions src/python/ensembl/io/genomio/manifest/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# limitations under the License.
"""Creates a manifest file in a folder depending on the file names ends."""

import ensembl.io.genomio
from ensembl.io.genomio.manifest.manifest import Manifest
from ensembl.utils.argparse import ArgumentParser
from ensembl.utils.logging import init_logging_with_args
Expand All @@ -27,6 +28,7 @@ def main() -> None:
parser.add_argument_dst_path(
"--manifest_dir", required=True, help="Folder where to create a manifest file"
)
parser.add_argument("--version", action="version", version=ensembl.io.genomio.__version__)
parser.add_log_arguments()
args = parser.parse_args()
init_logging_with_args(args)
Expand Down
2 changes: 1 addition & 1 deletion src/python/ensembl/io/genomio/manifest/manifest_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def add_error(self, error: str) -> None:
def load_seq_regions(self) -> None:
"""Retrieve seq_regions lengths and circular information from the seq_region JSON file."""

if not "seq_region" in self.manifest_files:
if "seq_region" not in self.manifest_files:
return
logging.info("Manifest contains seq_region JSON")
seq_regions = get_json(Path(self.manifest_files["seq_region"]))
Expand Down
Loading