Skip to content

Commit f6f7991

Browse files
Merge pull request #13 from scbirlab/dev
Guard empty paired MSAs. Also added phage TLS<->E. coli. to HPI map
2 parents cb873ed + 5452a69 commit f6f7991

6 files changed

Lines changed: 464723 additions & 16 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "yunta"
3-
version = "0.1.1"
3+
version = "0.1.2"
44
authors = [
55
{ name="Eachan Johnson", email="eachan.johnson@crick.ac.uk" },
66
]

yunta/data/20260516_hpi.csv

Lines changed: 464693 additions & 0 deletions
Large diffs are not rendered by default.

yunta/interaction_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
)
3232
_data_csv_path = os.path.join(
3333
_data_root,
34-
"20250409_hpi.csv",
34+
"20260516_hpi.csv",
3535
)
3636

3737

yunta/interactions/runner.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,22 @@ def _pair_msas(
2626
interaction_map: Optional[Union[str, Mapping[str, Iterable[str]]]] = None,
2727
enforce_ref_match: bool = False
2828
) -> PairedMSA:
29-
return (
30-
PairedMSA.from_msa(
29+
try:
30+
paired_msa = PairedMSA.from_msa(
3131
msa1,
3232
msa2,
3333
blocked=blocked,
3434
interaction_map=interaction_map,
3535
enforce_ref_match=enforce_ref_match,
3636
)
37-
.filter_by_gap_fraction(max_gap_fraction)
38-
)
37+
except AttributeError as e: # no pairs!
38+
print_err(f"[WARN] Skipping pair,", e)
39+
return None
40+
else:
41+
return (
42+
paired_msa
43+
.filter_by_gap_fraction(max_gap_fraction)
44+
)
3945

4046

4147
def _calculate_interaction_blocks(
@@ -173,6 +179,8 @@ def run(
173179
interaction_map=interaction_map,
174180
enforce_ref_match=enforce_ref_match,
175181
)
182+
if paired_msa is None: # failure
183+
return None, None, None
176184
print_err("[INFO] Generated", paired_msa)
177185
neff = paired_msa.neff()
178186

@@ -185,7 +193,7 @@ def run(
185193
chunksize=chunksize,
186194
use_sequences=self.use_sequences,
187195
use_id=self.use_id,
188-
**kwargs
196+
**kwargs,
189197
)
190198
result_interaction = results[:paired_msa.chain_a_length, paired_msa.chain_a_length:]
191199
scores = score_contact_map(result_interaction)

yunta/screening.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,18 @@ def _screen_one_vs_many(
4646
for msa2 in tqdm(msa_file2):
4747
if msa2 is not None:
4848
msa2 = MSA.from_file(msa2)
49-
results.append(
50-
runner().run(
51-
msa1=msa1,
52-
msa2=msa2,
53-
max_gap_fraction=max_gap_fraction,
54-
interaction_map=interaction_map,
55-
**kwargs,
56-
)
49+
result = runner().run(
50+
msa1=msa1,
51+
msa2=msa2,
52+
max_gap_fraction=max_gap_fraction,
53+
interaction_map=interaction_map,
54+
**kwargs,
5755
)
56+
if result[0] is not None:
57+
results.append(result)
58+
else:
59+
print_err(f"[WARN] Failed calculation for {msa1}, {msa2}. Continuing.")
60+
continue
5861
return results
5962

6063

yunta/structs/msa.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,10 @@ def from_msa(
579579
enforce_ref_match=enforce_ref_match,
580580
**kwargs
581581
)
582-
return cls(lines=msa_lines, chain_a_length=chain_a_length)
582+
if len(msa_lines) > 0:
583+
return cls(lines=msa_lines, chain_a_length=chain_a_length)
584+
else:
585+
raise AttributeError(f"Pairing {msa1} and {msa2} resulted in no pairs.")
583586

584587
@classmethod
585588
def from_file(

0 commit comments

Comments
 (0)