Deduplicate template hits by sequence - #348
Conversation
jandom
left a comment
There was a problem hiding this comment.
Great PR, thank you @etowahadams – there are some minor linting problems
| # A2. Deduplicate by ungapped hit sequence, keeping the first | ||
| # (highest-ranked) occurrence. Without this, multiple hits that cover | ||
| # the same query region with identical residues (e.g. several crystal | ||
| # forms of the same complex) each consume a separate template slot. | ||
| if self.deduplicate_sequences: | ||
| if template.seq in seen_sequences: | ||
| if self.create_logs: | ||
| worker_logger.info( | ||
| f"{template.entry_id} {template.chain_id} is a" | ||
| " sequence duplicate of an already-accepted" | ||
| " template." | ||
| ) | ||
| continue | ||
| seen_sequences.add(template.seq) | ||
|
|
There was a problem hiding this comment.
major: let's pull this out into a testable unit of code (a function) and putting under test
| max_release_date: datetime | None = None | ||
| min_release_date_diff: int | None = None | ||
| max_templates: int = 20 | ||
| deduplicate_sequences: bool = True |
There was a problem hiding this comment.
nits: boolean flags are typically a code smell, we should probably wrap this in a configuration object – but this is out of scope for this PR
| "M8Parser leaves TemplateData.seq unset, so the dedup check in " | ||
| "step A2 compares None while step H records the sequence " | ||
| "recovered by the step E realignment. The check never matches and " | ||
| "deduplicate_sequences is a no-op on the ColabFold path." |
jandom
left a comment
There was a problem hiding this comment.
After my changes i'm obviously happy with this :D
@etowahadams would be great if you could take another look?
| if self.deduplicate_sequences: | ||
| if template.seq in seen_sequences: | ||
| if self.create_logs: | ||
| worker_logger.info( | ||
| f"{template.entry_id} {template.chain_id} is a" | ||
| " sequence duplicate of an already-accepted template." | ||
| ) | ||
| continue | ||
| seen_sequences.add(template.seq) |
There was a problem hiding this comment.
this is moved significantly more down than it was: depending on the input (a3m, has sequence; m8 no sequence, needs to get seq from cif), the sequence is not available until this step
During inference, we allow for templates to have the same sequence. This is different from the behavior in AF3, where template hits with the same sequence are filtered out, such that the templates all have different sequences. This PR implements those changes.