-
Notifications
You must be signed in to change notification settings - Fork 55
Fix check_sequence filter #80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -143,7 +143,7 @@ def parse_representatives( | |||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| # Template cache construction | ||||||||||||||||||||||||||||||||||||
| def check_sequence( | ||||||||||||||||||||||||||||||||||||
| query_seq: str, | ||||||||||||||||||||||||||||||||||||
| query: TemplateHit, | ||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not strictly related to this PR, but could we update docstring for TemplateHit? Some of the fields seem out of date: openfold-3/openfold3/core/data/io/sequence/template.py Lines 69 to 85 in 0b9df93
|
||||||||||||||||||||||||||||||||||||
| hit: TemplateHit, | ||||||||||||||||||||||||||||||||||||
| max_subseq: float = 0.95, | ||||||||||||||||||||||||||||||||||||
| min_align: float = 0.1, | ||||||||||||||||||||||||||||||||||||
|
|
@@ -152,8 +152,8 @@ def check_sequence( | |||||||||||||||||||||||||||||||||||
| """Applies sequence filters to template hits following AF3 SI Section 2.4. | ||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we add a quick description of the template filters from this section. AFAICT from the code, these filters are:
Digging into the second statement, the anticipated outputs are:
If the above understanding is correct, I am not sure if this would resolve the issue raised in the test example given in #72 . In that case, we have a hit which has 100% coverage, but has a different sequence value. In that test case, I believe the function would still fail the checks in this function. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| Args: | ||||||||||||||||||||||||||||||||||||
| query_seq (str): | ||||||||||||||||||||||||||||||||||||
| The query sequence. | ||||||||||||||||||||||||||||||||||||
| query (TemplateHit): | ||||||||||||||||||||||||||||||||||||
| The query template_hit. | ||||||||||||||||||||||||||||||||||||
| hit (TemplateHit): | ||||||||||||||||||||||||||||||||||||
| Candidate template hit. | ||||||||||||||||||||||||||||||||||||
| max_subseq (float, optional): | ||||||||||||||||||||||||||||||||||||
|
|
@@ -167,13 +167,32 @@ def check_sequence( | |||||||||||||||||||||||||||||||||||
| bool: | ||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we update the return description to reflect the 3 values that are now being returned? Also, it doesn't appear that we use the other return values of query_aln and hit_aln. Perhaps it would be easier to add these return values later if/when they are needed? |
||||||||||||||||||||||||||||||||||||
| Whether the hit passes the sequence filters. | ||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||
| query_seq = query.hit_sequence.replace("-", "") | ||||||||||||||||||||||||||||||||||||
| hit_seq = hit.hit_sequence.replace("-", "") | ||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||
| ((len(hit_seq) / len(query_seq)) > max_subseq) | ||||||||||||||||||||||||||||||||||||
| | ((hit.aligned_cols / len(query_seq)) < min_align) | ||||||||||||||||||||||||||||||||||||
| | (len(hit_seq) < min_len) | ||||||||||||||||||||||||||||||||||||
| if len(hit_seq) < min_len: | ||||||||||||||||||||||||||||||||||||
| return True, None, None | ||||||||||||||||||||||||||||||||||||
| query_aln = np.frombuffer( | ||||||||||||||||||||||||||||||||||||
| query.hit_sequence.replace(".", "-").encode("ascii"), dtype="S1" | ||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||
| hit_aln = np.frombuffer( | ||||||||||||||||||||||||||||||||||||
| hit.hit_sequence.replace(".", "-").encode("ascii"), dtype="S1" | ||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| query_not_gap = query_aln != b"-" | ||||||||||||||||||||||||||||||||||||
| hit_not_gap = hit_aln != b"-" | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| columns_to_keep = query_not_gap & hit_not_gap | ||||||||||||||||||||||||||||||||||||
| covered = columns_to_keep.sum() | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| coverage = covered / (len(query_seq) or 1) | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| if coverage < min_align: | ||||||||||||||||||||||||||||||||||||
| return True, None, None | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| identical = (columns_to_keep & (query_not_gap == hit_not_gap)).sum() | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| return coverage >= max_subseq and identical == covered, query_aln, hit_aln | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| def parse_release_date(cif_file: CIFFile) -> datetime: | ||||||||||||||||||||||||||||||||||||
| """Parses the release date of a structure from its CIF file. | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we consider making this function name more descriptive. Perhaps something like "check_seqence_similarity_within_range"?