Skip to content

Commit

Permalink
feat: add a function to handle both cram and vcf/bcf BytesIO buffers.
Browse files Browse the repository at this point in the history
  • Loading branch information
AssafSternberg committed May 10, 2024
1 parent a25f7b8 commit a262035
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions modo/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def bytesio_to_alignment_segments(

def bytesio_to_iterator(
bytesio_buffer: BytesIO,
fileformat: str,
file_format: str,
reference_filename: Optional[str] = None,
) -> Iterator[AlignedSegment | VariantRecord]:
"""Takes a BytesIO buffer and returns a pysam iterator of
Expand All @@ -291,11 +291,11 @@ def bytesio_to_iterator(
temp_file.seek(0)

# Open the temporary file as a pysam.AlignmentFile/VarianFile object
if fileformat == "CRAM":
if file_format == "CRAM":
pysamFile = AlignmentFile(
temp_file.name, "rc", reference_filename=reference_filename
)
elif fileformat in ("VCF", "BCF"):
elif file_format in ("VCF", "BCF"):
# write_mode = r if fileformat=="VCF" else "rb"
pysamFile = VariantFile(temp_file.name, "rb")
with pysamFile as in_file:
Expand Down

0 comments on commit a262035

Please sign in to comment.