Skip to content

Commit

Permalink
Merge pull request #288 from jeromekelleher/move-recombinant-matching…
Browse files Browse the repository at this point in the history
…-offline

Move recombinant processing offline
  • Loading branch information
jeromekelleher authored Sep 20, 2024
2 parents b140386 + 9a0e133 commit f3f750e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 79 deletions.
13 changes: 1 addition & 12 deletions sc2ts/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,21 +461,10 @@ def match_samples(
cost = hmm_match.get_hmm_cost(num_mismatches)
# print(f"Final HMM pass:{sample.strain} hmm_cost={cost} {sample.summary()}")
logger.debug(f"Final HMM pass hmm_cost={cost} {sample.summary()}")
if sample.is_recombinant:
recombinants.append(sample)

if len(recombinants) > 0:
match_recombinants(
recombinants,
base_ts,
num_mismatches=num_mismatches,
show_progress=show_progress,
num_threads=num_threads,
)

return samples



def check_base_ts(ts):
md = ts.metadata
assert "sc2ts" in md
Expand Down
69 changes: 2 additions & 67 deletions tests/test_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,37 +630,7 @@ def test_recombinant_example_1(self, tmp_path, fx_ts_map, fx_alignment_store):
{"left": 15324, "parent": 52, "right": 29904},
],
}
assert smd["hmm_reruns"] == {
"forward": {
"mutations": [],
"path": [
{"left": 0, "parent": 36, "right": 15324},
{"left": 15324, "parent": 52, "right": 29904},
],
},
"no_recombination": {
"mutations": [
{
"derived_state": "T",
"inherited_state": "C",
"site_position": 15324,
},
{
"derived_state": "T",
"inherited_state": "C",
"site_position": 29303,
},
],
"path": [{"left": 0, "parent": 36, "right": 29904}],
},
"reverse": {
"mutations": [],
"path": [
{"left": 0, "parent": 36, "right": 3788},
{"left": 3788, "parent": 52, "right": 29904},
],
},
}
assert smd["hmm_reruns"] == {}

recomb_node = ts.node(ts.num_nodes - 1)
assert recomb_node.flags == sc2ts.NODE_IS_RECOMBINANT
Expand Down Expand Up @@ -755,42 +725,7 @@ def test_recombinant_example_2(self, tmp_path, fx_ts_map, fx_alignment_store):
],
}

assert smd["hmm_reruns"] == {
"forward": {
"mutations": [],
"path": [
{"left": 0, "parent": 62, "right": 29800},
{"left": 29800, "parent": 63, "right": 29904},
],
},
"no_recombination": {
"mutations": [
{
"derived_state": "A",
"inherited_state": "G",
"site_position": 29800,
},
{
"derived_state": "A",
"inherited_state": "C",
"site_position": 29801,
},
{
"derived_state": "A",
"inherited_state": "C",
"site_position": 29802,
},
],
"path": [{"left": 0, "parent": 62, "right": 29904}],
},
"reverse": {
"mutations": [],
"path": [
{"left": 0, "parent": 62, "right": 113},
{"left": 113, "parent": 63, "right": 29904},
],
},
}
assert smd["hmm_reruns"] == { }

def test_all_As(self, tmp_path, fx_ts_map, fx_alignment_store):
# Same as the recombinant_example_1() function above
Expand Down

0 comments on commit f3f750e

Please sign in to comment.