dridk / PyVCF3

A Variant Call Format reader for Python.
http://pyvcf.readthedocs.org/en/latest/index.html
Other
52 stars 9 forks source link

VCF writer - no way to pass escapechar param #12

Open davmlaw opened 2 months ago

davmlaw commented 2 months ago

If you try and write a string that needs escaping, writing fails with:

need to escape, but no escapechar set

Fix would be to add an escapechar param. Or, just allow **kwargs that you pass to csv.writer (let me know if you want a pull request but this is super simple)

Workaround is to override the writer property

    vcf_writer = Writer(f, vcf_reader)
    # Need to pass escapechar so redefine writer
    vcf_writer.writer = csv.writer(
        f,
        delimiter="\t",
        lineterminator="\n",
        quoting=csv.QUOTE_NONE,
        escapechar="\\",
    )