-
Notifications
You must be signed in to change notification settings - Fork 3
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: overloaded 'SeqDict.from_sam()' method to support SAM files (#176) #183
base: main
Are you sure you want to change the base?
Conversation
TimD1
commented
Sep 4, 2024
- in addition to pysam SAM headers and SAM header dicts, SeqDicts can now be initialized from SAM file paths and pysam SAM files
- added basic tests for this new functionality
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #183 +/- ##
==========================================
- Coverage 91.06% 90.78% -0.28%
==========================================
Files 18 18
Lines 2283 2301 +18
Branches 337 339 +2
==========================================
+ Hits 2079 2089 +10
- Misses 133 142 +9
+ Partials 71 70 -1 ☔ View full report in Codecov by Sentry. |
2f19451
to
bdf1284
Compare
- in addition to pysam SAM headers and SAM header dicts, SeqDicts can now be initialized from SAM file paths and pysam SAM files - added basic tests for this new functionality
bdf1284
to
45f7eca
Compare
WalkthroughThe pull request introduces modifications to the Additionally, the Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration 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.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
fgpyo/fasta/sequence_dictionary.py
(4 hunks)pyproject.toml
(1 hunks)tests/fgpyo/fasta/test_sequence_dictionary.py
(3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: testing (3.10)
- GitHub Check: testing (3.9)
🔇 Additional comments (3)
fgpyo/fasta/sequence_dictionary.py (1)
481-499
:from_sam
method implementation effectively handles multiple input types.The use of an
if-elif-else
chain improves readability and accommodates various data inputs as specified.tests/fgpyo/fasta/test_sequence_dictionary.py (1)
335-338
: Test cases validate newfrom_sam
functionality.The added tests ensure that the method correctly processes
Path
andpysam.AlignmentFile
inputs.pyproject.toml (1)
92-96
: Excluding@overload
annotations from coverage improves report accuracy.Adjusting the coverage configuration aligns with best practices for handling type stubs.
except Exception as e: | ||
raise ValueError(f"Could not parse sequence information from data: {data}") from e |
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.
🛠️ Refactor suggestion
Avoid including raw data in exception messages.
Including the entire data
object in the error message may lead to verbose logs or expose sensitive information. Consider providing a more general error message.
Apply this diff to adjust the error message:
-except Exception as e:
- raise ValueError(f"Could not parse sequence information from data: {data}") from e
+except Exception as e:
+ raise ValueError("Could not parse sequence information from provided data.") from e
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
except Exception as e: | |
raise ValueError(f"Could not parse sequence information from data: {data}") from e | |
except Exception as e: | |
raise ValueError("Could not parse sequence information from provided data.") from e |
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.
Looking really good, nice work! Could you fix up the one TODO and the few other very minor things?
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
fgpyo/fasta/sequence_dictionary.py (1)
479-479
: Fix typo in docstring."refrence" should be "reference".
- A `SequenceDictionary` mapping refrence names to their metadata. + A `SequenceDictionary` mapping reference names to their metadata.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
fgpyo/fasta/sequence_dictionary.py
(4 hunks)tests/fgpyo/fasta/test_sequence_dictionary.py
(3 hunks)
🔇 Additional comments (5)
fgpyo/fasta/sequence_dictionary.py (4)
Line range hint
129-142
: LGTM!Imports and type hints are appropriate for the new functionality.
452-464
: LGTM!Method overloads provide clear type hints for all supported input types.
487-488
: LGTM!File handling follows best practices with proper resource cleanup.
496-497
: 🛠️ Refactor suggestionAvoid exposing raw data in error messages.
Including raw data in error messages could leak sensitive information.
- raise ValueError(f"Could not parse sequence information from data: {data}") from e + raise ValueError("Could not parse sequence information from provided data.") from eLikely invalid or redundant comment.
tests/fgpyo/fasta/test_sequence_dictionary.py (1)
335-343
: LGTM!Test coverage is comprehensive and follows best practices.