-
Notifications
You must be signed in to change notification settings - Fork 8
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
Rewrite headers when write mode is append? #21
Comments
Thanks for asking this question. I did only consider |
Thanks for your reply! |
Ah, so you would need to either keep ~10,000 file handles open or open and append to an existing file. I think that is a reasonable use case, and I'll take a look to see how that could be implemented here. |
Yeah, it troubles me hours 😅. |
@xizhihui I've added some initial support for appending to existing SAM files using Lines 223 to 242 in 8e914ce
|
If you want to test this out, you can install from the develop branch using |
Thanks for you updating. I've tested it. In this check code, if mode is append and if self.file.mode == 'a' and self.file.tell() == 0:
# We're appending to an empty file. Assume we need a header.
self._merge_header(header)
self._header_dict_write()
elif self.file.mode == 'a' and self.file.tell() > 0:
if header:
raise NotImplementedError("Updating headers on existing SAM files is not supported.\n")
else:
self._merge_header(header)
self._header_dict_write() |
Thanks @xizhihui. I've incorporated that change and will push this as a new point release. |
Add support for appending to existing SAM files (#21).
Closing this as the change is now in v0.1.4.0. Please let me know if there's anything else I can do to make your use case work better! |
Hi, it seems that headers will be append many times if I append contents to an existing sam when these contents are not appended in just one time(open and close multiple times). Or in other words, does simplesam only support for write not append?
The text was updated successfully, but these errors were encountered: