-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: main
Are you sure you want to change the base?
Conversation
@@ -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}" |
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.
QoL improvement
Codecov ReportAttention: Patch coverage is
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. |
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.
This is very cool - and I'm surprised at actually how small of a PR this is!!
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 |
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.
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?
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 |
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.
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?
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) |
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.
I think this can be inline at the single call site now?
No description provided.