You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using pysam.bcftools.concat to concatenate VCF files, the -o option (for specifying the output file) is ignored. Instead, the concatenated output is written to stdout. This behavior is unexpected and makes it difficult to directly specify an output file during concatenation.
import pysam
import pysam.bcftools
import os
def create_dummy_vcf(filename, chrom, pos, ref, alt):
"""Creates a dummy VCF file with minimal content."""
header = (
"##fileformat=VCFv4.2\n"
f"##contig=<ID={chrom}>\n" # Add contig definition
"#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\n"
)
content = f"{chrom}\t{pos}\t.\t{ref}\t{alt}\t.\tPASS\t.\n"
with open(filename, "w") as vcf:
vcf.write(header)
vcf.write(content)
# Create two dummy VCF files
vcf1 = "dummy1.vcf"
vcf2 = "dummy2.vcf"
output_vcf = "concatenated.vcf"
create_dummy_vcf(vcf1, "chr1", 100, "A", "T")
create_dummy_vcf(vcf2, "chr1", 200, "G", "C")
# Attempt to concatenate using pysam.bcftools.concat
try:
out = pysam.bcftools.concat( '-o', output_vcf, vcf1, vcf2, catch_stdout=True)
if os.path.exists(output_vcf):
print(f"Output VCF successfully created: {output_vcf}")
else:
print(f"Output VCF not created as expected. Check stdout.")
print(out)
except Exception as e:
print(f"An error occurred: {e}")
# Clean up dummy files
os.remove(vcf1)
os.remove(vcf2)
if os.path.exists(output_vcf):
os.remove(output_vcf)
The text was updated successfully, but these errors were encountered:
When using pysam.bcftools.concat to concatenate VCF files, the -o option (for specifying the output file) is ignored. Instead, the concatenated output is written to stdout. This behavior is unexpected and makes it difficult to directly specify an output file during concatenation.
The text was updated successfully, but these errors were encountered: