diff --git a/README.pdf b/README.pdf index 119a69f..286883f 100644 Binary files a/README.pdf and b/README.pdf differ diff --git a/RELEASE_NOTES.pdf b/RELEASE_NOTES.pdf index ae6ae2d..89c3994 100644 Binary files a/RELEASE_NOTES.pdf and b/RELEASE_NOTES.pdf differ diff --git a/docs/docs.pdf b/docs/docs.pdf index 60458c1..201b3e7 100644 Binary files a/docs/docs.pdf and b/docs/docs.pdf differ diff --git a/docs/help.configuration.calculation.pdf b/docs/help.configuration.calculation.pdf index c8552fd..da300a0 100644 Binary files a/docs/help.configuration.calculation.pdf and b/docs/help.configuration.calculation.pdf differ diff --git a/docs/help.configuration.pdf b/docs/help.configuration.pdf index d044506..24c4029 100644 Binary files a/docs/help.configuration.pdf and b/docs/help.configuration.pdf differ diff --git a/docs/help.configuration.prioritization.pdf b/docs/help.configuration.prioritization.pdf index e323ed9..50a85b5 100644 Binary files a/docs/help.configuration.prioritization.pdf and b/docs/help.configuration.prioritization.pdf differ diff --git a/docs/help.parameters.databases.pdf b/docs/help.parameters.databases.pdf index 6edc67d..4877440 100644 Binary files a/docs/help.parameters.databases.pdf and b/docs/help.parameters.databases.pdf differ diff --git a/docs/help.parameters.pdf b/docs/help.parameters.pdf index 14984d9..269d959 100644 Binary files a/docs/help.parameters.pdf and b/docs/help.parameters.pdf differ diff --git a/docs/help.pdf b/docs/help.pdf index 7189791..ada53c8 100644 Binary files a/docs/help.pdf and b/docs/help.pdf differ diff --git a/docs/pdoc/howard/objects/variants.html b/docs/pdoc/howard/objects/variants.html index 541f50d..83d5367 100644 --- a/docs/pdoc/howard/objects/variants.html +++ b/docs/pdoc/howard/objects/variants.html @@ -12108,9 +12108,9 @@
11753 def calculation_rename_info_fields( -11754 self, -11755 fields_to_rename: dict = None, -11756 table: str = None, -11757 operation_name: str = "RENAME_INFO_FIELDS", -11758 ) -> None: -11759 """ -11760 The `calculation_rename_info_fields` function retrieves parameters from a dictionary, updates -11761 fields to rename and table if provided, and then calls another function to rename the fields. -11762 -11763 :param fields_to_rename: `fields_to_rename` is a dictionary that contains the fields to be -11764 renamed in a table. Each key-value pair in the dictionary represents the original field name as -11765 the key and the new field name as the value -11766 :type fields_to_rename: dict -11767 :param table: The `table` parameter in the `calculation_rename_info_fields` method is used to -11768 specify the name of the table for which the fields are to be renamed. It is a string type -11769 parameter -11770 :type table: str -11771 :param operation_name: The `operation_name` parameter in the `calculation_rename_info_fields` -11772 method is a string that specifies the name of the operation being performed. In this context, it -11773 is used as a default value for the operation name if not explicitly provided when calling the -11774 function, defaults to RENAME_INFO_FIELDS -11775 :type operation_name: str (optional) -11776 """ -11777 -11778 # Param -11779 param = self.get_param() -11780 -11781 # Get param fields to rename -11782 param_fields_to_rename = ( -11783 param.get("calculation", {}) -11784 .get("calculations", {}) -11785 .get(operation_name, {}) -11786 .get("fields_to_rename", None) -11787 ) -11788 -11789 # Get param table -11790 param_table = ( -11791 param.get("calculation", {}) -11792 .get("calculations", {}) -11793 .get(operation_name, {}) -11794 .get("table", None) -11795 ) -11796 -11797 # Init fields_to_rename -11798 if fields_to_rename is None: -11799 fields_to_rename = param_fields_to_rename -11800 -11801 # Init table -11802 if table is None: -11803 table = param_table -11804 -11805 renamed_fields = self.rename_info_fields( -11806 fields_to_rename=fields_to_rename, table=table -11807 ) -11808 -11809 log.debug(f"renamed_fields:{renamed_fields}") +diff --git a/docs/tips.pdf b/docs/tips.pdf index 28cdc03..e615578 100644 Binary files a/docs/tips.pdf and b/docs/tips.pdf differ diff --git a/docs/user_guide.pdf b/docs/user_guide.pdf index eaf64ee..c099f38 100644 Binary files a/docs/user_guide.pdf and b/docs/user_guide.pdf differ diff --git a/howard/objects/variants.py b/howard/objects/variants.py index 0718f0d..6bd8a1d 100644 --- a/howard/objects/variants.py +++ b/howard/objects/variants.py @@ -11713,9 +11713,9 @@ def rename_info_fields( del header.infos[field_to_rename] # Rename INFO patterns - field_pattern = rf'(^|;)({field_to_rename})=([^;]*)' + field_pattern = rf'(^|;)({field_to_rename})($|;|=[^;]*)' if field_renamed is not None: - field_renamed_pattern = rf'\1{field_renamed}=\3' + field_renamed_pattern = rf'\1{field_renamed}\3' else: field_renamed_pattern = '' @@ -11736,6 +11736,11 @@ def rename_info_fields( else: log.info(f"Rename or remove fields - field '{field_to_rename}' removed") + else: + + log.warning(f"Rename or remove fields - field '{field_to_rename}' not in header") + + # Rename INFO for regex_replace_key, regex_replace in regex_replace_dict.items(): log.info(f"Rename or remove fields - Process [{regex_replace_key+1}/{len(regex_replace_dict)}]...") diff --git a/plugins/README.pdf b/plugins/README.pdf index 1d66dc1..40f2849 100644 Binary files a/plugins/README.pdf and b/plugins/README.pdf differ diff --git a/tests/data/example.annotation_names.vcf b/tests/data/example.annotation_names.vcf index a53d70e..681ebb0 100644 --- a/tests/data/example.annotation_names.vcf +++ b/tests/data/example.annotation_names.vcf @@ -24,6 +24,7 @@ ##INFO=11758 def calculation_rename_info_fields( +11759 self, +11760 fields_to_rename: dict = None, +11761 table: str = None, +11762 operation_name: str = "RENAME_INFO_FIELDS", +11763 ) -> None: +11764 """ +11765 The `calculation_rename_info_fields` function retrieves parameters from a dictionary, updates +11766 fields to rename and table if provided, and then calls another function to rename the fields. +11767 +11768 :param fields_to_rename: `fields_to_rename` is a dictionary that contains the fields to be +11769 renamed in a table. Each key-value pair in the dictionary represents the original field name as +11770 the key and the new field name as the value +11771 :type fields_to_rename: dict +11772 :param table: The `table` parameter in the `calculation_rename_info_fields` method is used to +11773 specify the name of the table for which the fields are to be renamed. It is a string type +11774 parameter +11775 :type table: str +11776 :param operation_name: The `operation_name` parameter in the `calculation_rename_info_fields` +11777 method is a string that specifies the name of the operation being performed. In this context, it +11778 is used as a default value for the operation name if not explicitly provided when calling the +11779 function, defaults to RENAME_INFO_FIELDS +11780 :type operation_name: str (optional) +11781 """ +11782 +11783 # Param +11784 param = self.get_param() +11785 +11786 # Get param fields to rename +11787 param_fields_to_rename = ( +11788 param.get("calculation", {}) +11789 .get("calculations", {}) +11790 .get(operation_name, {}) +11791 .get("fields_to_rename", None) +11792 ) +11793 +11794 # Get param table +11795 param_table = ( +11796 param.get("calculation", {}) +11797 .get("calculations", {}) +11798 .get(operation_name, {}) +11799 .get("table", None) +11800 ) +11801 +11802 # Init fields_to_rename +11803 if fields_to_rename is None: +11804 fields_to_rename = param_fields_to_rename +11805 +11806 # Init table +11807 if table is None: +11808 table = param_table +11809 +11810 renamed_fields = self.rename_info_fields( +11811 fields_to_rename=fields_to_rename, table=table +11812 ) +11813 +11814 log.debug(f"renamed_fields:{renamed_fields}")##INFO= ##INFO= +##INFO= ##contig= ##contig= ##contig= @@ -57,8 +58,8 @@ #CHROM POS ID REF ALT QUAL FILTER INFO FORMAT sample1 sample2 sample3 sample4 chr1 28736 . A C 100 PASS CLNSIG=pathogenic GT:AD:DP:GQ 0/1:525,204:729:99 0/1:12659,4994:17664:99 1/1:12658,4995:17663:99 1/1:401,175:576:99 chr1 35144 . A C 100 PASS CLNSIG=non-pathogenic GT:AD:DP:GQ ./.:.:.:. 0/1:12659,4994:17664:99 0/1:12658,4995:17663:99 0/1:401,175:576:99 -chr1 69101 . A G 100 PASS DP=50;CLNSIG=non-pathogenic;SIFT=D GT:AD:DP:GQ 0/1:525,204:729:99 ./.:.:.:. 0/1:12658,4995:17663:99 0/1:401,175:576:99 -chr1 768251 . A G 100 PASS CLNSIG=NP;PREFIXCLNSIG=NP;CLNSIGSUFFIX=P GT:AD:DP:GQ 0/1:525,204:729:99 ./.:.:.:. 0/1:12658,4995:17663:99 0/1:401,175:576:99 +chr1 69101 . A G 100 PASS DP=50;CLNSIG=non-pathogenic;SIFT=D;SPiP_Alt GT:AD:DP:GQ 0/1:525,204:729:99 ./.:.:.:. 0/1:12658,4995:17663:99 0/1:401,175:576:99 +chr1 768251 . A G 100 PASS CLNSIG=NP;PREFIXCLNSIG=NP;SPiP_Alt;CLNSIGSUFFIX=P GT:AD:DP:GQ 0/1:525,204:729:99 ./.:.:.:. 0/1:12658,4995:17663:99 0/1:401,175:576:99 chr1 768252 . A G 100 PASS PREFIXCLNSIG=NP GT:AD:DP:GQ 0/1:525,204:729:99 ./.:.:.:. 0/1:12658,4995:17663:99 0/1:401,175:576:99 -chr1 768253 . A G 100 PASS CLNSIGSUFFIX=P GT:AD:DP:GQ 0/1:525,204:729:99 ./.:.:.:. 0/1:12658,4995:17663:99 0/1:401,175:576:99 +chr1 768253 . A G 100 PASS SPiP_Alt;CLNSIGSUFFIX=P GT:AD:DP:GQ 0/1:525,204:729:99 ./.:.:.:. 0/1:12658,4995:17663:99 0/1:401,175:576:99 chr7 55249063 rs1050171 G A 5777 PASS CLNSIG=NP;DP=125;CLNSIG=NP GT:AD:DP:GQ 0/1:525,204:729:99 0/1:12659,4994:17664:99 ./.:.:.:. 0/1:401,175:576:99 diff --git a/tests/test_objects_variants.py b/tests/test_objects_variants.py index 2fd6f27..bf987c0 100644 --- a/tests/test_objects_variants.py +++ b/tests/test_objects_variants.py @@ -2196,13 +2196,16 @@ def test_rename_fields(): "field_not_in_header": "field_not_in_header_renamed", "": "", "SIFT": None, + "SPiP_Alt": "SPiP_alternative", + "SPiP_alternative": None, } # Rename fields fields_renamed = variants.rename_info_fields(fields_to_rename=fields_to_rename) - assert fields_renamed == {'CLNSIG': 'CLNSIG_renamed', 'PREFIXCLNSIG': 'PREFIXCLNSIG_renamed', 'DP': 'depth', 'SIFT': None} + assert fields_renamed == {'CLNSIG': 'CLNSIG_renamed', 'PREFIXCLNSIG': 'PREFIXCLNSIG_renamed', 'DP': 'depth', 'SIFT': None, 'SPiP_Alt': 'SPiP_alternative', 'SPiP_alternative': None} assert len(variants.get_query_to_df("SELECT INFO FROM variants WHERE INFO LIKE '%SIFT%'")) == 0 assert len(variants.get_query_to_df("SELECT INFO FROM variants WHERE INFO LIKE '%None=%'")) == 0 + assert len(variants.get_query_to_df("SELECT INFO FROM variants WHERE INFO LIKE '%SPiP%'")) == 0 # Check if VCF is in correct format with pyVCF remove_if_exists([output_vcf]) @@ -2235,6 +2238,8 @@ def test_rename_fields_to_param_and_export(): "field_not_in_header": "field_not_in_header_renamed", "": "", "SIFT": None, + "SPiP_Alt": "SPiP_alternative", + "SPiP_alternative": None, } } }