Skip to content

Commit

Permalink
Fix code style issues with Black
Browse files Browse the repository at this point in the history
  • Loading branch information
lint-action committed Nov 5, 2024
1 parent 7684077 commit ed2a26d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 46 deletions.
8 changes: 2 additions & 6 deletions scripts/check_hgnc_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,15 @@ def cli(context, repeats_file, loglevel):

if len(response_rest["docs"]) > 1:
LOG.warning(
"Entry {} got {} hgnc responses - using first".format(
entry, len(response_rest)
)
"Entry {} got {} hgnc responses - using first".format(entry, len(response_rest))
)

symbol_from_id = response_rest["docs"][0]["symbol"]

if symbol_from_id == locus_symbol:
LOG.info("OK locus %s symbol %s", entry, locus_symbol)
elif symbol_from_id.lower() == locus_symbol.lower():
LOG.warning(
"OK locus %s symbol %s but differs in case", entry, locus_symbol
)
LOG.warning("OK locus %s symbol %s but differs in case", entry, locus_symbol)
else:
LOG.error(
"OOOPS locus_symbol %s and symbol %s from HGNC id %i do not match",
Expand Down
4 changes: 1 addition & 3 deletions scripts/compare_locus_values_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ def cli(context, repeats_file, alt_repeats_file, loglevel):
repeat_information = parse_repeat_file(file_handle, repeats_file_type="json")

with open(alt_repeats_file, "r") as file_handle:
other_repeat_information = parse_repeat_file(
file_handle, repeats_file_type="json"
)
other_repeat_information = parse_repeat_file(file_handle, repeats_file_type="json")

if not repeat_information or not other_repeat_information:
LOG.warning("Could not find any repeat info")
Expand Down
17 changes: 4 additions & 13 deletions stranger/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ def print_version(ctx, param, value):
)
@click.option("-i", "--family_id", default="1")
@click.option("-t", "--trgt", is_flag=True, help="File was produced with TRGT")
@click.option(
"--version", is_flag=True, callback=print_version, expose_value=False, is_eager=True
)
@click.option("--version", is_flag=True, callback=print_version, expose_value=False, is_eager=True)
@click.option(
"--loglevel",
default="INFO",
Expand Down Expand Up @@ -184,29 +182,22 @@ def cli(context, vcf, family_id, repeats_file, loglevel, trgt):
individual_index = get_individual_index(header_info)
variant_info["format_dicts"] = get_format_dicts(
variant_info["FORMAT"],
[
variant_info[individual]
for individual in header_info[individual_index:]
],
[variant_info[individual] for individual in header_info[individual_index:]],
)

if len(variant_info["alts"]) > 1:
variant_infos = decompose_var(variant_info)

for variant_info in variant_infos:
update_decomposed_variant_format_fields(
variant_info, header_info, individual_index
)
update_decomposed_variant_format_fields(variant_info, header_info, individual_index)

for variant_info in variant_infos:
repeat_data = get_repeat_info(variant_info, repeat_information)

if repeat_data:
variant_info["info_dict"]["STR_STATUS"] = repeat_data["repeat_strings"]
variant_info["info_dict"]["STR_NORMAL_MAX"] = str(repeat_data["lower"])
variant_info["info_dict"]["STR_PATHOLOGIC_MIN"] = str(
repeat_data["upper"]
)
variant_info["info_dict"]["STR_PATHOLOGIC_MIN"] = str(repeat_data["upper"])
variant_info["info_dict"]["RankScore"] = ":".join(
[str(family_id), str(repeat_data["rank_score"])]
)
Expand Down
34 changes: 10 additions & 24 deletions stranger/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,14 @@ def parse_json(file_handle):
normal_max = repeat_unit["NormalMax"]
except KeyError as err:
LOG.warning(
"Repeat number {0} ({1}) is missing 'NormalMax'. Skipping..".format(
i, repid
)
"Repeat number {0} ({1}) is missing 'NormalMax'. Skipping..".format(i, repid)
)
continue
try:
pathologic_min = repeat_unit["PathologicMin"]
except KeyError as err:
LOG.warning(
"Repeat number {0} ({1}) is missing 'PathologicMin'. Skipping..".format(
i, repid
)
"Repeat number {0} ({1}) is missing 'PathologicMin'. Skipping..".format(i, repid)
)
continue

Expand All @@ -101,9 +97,7 @@ def parse_json(file_handle):
# TRGT uses TRID instead of REPID
trid = repeat_unit["TRID"]

repeat_info[trid] = dict(
normal_max=normal_max, pathologic_min=pathologic_min
)
repeat_info[trid] = dict(normal_max=normal_max, pathologic_min=pathologic_min)

for annotated_key in ANNOTATE_REPEAT_KEYS:
if repeat_unit.get(annotated_key):
Expand All @@ -117,9 +111,7 @@ def parse_json(file_handle):
reference_region = repeat_unit["ReferenceRegion"]
except KeyError as err:
LOG.warning(
"Repeat number {0} ({1}) is missing 'ReferenceRegion'. Skipping..".format(
i, repid
)
"Repeat number {0} ({1}) is missing 'ReferenceRegion'. Skipping..".format(i, repid)
)
continue
if "PathologicRegion" in repeat_unit:
Expand Down Expand Up @@ -255,9 +247,7 @@ def get_repeat_info(variant_info, repeat_info):

for annotate_repeat_key in ANNOTATE_REPEAT_KEYS:
if repeat_info[repeat_id].get(annotate_repeat_key):
repeat_data[annotate_repeat_key] = str(
repeat_info[repeat_id][annotate_repeat_key]
)
repeat_data[annotate_repeat_key] = str(repeat_info[repeat_id][annotate_repeat_key])

return repeat_data

Expand Down Expand Up @@ -291,9 +281,7 @@ def get_trgt_repeat_res(variant_info, repeat_info):
continue

if len(mcs) > 1:
pathologic_mcs = repeat_info[repeat_id].get(
"pathologic_struc", range(len(mcs))
)
pathologic_mcs = repeat_info[repeat_id].get("pathologic_struc", range(len(mcs)))

for index, count in enumerate(mcs):
if index in pathologic_mcs:
Expand Down Expand Up @@ -389,9 +377,7 @@ def get_individual_index(header_info):
return individual_index


def update_decomposed_variant_format_fields(
variant_info, header_info, individual_index
):
def update_decomposed_variant_format_fields(variant_info, header_info, individual_index):
"""
Update variant_info individual FORMAT fields with information found in the now up to date
format_dicts.
Expand Down Expand Up @@ -454,8 +440,8 @@ def decompose_var(variant_info):
if field in ["GT"]:
continue
variant_component_value = individual_value.split(",")[variant_component]
result_variants[index]["format_dicts"][individual_index][field] = (
variant_component_value
)
result_variants[index]["format_dicts"][individual_index][
field
] = variant_component_value

return result_variants

0 comments on commit ed2a26d

Please sign in to comment.