Skip to content

Commit

Permalink
IN-500 better readability
Browse files Browse the repository at this point in the history
  • Loading branch information
Aisha-D committed Oct 18, 2024
1 parent 66f7ed5 commit d50c6f0
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions resources/home/dnanexus/generate_workbook/utils/vcf.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,11 +743,20 @@ def drop_columns(self, vcfs=None) -> None:
vcfs[idx].drop(to_drop, axis=1, inplace=True, errors='ignore')


def order_columns(self, vcfs) -> None:
def order_columns(self, vcfs) -> list:
"""
Reorder columns by specified order from `--reorder` argument, any not
specified will retain original order after reorder columns
Parameters
----------
vcfs : list
list of pd.DataFrames of vcfs to order columns from
Returns
-------
list
list of dataframes with ordered columns
Raises
------
AssertionError
Expand Down Expand Up @@ -965,10 +974,18 @@ def add_raw_change(self) -> None:
'{0[CHROM]}:g.{0[POS]}{0[REF]}>{0[ALT]}'.format, axis=1)


def percent_af(self, vcfs):
def percent_af(self, vcfs) -> list:
"""
Finds the column with "AF" and will convert the number format
to percent
Parameters
----------
vcfs : list
list of pd.DataFrames of vcfs to change the AF columns type
Returns
-------
list
list of dataframes with AF changed to percent type
"""
# find the sheets and apply to all sheets
for idx, vcf in enumerate(vcfs):
Expand All @@ -978,7 +995,7 @@ def percent_af(self, vcfs):
vcf['AF'] = vcf['AF'].map(lambda n: '{:,.1%}'.format(n))

vcfs[idx] = vcf

return vcfs


Expand Down

0 comments on commit d50c6f0

Please sign in to comment.