How to use the pygtftk.utils.make_outdir_and_file function in pygtftk

To help you get started, we’ve selected a few pygtftk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dputhier / pygtftk / pygtftk / plugins / control_list.py View on Github external
fl = fl + pseudo_count
                if fl <= 0:
                    message("Can not log transform negative/zero values.",
                            type="ERROR")

        except:
            msg = "It seems that column 2 of input file"
            msg += " contains non numeric values."
            msg += "Check that no header is present and that "
            msg += "columns are ordered properly."
            message(msg, type="ERROR")

    message("Selecting genes (R call).")

    # Preparing pdf file name
    file_out_list = make_outdir_and_file(out_dir, ["control_list.txt",
                                                   "reference_list.txt",
                                                   "diagnostic_diagrams.pdf",
                                                   "R_code_control_list.R",
                                                   "command.log"],
                                         force=True)

    control_file, reference_file_out, pdf_file, r_code_file, log_file = file_out_list

    code_body = """

            ########################################
            # Load library
            ########################################

            suppressWarnings(suppressMessages(library(beanplot)))
            suppressWarnings(suppressMessages(library(ggplot2)))
github dputhier / pygtftk / pygtftk / plugins / profile.py View on Github external
img_file = "tts_u%s_d%s." + page_format
        img_file = img_file % (config['from'], config['to'])

    elif config['ft_type'] == 'transcript':

        img_file = "transcript_u%s_d%s." + page_format
        img_file = img_file % (config['from'], config['to'])
    elif config['ft_type'] == 'user_regions':
        img_file = "user_regions_u%s_d%s." + page_format
        img_file = img_file % (config['from'], config['to'])
    elif config['ft_type'] == 'single_nuc':
        img_file = "user_positions_u%s_d%s." + page_format
        img_file = img_file % (config['from'], config['to'])

    if user_img_file is None:
        file_out_list = make_outdir_and_file(out_dir,
                                             [img_file, "R_diagram_code.R"],
                                             force=True)

        img_file, r_code_file = file_out_list

    else:
        file_out_list = make_outdir_and_file(out_dir,
                                             ["R_diagram_code.R"],
                                             force=True)

        r_code_file = file_out_list[0]
        img_file = user_img_file
        if not img_file.name.endswith(page_format):
            msg = "Image format: {f}. Please fix.".format(f=page_format)
            message(msg, type="ERROR")
        test_path = os.path.abspath(img_file.name)
github dputhier / pygtftk / pygtftk / plugins / profile.py View on Github external
elif config['ft_type'] == 'transcript':

        img_file = "transcript_u%s_d%s." + page_format
        img_file = img_file % (config['from'], config['to'])

    elif config['ft_type'] == 'user_regions':
        img_file = "user_regions_u%s_d%s." + page_format
        img_file = img_file % (config['from'], config['to'])

    elif config['ft_type'] == 'single_nuc':
        img_file = "user_positions_u%s_d%s." + page_format
        img_file = img_file % (config['from'], config['to'])
    else:
        raise GTFtkError("Unknown feature type.")

    file_out_list = make_outdir_and_file(out_dir,
                                         ["profile_stats.txt",
                                          img_file],
                                         force=True)

    data_file, img_file = file_out_list

    if user_img_file is not None:

        os.unlink(img_file.name)
        img_file = user_img_file

        if not img_file.name.endswith(page_format):
            msg = "Image format: {f}. Please fix.".format(f=page_format)
            message(msg, type="ERROR")

        test_path = os.path.abspath(img_file.name)
github dputhier / pygtftk / pygtftk / plugins / ologram.py View on Github external
else:
            more_bed_labels = []
            for a_bed in more_bed:
                a_bed = os.path.basename(a_bed.name)
                a_bed = re.sub("_converted\.[Bb][Ee][Dd][3456]{0,1}$", "", a_bed)
                # This one is a little bit complexe...
                # this is in case pygtftk name appear in the initial name...
                a_bed = re.sub("_pygtftk_?((?!pygtftk).)*$", "", a_bed)
                more_bed_labels += [a_bed]
            message("--more-bed-label will be set to: " + ",".join(more_bed_labels), type="DEBUG")

    # -------------------------------------------------------------------------
    # Preparing output files
    # -------------------------------------------------------------------------

    file_out_list = make_outdir_and_file(out_dir=outputdir,
                                         alist=["00_ologram_stats.tsv",
                                                "00_ologram_diagrams.pdf"
                                                ],
                                         force=True)

    data_file, pdf_file = file_out_list

    if no_pdf:
        if pdf_file_alt:
            os.unlink(pdf_file_alt.name)
        os.unlink(pdf_file.name)
        pdf_file = None
    else:
        if pdf_file_alt is not None:

            os.unlink(pdf_file.name)
github dputhier / pygtftk / pygtftk / plugins / profile.py View on Github external
elif config['ft_type'] == 'user_regions':
        img_file = "user_regions_u%s_d%s." + page_format
        img_file = img_file % (config['from'], config['to'])
    elif config['ft_type'] == 'single_nuc':
        img_file = "user_positions_u%s_d%s." + page_format
        img_file = img_file % (config['from'], config['to'])

    if user_img_file is None:
        file_out_list = make_outdir_and_file(out_dir,
                                             [img_file, "R_diagram_code.R"],
                                             force=True)

        img_file, r_code_file = file_out_list

    else:
        file_out_list = make_outdir_and_file(out_dir,
                                             ["R_diagram_code.R"],
                                             force=True)

        r_code_file = file_out_list[0]
        img_file = user_img_file
        if not img_file.name.endswith(page_format):
            msg = "Image format: {f}. Please fix.".format(f=page_format)
            message(msg, type="ERROR")
        test_path = os.path.abspath(img_file.name)
        test_path = os.path.dirname(test_path)

        if not os.path.exists(test_path):
            os.makedirs(test_path)

    # ------------------------------------------------------------------
    # Graphics with a call to R
github dputhier / pygtftk / pygtftk / plugins / heatmap.py View on Github external
else:
            message(
                "Please provide --transcript-file if --x-factor or "
                "--y-factor is set to tx_classes.",
                type="ERROR")

    # -------------------------------------------------------------------------
    #
    # Prepare output files
    #
    # -------------------------------------------------------------------------

    img_file = config['ft_type'] + "_u%s_d%s." + page_format
    img_file = img_file % (config['from'], config['to'])

    file_out_list = make_outdir_and_file(out_dir,
                                         [img_file,
                                          "data_long_format.txt",
                                          "transcript_order_and_class.txt"],
                                         force=True)

    img_file, data_file, tx_order_file_out = file_out_list

    if user_img_file is not None:
        os.unlink(img_file.name)
        img_file = user_img_file
        if not img_file.name.endswith(page_format):
            msg = "Image format: {f}. Please fix.".format(f=page_format)
            message(msg, type="ERROR")

    # -------------------------------------------------------------------------
    #