Skip to content
Snippets Groups Projects
Commit 358f6d4c authored by Floreal Cabanettes's avatar Floreal Cabanettes
Browse files

xlsxwriter as optional dependency

parent 62de38ec
No related branches found
No related tags found
No related merge requests found
...@@ -21,8 +21,6 @@ import string ...@@ -21,8 +21,6 @@ import string
import os import os
import re import re
import xlsxwriter
import sys import sys
prg_path = os.path.dirname(os.path.realpath(__file__)) prg_path = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(0, os.path.join(prg_path, "lib")) sys.path.insert(0, os.path.join(prg_path, "lib"))
...@@ -499,6 +497,13 @@ def create_xls_document(args, headers, filtered_records, nb_records, nb_inds, ce ...@@ -499,6 +497,13 @@ def create_xls_document(args, headers, filtered_records, nb_records, nb_inds, ce
:param cells_gq: cells for third sheet (genotype quality) :param cells_gq: cells for third sheet (genotype quality)
:param max_col_len: max content length for each column :param max_col_len: max content length for each column
""" """
try:
import xlsxwriter
except ImportError:
print("Excel file not built: xslxwriter python module not installed")
return False
with xlsxwriter.Workbook(args.output + ".xslx") as workbook: with xlsxwriter.Workbook(args.output + ".xslx") as workbook:
################################# #################################
...@@ -553,6 +558,16 @@ def create_xls_document(args, headers, filtered_records, nb_records, nb_inds, ce ...@@ -553,6 +558,16 @@ def create_xls_document(args, headers, filtered_records, nb_records, nb_inds, ce
def create_tsv_file(filename: str, headers: list, cells: dict, nb_tools: int, nb_per_tool: int, records_range: ()): def create_tsv_file(filename: str, headers: list, cells: dict, nb_tools: int, nb_per_tool: int, records_range: ()):
"""
Create tabulated separated values file
:param filename: filename of the file
:param headers: headers of each sheet
:param cells: cells of the table to save
:param nb_tools: number of tools
:param nb_per_tool: number per tools
:param records_range: range of records to treat {tuple(2)}
:return:
"""
# Init rows: # Init rows:
head = ["", headers[0]] head = ["", headers[0]]
top_headers = {} top_headers = {}
...@@ -590,8 +605,6 @@ def create_tsv_file(filename: str, headers: list, cells: dict, nb_tools: int, nb ...@@ -590,8 +605,6 @@ def create_tsv_file(filename: str, headers: list, cells: dict, nb_tools: int, nb
tsv_file.write(tsv) tsv_file.write(tsv)
# noinspection PyUnresolvedReferences
def main(): def main():
# parse the command line args # parse the command line args
args = get_args() args = get_args()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment