Ejemplo n.º 1
0
def runDirectExport(dataHub):
    if dataHub.args.export:
        logging.info("* Exporting views *")
        ensureExportData(dataHub)

        exportFormat = export.getExportFormat(dataHub.args)

        if dataHub.args.type == "batch":
            if not os.path.exists(dataHub.args.export):
                os.makedirs(dataHub.args.export)
            elif not os.path.isdir(dataHub.args.export):
                logging.error("In batch mode, --export must be passed as a directory, not a file: '{}'".format(dataHub.args.export))
                sys.exit(1)
            path = os.path.join(dataHub.args.export, "{}.{}".format(dataHub.variant.shortName(), exportFormat))
        else:
            path = dataHub.args.export

        exportData = dataHub.trackCompositor.render()
        if exportFormat != "svg":
            converter = export.getExportConverter(dataHub.args, exportFormat)
            exportData = export.convertSVG(exportData, exportFormat, converter)

        with open(path, "w") as outf:
            outf.write(exportData)

        if dataHub.args.open_exported:
            utilities.launchFile(dataHub.args.export)

        if dataHub.args.dotplots:
            dotplotPath = os.path.splitext(path)[0] + ".dotplot.png"
            with open(dotplotPath, "wb") as dotplotFile:
                dotplotFile.write(dataHub.dotplots["ref vs ref"])
Ejemplo n.º 2
0
def runDirectExport(dataHub):
    if dataHub.args.export:
        logging.info("* Exporting views *")
        ensureExportData(dataHub)

        exportFormat = export.getExportFormat(dataHub.args)

        if dataHub.args.type == "batch" or dataHub.args.format is not None:
            if not os.path.exists(dataHub.args.export):
                os.makedirs(dataHub.args.export)
            path = os.path.join(dataHub.args.export, "{}.{}".format(dataHub.variant.shortName(), exportFormat))
        else:
            path = dataHub.args.export

        exportData = dataHub.trackCompositor.render()
        if exportFormat != "svg":
            converter = export.getExportConverter(dataHub.args, exportFormat)
            exportData = export.convertSVG(exportData, exportFormat, converter)

        outf = open(path, "w")
        outf.write(exportData)
        outf.close()

        if dataHub.args.open_exported:
            utilities.launchFile(dataHub.args.export)
Ejemplo n.º 3
0
def runDirectExport(dataHub):
    if dataHub.args.export:
        logging.info("* Exporting views *")
        ensureExportData(dataHub)

        exportFormat = export.getExportFormat(dataHub.args)

        if dataHub.args.type == "batch" or dataHub.args.format is not None:
            if not os.path.exists(dataHub.args.export):
                os.makedirs(dataHub.args.export)
            path = os.path.join(
                dataHub.args.export,
                "{}.{}".format(dataHub.variant.shortName(), exportFormat))
        else:
            path = dataHub.args.export

        exportData = dataHub.trackCompositor.render()
        if exportFormat != "svg":
            converter = export.getExportConverter(dataHub.args, exportFormat)
            exportData = export.convertSVG(exportData, exportFormat, converter)

        outf = open(path, "w")
        outf.write(exportData)
        outf.close()

        if dataHub.args.open_exported:
            utilities.launchFile(dataHub.args.export)
Ejemplo n.º 4
0
Archivo: app.py Proyecto: svviz/svviz
def runDirectExport(dataHub):
    if dataHub.args.export:
        logging.info("* Exporting views *")
        ensureExportData(dataHub)

        exportFormat = export.getExportFormat(dataHub.args)

        if dataHub.args.type == "batch":
            if not os.path.exists(dataHub.args.export):
                os.makedirs(dataHub.args.export)
            elif not os.path.isdir(dataHub.args.export):
                logging.error("In batch mode, --export must be passed as a directory, not a file: '{}'".format(dataHub.args.export))
                sys.exit(1)
            path = os.path.join(dataHub.args.export, "{}.{}".format(dataHub.variant.shortName(), exportFormat))
        else:
            path = dataHub.args.export

        exportData = dataHub.trackCompositor.render()
        filemode = "w"
        if exportFormat != "svg":
            converter = export.getExportConverter(dataHub.args, exportFormat)
            exportData = export.convertSVG(exportData, exportFormat, converter)
            filemode = "wb"
            
        with open(path, filemode) as outf:
            outf.write(exportData)

        if dataHub.args.open_exported:
            utilities.launchFile(dataHub.args.export)

        outbasepath = os.path.splitext(path)[0]
        if dataHub.args.dotplots:
            dotplotPath = outbasepath + ".dotplot.png"
            with open(dotplotPath, "wb") as dotplotFile:
                dotplotFile.write(dataHub.dotplots["ref vs ref"])

        if dataHub.args.export_insert_sizes:
            didExportISD = False

            plotInsertSizeDistributions(dataHub)
            for name, sample in dataHub.samples.items():
                if sample.insertSizePlot is not None:
                    outpath = outbasepath + ".insertsizes.{}.png".format(name)
                    with open(outpath, "w") as isdfile:
                        isdfile.write(sample.insertSizePlot)
                    didExportISD = True

            if not didExportISD:
                print("** Failed to plot the insert size distributions; please make sure the **")
                print("** rpy2 is installed, your input bam files have sufficient numbers of **")
                print("** reads (> 50,000), and that the reads are paired-ended eg Illumina  **")
                print("** and not PacBio                                                     **")
Ejemplo n.º 5
0
def checkRequirements(args):
    if not remap.check_swalign():
        print "ERROR: check that svviz is correctly installed -- the 'ssw' Smith-Waterman alignment module does not appear to be functional"
        sys.exit(1)
    if args.export:
        exportFormat = export.getExportFormat(args)
        converter = export.getExportConverter(args, exportFormat)
        if converter is None and exportFormat != "svg":
            if args.converter is not None:
                logging.error("ERROR: unable to run SVG converter '{}'. Please check that it is "
                    "installed correctly".format(args.converter))
            else:
                logging.error("ERROR: unable to export to PDF/PNG because at least one of the following "
                    "programs must be correctly installed: webkitToPDF, librsvg or inkscape")

            sys.exit(1)
Ejemplo n.º 6
0
def checkRequirements(args):
    if not remap.check_swalign():
        print "ERROR: check that svviz is correctly installed -- the 'ssw' Smith-Waterman alignment module does not appear to be functional"
        sys.exit(1)
    if args.export:
        exportFormat = export.getExportFormat(args)
        converter = export.getExportConverter(args, exportFormat)
        if converter is None and exportFormat != "svg":
            if args.converter is not None:
                logging.error(
                    "ERROR: unable to run SVG converter '{}'. Please check that it is "
                    "installed correctly".format(args.converter))
            else:
                logging.error(
                    "ERROR: unable to export to PDF/PNG because at least one of the following "
                    "programs must be correctly installed: webkitToPDF, librsvg or inkscape"
                )

            sys.exit(1)
Ejemplo n.º 7
0
def runDirectExport(dataHub):
    if dataHub.args.export:
        logging.info("* Exporting views *")
        ensureExportData(dataHub)

        exportFormat = export.getExportFormat(dataHub.args)

        if dataHub.args.type == "batch":
            if not os.path.exists(dataHub.args.export):
                os.makedirs(dataHub.args.export)
            elif not os.path.isdir(dataHub.args.export):
                logging.error(
                    "In batch mode, --export must be passed as a directory, not a file: '{}'"
                    .format(dataHub.args.export))
                sys.exit(1)
            path = os.path.join(
                dataHub.args.export,
                "{}.{}".format(dataHub.variant.shortName(), exportFormat))
        else:
            path = dataHub.args.export

        exportData = dataHub.trackCompositor.render()
        filemode = "w"
        if exportFormat != "svg":
            converter = export.getExportConverter(dataHub.args, exportFormat)
            exportData = export.convertSVG(exportData, exportFormat, converter)
            filemode = "wb"

        with open(path, filemode) as outf:
            outf.write(exportData)

        if dataHub.args.open_exported:
            utilities.launchFile(dataHub.args.export)

        outbasepath = os.path.splitext(path)[0]
        if dataHub.args.dotplots:
            dotplotPath = outbasepath + ".dotplot.png"
            with open(dotplotPath, "wb") as dotplotFile:
                dotplotFile.write(dataHub.dotplots["ref vs ref"])

        if dataHub.args.export_insert_sizes:
            didExportISD = False

            plotInsertSizeDistributions(dataHub)
            for name, sample in dataHub.samples.items():
                if sample.insertSizePlot is not None:
                    outpath = outbasepath + ".insertsizes.{}.png".format(name)
                    with open(outpath, "w") as isdfile:
                        isdfile.write(sample.insertSizePlot)
                    didExportISD = True

            if not didExportISD:
                print(
                    "** Failed to plot the insert size distributions; please make sure the **"
                )
                print(
                    "** rpy2 is installed, your input bam files have sufficient numbers of **"
                )
                print(
                    "** reads (> 50,000), and that the reads are paired-ended eg Illumina  **"
                )
                print(
                    "** and not PacBio                                                     **"
                )