Skip to content

Commit

Permalink
Merge pull request #130 from eastgenomics/v2.3.0-release
Browse files Browse the repository at this point in the history
v2.3.0 release (#130)

Co-Authored-By: Yu-jinKim <yujin.kim@hotmail.fr>
Co-Authored-By: mattgarner <mattgarner@users.noreply.github.com>
  • Loading branch information
mattgarner and Yu-jinKim authored Jan 5, 2023
2 parents 7612860 + 6bd0ec3 commit 275066d
Show file tree
Hide file tree
Showing 9 changed files with 447 additions and 23 deletions.
15 changes: 15 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,21 @@ This app may be executed as a standalone app.

`--additional_sheet_names` (`list`): Names to use for additional file sheets, if specified these MUST be the same number as the number of files passed and in the same order (`-iadditional_files=file1 -iadditional_files=file2 -iadditional_sheet_names='name_1 name_2'`). If not given, the first 31 characters of the filename will be used.

`--colour_cells` (`string`): Add conditional colouring of cells for a given column, this should be specified as column:value_range:colour, where colour is a valid hex value or colour name. Multiple conditions may be given in a single `value_range` for the same column and colour values by chaining multiple with either `&` for all or `|` for any condition (n.b. `&` and `|` cannot be used in the same expression). Column names should be given as they appear in the VCF, except for cases where renaming has been specified with `--rename`, in which case the given column name should be used. Example formats:
```
# single condition
-icolour_cells "VF:>=0.9:green"
# both of two conditions
-icolour_cells "VF:<0.8&>=0.6:orange"
# either of two conditions
-icolour_cells "VF:>0.9|<0.1:red"
# multiple conditions to colour column across multiple ranges and colours
-icolour_cells "VF:>=0.9:green VF:<0.9&>=0.4:orange VF:>0.4:red"
```

`--output_prefix` (`string`): Prefix for naming output xlsx file. If not given for single file, the VCF prefix will be used. For 2+ input VCFs this must be specified.

`--merge_vcfs` (`bool`): Determines if to merge multiple VCFs to one sheet (default: `False`).
Expand Down
17 changes: 13 additions & 4 deletions dxapp.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
"title": "eggd_generate_variant_workbook",
"summary": "Create Excel workbook from VEP annotated vcf",
"dxapi": "1.0.0",
"version": "2.2.0",
"version": "2.3.0",
"properties": {
"githubRelease": "v2.3.0"
},
"whatsNew": "* v2.0.0 Rewrite of previous app to generate xlsx file from a VEP annotated VCF(s); * v2.0.1 Bug fix to correctly treat CHROM as string values; * v2.0.2 Bug fix for ACMG report template structure; * v2.0.3 Bug fixes for issues with hyperlinks, changed app name to eggd_generate_variant_workbook; * v2.1.0 Handle VCFs from GATK gCNV and Illumina TSO500, readability tweaks to variant sheets; * v2.1.1 Bug fix for typing of numeric values in hyperlinks; * v2.2.0 Added ability to pass in non VCF files (tsvs/csvs and images) to additional sheets, optional adding of links to DECIPHER with --decipher; * v2.3.0 Added conditional colouring of cells in variant sheets, new 'basic' summary sheet;",
"authorizedUsers": [
"org-emee_1"
],
"developers":[
"org-emee_1"
],
"properties": {
"githubRelease": "v2.2.0"
},
"inputSpec": [
{
"name": "vcfs",
Expand Down Expand Up @@ -159,6 +160,14 @@
"help": "Prefix for naming output xlsx file",
"group": "generate_workbook.py"
},
{
"name": "colour_cells",
"label": "colour cells",
"class": "string",
"optional": true,
"help": "Add conditional colouring of cells for a given column, this should be specified as column:value_range:colour, where colour is a valid hex value or colour name. See readme for futher details.",
"group": "generate_workbook.py"
},
{
"name": "merge_vcfs",
"label": "Merge",
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
colour==0.1.5
python-Levenshtein==0.12.2
openpyxl==3.0.9
pandas==1.3.5
32 changes: 31 additions & 1 deletion resources/home/dnanexus/generate_workbook/generate_workbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def __init__(self):
self.set_sheet_names()
self.verify_sheets()
self.verify_images()
self.verify_colours()

print(f"Arguments passed: ", ''.join([
f"\n\t\t{' : '.join((str(x), str(self.args.__dict__[x])))}"
Expand Down Expand Up @@ -264,14 +265,21 @@ def parse_args(self) -> argparse.Namespace:
'before writing to the Excel file.'
)
)

parser.add_argument(
'--decipher', required=False, action='store_true',
help=(
'Determines whether or not to include column of DECIPHER links'
'n.b. DECIPHER is only available for variants in build 38 '
)
)
parser.add_argument(
'--colour', required=False, nargs='+',
help=(
'Add conditional colouring of cells for a given column, this '
'should be specified as column:value_range:colour, where '
'colour is a valid hex value or colour name'
)
)

return parser.parse_args()

Expand Down Expand Up @@ -347,6 +355,7 @@ def verify_sheets(self) -> None:
f"of sheet names passed: {len(self.args.additional_sheets)}"
)


def verify_images(self) -> None:
"""
Checks where images with names and / or sizes are passed that
Expand Down Expand Up @@ -394,6 +403,27 @@ def verify_images(self) -> None:
)


def verify_colours(self) -> None:
"""
Checks when colouring for cells specified with --colour that
the arguments passed are do not contain both & and |
Raises
------
AssertionError
raised when a mix of '&' and '|' are used in the same condition
"""
if not self.args.colour:
return

assert max([
len(set(re.findall(r'[&|]', x))) for x in self.args.colour
]) <= 1, (
'invalid colouring expression - can not contain both & and | in '
'a single expression'
)


def set_sheet_names(self) -> None:
"""
Sets list of names for naming output sheets in Excel file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,38 @@ def test_invalid_image_sizes(self):
self.args_obj.verify_images()

self.args_obj.args.image_sheets = None


class TestVerifyColours():
"""
Tests for generate_workbook.verify_colours to check for valid
colouring expressions being given
"""
with patch("sys.argv", []):
args_obj = object.__new__(arguments)
args_obj.args = args_obj.parse_args()


def test_valid_colour_expressions(self):
"""
Test a range of valid expressions pass the check
"""
self.args_obj.args.colour = [
'VF:>=0.9:green',
'VF:>0.4:red',
'VF:<0.9&>=0.4:orange',
'Consequence:=synonymous_variant|=upstream_variant:green'
]

self.args_obj.verify_colours()


def test_invalid_colour_expression(self):
"""
Test that the assertion in verify_colours() is correctly
raised if both & and | are used in the same expression
"""
self.args_obj.args.colour = ['VF:<0.9&>=0.4|<1:orange']

with pytest.raises(AssertionError):
self.args_obj.verify_colours()
Loading

0 comments on commit 275066d

Please sign in to comment.