Skip to content

Commit

Permalink
lint(call): rename candidate_snvs_dict to candidate_snvs + reflow
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlougheed committed Jun 11, 2024
1 parent e3bd011 commit bea6040
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
12 changes: 6 additions & 6 deletions strkit/call/call_locus.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ def call_alleles_with_incorporated_snvs(
read_dict_extra: dict[str, dict],
n_reads_in_dict: int, # We could derive this again, but we already have before...
useful_snvs: list[tuple[int, int]],
candidate_snvs_dict: CandidateSNVs,
candidate_snvs: CandidateSNVs,
# ---
snv_quality_threshold: int,
# ---
Expand Down Expand Up @@ -656,7 +656,7 @@ def call_alleles_with_incorporated_snvs(
n_alleles,
read_dict,
useful_snvs,
candidate_snvs_dict,
candidate_snvs,
# ---
snv_quality_threshold,
# ---
Expand Down Expand Up @@ -909,10 +909,10 @@ def call_locus(

# Find candidate SNVs, if we're using SNV data

candidate_snvs_dict: Optional[CandidateSNVs] = None # Lookup dictionary for candidate SNVs by position
candidate_snvs: Optional[CandidateSNVs] = None # Lookup dictionary for candidate SNVs by position
if n_overlapping_reads and should_incorporate_snvs and snv_vcf_file:
# ^^ n_overlapping_reads check since otherwise we will have invalid left/right_most_coord
candidate_snvs_dict = snv_vcf_file.get_candidate_snvs(
candidate_snvs = snv_vcf_file.get_candidate_snvs(
snv_vcf_contigs, snv_vcf_file_format, contig, left_most_coord, right_most_coord
)

Expand Down Expand Up @@ -1309,7 +1309,7 @@ def call_locus(
read_dict_extra,
read_q_coords,
read_r_coords,
candidate_snvs_dict,
candidate_snvs,
params.min_allele_reads,
significant_clip_snv_take_in,
only_known_snvs,
Expand All @@ -1329,7 +1329,7 @@ def call_locus(
read_dict_extra=read_dict_extra,
n_reads_in_dict=n_reads_in_dict,
useful_snvs=useful_snvs,
candidate_snvs_dict=candidate_snvs_dict,
candidate_snvs=candidate_snvs,
# ---
snv_quality_threshold=snv_min_base_qual,
# ---
Expand Down
6 changes: 2 additions & 4 deletions strkit/call/repeats.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,13 @@ def score_ref_boundaries(db_seq: str, tr_candidate: str, flank_left_seq: str, fl

# Always assign parasail results to variables due to funky memory allocation behaviour
ext_r_seq = f"{flank_left_seq}{tr_candidate}"
r_fwd = parasail.sg_de_scan_sat(
ext_r_seq, db_seq, indel_penalty, indel_penalty, dna_matrix)
r_fwd = parasail.sg_de_scan_sat(ext_r_seq, db_seq, indel_penalty, indel_penalty, dna_matrix)
r_adj = r_fwd.end_ref + 1 - len(flank_left_seq) - ref_size # Amount to tweak boundary on the right side by

db_seq_rev = db_seq[::-1]
ext_l_seq = f"{tr_candidate}{flank_right_seq[max(r_adj, 0):]}"[::-1] # reverse

r_rev = parasail.sg_de_scan_sat(
ext_l_seq, db_seq_rev, indel_penalty, indel_penalty, dna_matrix)
r_rev = parasail.sg_de_scan_sat(ext_l_seq, db_seq_rev, indel_penalty, indel_penalty, dna_matrix)
l_adj = r_rev.end_ref + 1 - len(flank_right_seq) - ref_size # Amount to tweak boundary on the left side by

return (r_fwd.score, r_adj), (r_rev.score, l_adj)
Expand Down
6 changes: 3 additions & 3 deletions strkit/call/snvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def call_and_filter_useful_snvs(
n_alleles: int,
read_dict: dict[str, ReadDict],
useful_snvs: list[tuple[int, int]],
candidate_snvs_dict: CandidateSNVs,
candidate_snvs: CandidateSNVs,
# ---
snv_quality_threshold: int,
# ---
Expand All @@ -42,7 +42,7 @@ def call_and_filter_useful_snvs(
:param n_alleles: The number of alleles called for this locus.
:param read_dict: Dictionary of read data. Must already have peaks assigned.
:param useful_snvs: List of tuples representing useful SNVs: (SNV index, reference position)
:param candidate_snvs_dict: A dictionary of useful SNVs, indexed by reference position. Used to look up IDs.
:param candidate_snvs: A dictionary of useful SNVs, indexed by reference position. Used to look up IDs.
:param snv_quality_threshold: Minimum PHRED score needed to incorporate a read base into the genotype.
:param snv_genotype_cache: Cache for SNV genotype/phase set information.
:param locus_log_str: Locus string representation for logging purposes.
Expand Down Expand Up @@ -134,7 +134,7 @@ def call_and_filter_useful_snvs(
logger_.warning(f"{locus_log_str} - for SNV position {u_ref}: got degenerate call {call} from {peak_counts=}")
skipped = True

snv_rec = candidate_snvs_dict.get(u_ref)
snv_rec = candidate_snvs.get(u_ref)
if snv_rec is not None:
snv_id = snv_rec["id"]
if snv_id == ".":
Expand Down

0 comments on commit bea6040

Please sign in to comment.