dgomezpere / msm_tfm

Development of an application to visualize, annotate and prioritize somatic variants in cancer
0 stars 0 forks source link

[vcf_etl%vcf_header] Document VcfHeader class, methods and decorators #10

Closed dgomezpere closed 2 years ago

dgomezpere commented 2 years ago

:warning: IMPORTANT NOTE

:warning: Follow as much as possible the following examples to document the docstrings.

:warning: If there is any question, ask me in the comments of this issue!!

:warning: Commit changes in msm branch

Examples

class VcfHeader:
    def __init__(self, filepath=None):
        """
        Class to store metadata information from the header of a VCF formatted file.
        :param filepath: path/to/file.vcf(.gz)
        """
        # Initialize all properties to None
        self._vcf_filepath = None
        self._header = None
        self._file_format = None
    # Private methods
    def _load_header_from_vcf_filepath(self, filepath: str) -> vcfpy.header.Header:
        """
        Loads the header content from a VCF filepath in a vcfpy.header.Header class.
        :param filepath: path/to/file.vcf
        """
        self._header = vcfpy.Reader.from_path(filepath).header
    @property
    def variant_caller(self):
        """
        Returns a VariantCaller object (see VariantCaller class)
        :return: VariantCaller
        """
        return self._variant_caller
    @variant_caller.setter
    def variant_caller(self, value):
        """
        Creates a VariantCaller object from a dict with required keys and values.
        :param value: Dict with the following format:
            {
                "name": str,
                "version": str,
            }
        """
        if type(value) == dict:
            self._variant_caller = VariantCaller()
            self._variant_caller.mapping = value