Skip to content

Commit

Permalink
Fix bug with individual genotype correction
Browse files Browse the repository at this point in the history
  • Loading branch information
PedroBarbosa committed Apr 22, 2024
1 parent f2923f5 commit fd20890
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 25 deletions.
2 changes: 1 addition & 1 deletion dress/datasetgeneration/config_evolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def correct_phenotypes(
genotype_to_phenotype=rep.genotype_to_phenotype, # type: ignore
)
is_valid = (
True if _is_valid_individual(ind, original_seq, excluded_regions, rs) else False
True if _is_valid_individual(_ind, original_seq, excluded_regions, rs) else False
)

new_pop.append(_ind) # type: ignore
Expand Down
28 changes: 4 additions & 24 deletions dress/datasetgeneration/grammars/pwm_perturbation_grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def remove_diffunit_overlaps(
if isinstance(d, MotifSNV) and d.is_redundant(seq):
d.sample_new_nucleotide(rs)

if isinstance(d, MotifDeletion):
if isinstance(d, (MotifDeletion, MotifAblation)):
current_r = [
1,
d.position[0],
Expand All @@ -162,8 +162,8 @@ def remove_diffunit_overlaps(
]

elif isinstance(
d, (MotifInsertion, MotifSubstitution, MotifAblation, MotifSNV)
):
d, (MotifInsertion, MotifSubstitution, MotifSNV)
):
current_r = [1, d.position, d.position + 1, d.get_size(), str(d)]

else:
Expand Down Expand Up @@ -360,17 +360,7 @@ def perturb(self, seq: str, position_tracker: int) -> str:
)

def adjust_index(self, ss_indexes: List[list]) -> List[list]:
_ss_idx = list(itertools.chain(*ss_indexes))

adj = [
(
ss - self.get_size()
if isinstance(ss, int) and self.position[0] < ss
else ss
)
for ss in _ss_idx
]
return [adj[0:2], adj[2:4], adj[4:6]]
return ss_indexes

def get_size(self) -> int:
return self.position[1] - self.position[0]
Expand Down Expand Up @@ -417,16 +407,6 @@ def get_distance_to_cassette(self) -> int:
def __str__(self):
return f"MotifSubstitution[{self.position},{self.nucleotides[0]},{self.get_size()},{self.get_location()},{self.get_distance_to_cassette()}]"

# grammar_nodes = []
# grammar_map = {'snv_weight': MotifSNV,
# 'deletion_weight': MotifDeletion,
# 'insertion_weight': MotifInsertion,
# 'motif_ablation_weight': MotifAblation,
# 'motif_substitution_weight': MotifSubstitution}

# for _arg, nodename in grammar_map.items():
# if kwargs[_arg] > 0:
# grammar_nodes.append(weight(kwargs[_arg])(nodename))
g = extract_grammar(
[
weight(kwargs["snv_weight"])(MotifSNV),
Expand Down

0 comments on commit fd20890

Please sign in to comment.