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

feat: use primer3-py for primer3 instead of the executable #101

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nh13
Copy link
Member

@nh13 nh13 commented Dec 13, 2024

No description provided.

@@ -208,7 +208,7 @@ def __str__(self) -> str:
"""
# If the bases field is None, replace with MISSING_BASES_STRING
bases: str = self.bases if self.bases is not None else MISSING_BASES_STRING
return f"{bases}\t{self.tm}\t{self.penalty}\t{self.span}"
return f"{bases}\t{self.tm:.2f}\t{self.penalty:.2f}\t{self.span}"
Copy link
Member Author

Choose a reason for hiding this comment

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

QoL improvement

Copy link

codecov bot commented Dec 14, 2024

Codecov Report

Attention: Patch coverage is 92.59259% with 2 lines in your changes missing coverage. Please review.

Please upload report for BASE (main@3c3ed80). Learn more about missing BASE report.
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
prymer/primer3/primer3.py 92.30% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #101   +/-   ##
=======================================
  Coverage        ?   96.87%           
=======================================
  Files           ?       26           
  Lines           ?     1695           
  Branches        ?      184           
=======================================
  Hits            ?     1642           
  Misses          ?       31           
  Partials        ?       22           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@tfenne tfenne left a comment

Choose a reason for hiding this comment

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

This is very cool - and I'm surprised at actually how small of a PR this is!!

Comment on lines +387 to +392
for tag, value in assembled_primer3_tags.items():
tag_str = f"{tag}"
if tag_str.startswith("SEQUENCE"):
seq_args[tag_str] = value
else:
global_args[tag] = value
Copy link
Member

Choose a reason for hiding this comment

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

This works ... but I think we could probably also add a is_global_arg() to Primer3InputTag that does this more efficiently (e.g. based on ordinal) or split Primer3InputTag into two classes - one for globals and one for sequence tags?

Comment on lines +396 to +401
for key, value in design_primers_retval.items():
# Because Primer3 will emit both the input given and the output generated, we
# discard the input that is echo'ed back by looking for tags (keys)
# that do not match any Primer3InputTag
if not any(key == item.value for item in Primer3InputTag):
primer3_results[key] = value
Copy link
Member

Choose a reason for hiding this comment

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

Is this actually needed? I don't think there's any harm in allow the inputs to be present in the dict() used below.

If you feel strongly about this .. perhaps we have a more efficient way than looping through all the values in Primer3InputTag - e.g. create a _ALL_INPUT_TAG_STRINGS set and at the class level and check for membership?

Comment on lines 403 to 410
def primer3_error(message: str) -> None:
"""Formats the Primer3 error and raises a ValueError."""
error_message = f"{message}: "
# add in any reported PRIMER_ERROR
if "PRIMER_ERROR" in primer3_results:
error_message += primer3_results["PRIMER_ERROR"]
# add in any error lines
if len(error_lines) > 0:
error_message += "\n".join(f"\t\t{e}" for e in error_lines)
# raise the exception now
raise ValueError(error_message)
Copy link
Member

Choose a reason for hiding this comment

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

I think this can be inline at the single call site now?

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.

2 participants