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

Support stdin/stdout in sam.reader and sam.writer #67

Closed
msto opened this issue Oct 21, 2023 · 1 comment
Closed

Support stdin/stdout in sam.reader and sam.writer #67

msto opened this issue Oct 21, 2023 · 1 comment

Comments

@msto
Copy link
Contributor

msto commented Oct 21, 2023

It would be helpful if sam.reader() and sam.writer() supported the special cases of "-" and/or "stdin" and "stdout" to open sys.stdin and sys.stdout directly for reading/writing

to avoid verbosity like the following

in_bam_path: SamPath = sys.stdin if str(in_bam) in ["-", "stdin"] else in_bam

out_bam_path: SamPath
out_file_type: Optional[SamFileType]
if str(out_bam) in ["-", "stdout"]:
    out_bam_path = sys.stdout
    out_file_type = SamFileType.SAM
else:
    out_bam_path = out_bam
    out_file_type = None
    
with (
    reader(in_bam_path) as bam_reader,
    writer(
        out_bam_path,
        header=bam_reader.header,
        file_type=out_file_type,
    ) as bam_writer,
@nh13
Copy link
Member

nh13 commented Jul 13, 2024

Implemented in #69

@nh13 nh13 closed this as completed Jul 13, 2024
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

No branches or pull requests

2 participants