Skip to content
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

Expose generate_alignment + generate_hgvs_variants_from_alignment functions #18

Merged
merged 7 commits into from
Jul 1, 2024

Conversation

austin-mbs
Copy link
Contributor

@austin-mbs austin-mbs commented Jun 27, 2024

Description

As part of the alignment work, we are exposing some additional functions that can be used externally.

  • generate_alignment (Builds a HGVS Alignment object)
  • generate_hgvs_variants_from_alignment (Skipping alignment generation)

Also, as part of this PR

  • Updated docs - make import rules more explicitly mentioned - internals should not be used

Relevant Links

N/A

Screenshots & Media

N/A

Testing

  • Unit Tests added

Code Flow

N/A

Edge cases / Breaking Changes / Known Issues

N/A

@heuermh heuermh self-requested a review June 28, 2024 15:47
README.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor typo, provides → provide

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

boolean flags for strategies are not my favorite, could a separate method make a better API? Or perhaps allow the strategy to be passed in?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is existing functionality that is just getting moved so it would be a breaking change to get rid of the flag. Don't think it's worth doing right now, but I am open to a change in a follow up PR if you feel its important. Personally I find the ergonomics of passing a boolean to be a bit better then some string that represents the "method" you want (we'd likely want some kind of constant / enum, etc). If there were a bunch of methods it would make more sense.

Copy link
Contributor

@mbiokyle29 mbiokyle29 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few notes on doc-strings and tests that should not have been moved. If you could also get tests added for the new generate_hgvs_variants_from_alignment and populate the PR description with a bit more info, that would be great. Thanks for this!

"""
Given a pairwise alignment object and a molecule type, generate a list of HGVS SequenceVariants.

- Alignment: Generated via BioPython.PairwiseAligner - (`generate_alignment` for more information)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"See generate_alignemt for more information"

Comment on lines 35 to 36


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you trim this excess white space?

def generate_hgvs_variants_from_alignment(
alignment: Alignment, use_non_standard_substitution_rules: bool = False, molecule_type: str = MOLECULE_TYPE_PROTEIN
) -> list[SequenceVariant]:
"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding some examples here using the follow format might be nice for the API docs:

    .. code-block:: python

        >>> from palamedes import generate_hgvs_variants
        >>> generate_hgvs_variants("PFKISIHL", "TPFKISIH")
        [
            SequenceVariant(ac=ref, type=p, posedit=Pro1extThr-1, gene=None),
            SequenceVariant(ac=ref, type=p, posedit=Leu8del, gene=None),
        ]

This is from the doc string for generate_hgvs_variants

molecule_type: str = MOLECULE_TYPE_PROTEIN,
aligner: PairwiseAligner | None = None,
) -> Alignment:
"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is public now, can you add some code example to the doc string, using the same block as above?

Comment on lines +209 to +211
raise NotImplementedError(
f"Type {molecule_type} unsupported or unrecognized! Current supported types: {','.join(BUILDER_CONFIG.keys())}"
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for making this error message better!

@@ -0,0 +1,216 @@
from palamedes import generate_variant_blocks, generate_alignment
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generate_variant_blocks is still defined in align.py, so the tests for it should stay in there. Only generate_alignment was moved.

mbiokyle29
mbiokyle29 previously approved these changes Jul 1, 2024
Copy link
Contributor

@mbiokyle29 mbiokyle29 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@austin-mbs austin-mbs merged commit b5b33bc into main Jul 1, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants