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

Does add_format function work with multisample vcf file ? #157

Open
giacuong171 opened this issue Sep 7, 2023 · 1 comment
Open

Does add_format function work with multisample vcf file ? #157

giacuong171 opened this issue Sep 7, 2023 · 1 comment

Comments

@giacuong171
Copy link

I'm using vcfpy to add an extra field in FORMAT of each record of a multisamples vcf file. From the document, i think that the function add_format would help me to do that. However, it keeps adding the same values for every sample. How can i add different value for each sample?

@giacuong171
Copy link
Author

def add_format(self, key, value=None):
        """Add an entry to format

        The record's calls ``data[key]`` will be set to ``value`` if not yet
        set and value is not ``None``.  If key is already in FORMAT then
        nothing is done.
        """
        if key in self.FORMAT:
            return
        self.FORMAT.append(key)
        if value is not None:
            for call in self:
                call.data.setdefault(key, value)

What I understand is that, in this code line "call.data.setdefault(key,value)", key here should be the new field in the Format,and value should be the value for that new field. If so, then it will add the same value for all samples ?

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

1 participant