-
Notifications
You must be signed in to change notification settings - Fork 75
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
Fasta more dict-like behaviour #156
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a6a1253
Fasta more dict-like behaviour
Maarten-vd-Sande 99a9f69
add keys, values, items to Fasta class
Maarten-vd-Sande cede320
minor keys bug fix and list comprehension to dict comprehension
Maarten-vd-Sande 2f82d43
remove debugging print
Maarten-vd-Sande 990a22c
Add some debugging for #156 failing test
mdshw5 8995223
Fix for record insertion order in #156
mdshw5 80ad273
Bump version for release
mdshw5 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -997,13 +997,13 @@ def __init__(self, | |
sequence_always_upper=sequence_always_upper, | ||
rebuild=rebuild, | ||
build_index=build_index) | ||
self.keys = self.faidx.index.keys | ||
if not self.mutable: | ||
self.records = dict( | ||
[(rname, FastaRecord(rname, self)) for rname in self.keys()]) | ||
self.records = {rname: FastaRecord(rname, self) | ||
for rname in self.faidx.index.keys()} | ||
elif self.mutable: | ||
self.records = dict([(rname, MutableFastaRecord(rname, self)) | ||
for rname in self.keys()]) | ||
self.records = {rname: MutableFastaRecord(rname, self) | ||
for rname in self.faidx.index.keys()} | ||
|
||
|
||
def __contains__(self, rname): | ||
"""Return True if genome contains record.""" | ||
|
@@ -1060,6 +1060,15 @@ def get_spliced_seq(self, name, intervals, rc=False): | |
# len(Sequence.seq) != end - start | ||
return Sequence(name=name, seq=seq, start=None, end=None) | ||
|
||
def keys(self): | ||
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. I agree that this brings clarity to the methods. |
||
return self.records.keys() | ||
|
||
def values(self): | ||
return self.records.values() | ||
|
||
def items(self): | ||
return self.records.items() | ||
|
||
def close(self): | ||
self.__exit__() | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Great! You can ignore my previous comment.
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.
It seems like dictionary key insertion order is the issue, and I will update here to do something similar to what the
Fasta.keys
method currently relies on:pyfaidx/pyfaidx/__init__.py
Line 399 in f1668d2