示例#1
0
    def go(self, skip_dry_run=False):
        """Do the actual running"""

        if self.save_workflow_graph or (not skip_dry_run):
            self.dry_run()

        if self.dry_run_only:
            return

        # snakemake.main() accepts an `argv` parameter, but then the code has mixed responses to
        # that, and at places continues to read from sys.argv in a hardcoded manner. so we have to
        # overwrite our argv here.
        original_sys_argv = copy.deepcopy(sys.argv)

        sys.argv = ['snakemake',
                    '--snakefile',
                    get_workflow_snake_file_path(self.args.workflow),
                    '--configfile',
                    self.args.config_file]

        if self.additional_params:
            sys.argv.extend(self.additional_params)

        if self.list_dependencies:
            sys.argv.extend(['--dryrun', '--printshellcmds'])
            snakemake.main()
            sys.exit(0)
        else:
            sys.argv.extend(['-p'])
            snakemake.main()

        # restore the `sys.argv` to the original for the sake of sakity (totally made up word,
        # but you already know what it measn. you're welcome.)
        sys.argv = original_sys_argv
示例#2
0
    def go(self, skip_dry_run=False):
        """Do the actual running"""

        if self.save_workflow_graph or (not skip_dry_run):
            self.dry_run()

        if self.dry_run_only:
            return

        # snakemake.main() accepts an `argv` parameter, but then the code has mixed responses to
        # that, and at places continues to read from sys.argv in a hardcoded manner. so we have to
        # overwrite our argv here.
        original_sys_argv = copy.deepcopy(sys.argv)

        sys.argv = [
            'snakemake', '--snakefile',
            get_workflow_snake_file_path(self.args.workflow), '--configfile',
            self.args.config_file
        ]

        if self.additional_params:
            sys.argv.extend(self.additional_params)

        if self.list_dependencies:
            sys.argv.extend(['--dryrun', '--printshellcmds'])
            snakemake.main()
            sys.exit(0)
        else:
            sys.argv.extend(['-p'])
            snakemake.main()

        # restore the `sys.argv` to the original for the sake of sakity (totally made up word,
        # but you already know what it measn. you're welcome.)
        sys.argv = original_sys_argv
示例#3
0
 def run(self):
     '''
     Run the wrapped command or workflow.
     '''
     # Overwrite the generic method, because we have to use the snakemake API
     try:
         snakemake.main(self.remaining[1:])
     except SystemExit:
         # snakemake main wants to exit ... but we want to write the xml files first
         return
示例#4
0
def main(**config):
    """
    Main function of pancovcorrect

    Parameter:

    config: A dict pass to snakemake as config.
    Value associate to 'snakemake' is parse with snakemake cli parser.

    Return:

    True if workflow execution was successful.
    """
    params = config["snakemake"]
    del config["snakemake"]

    # Found Snakefile
    params.extend(
        [
            "--snakefile",
            os.path.join(os.path.dirname(__file__), f"{package_name}.snk"),
        ]
    )

    # Add parameter with config
    params.append("--config")
    for (name, value) in config.items():
        params.append(f"{name}={value}")

    # Add target
    params.extend(["--", "all"])

    return snakemake.main(params)
示例#5
0
def proxy_to_snakemake(tailseeker_dir):
    from snakemake import main

    tailseeker_main_file = os.path.join(tailseeker_dir, 'tailseeker', 'main.py')

    if '-s' not in sys.argv and '--snakefile' not in sys.argv:
        sys.argv.insert(1, '-s')
        sys.argv.insert(2, tailseeker_main_file)

    sys.exit(main())
示例#6
0
def proxy_to_snakemake(tailseeker_dir):
    from snakemake import main

    tailseeker_main_file = os.path.join(tailseeker_dir, 'tailseeker',
                                        'main.py')

    if '-s' not in sys.argv and '--snakefile' not in sys.argv:
        sys.argv.insert(1, '-s')
        sys.argv.insert(2, tailseeker_main_file)

    sys.exit(main())
示例#7
0
# This script makes it possible to invoke snakemake with 'python3 -m snakemake'
from snakemake import main

main()
示例#8
0
 def __call__(self, parser, namespace, values, option_string=None):
     snakemake.main(["-h"])
示例#9
0
def proxy_to_snakemake(tailseeker_dir):
    from snakemake import main

    tailseeker_main_file = os.path.join(tailseeker_dir, 'tailseeker', 'main.py')

    if '-s' not in sys.argv and '--snakefile' not in sys.argv:
        sys.argv.insert(1, '-s')
        sys.argv.insert(2, tailseeker_main_file)

    sys.exit(main())

def show_banner():
    if os.environ.get('TAILSEEKER_SKIP_BANNER', 'no') == 'no':
        print("""\
Tailseeker {version} - High-throughput measurement of poly(A) tails
""".format(version=tailseeker.__version__))

def main(tailseeker_dir):
    show_banner()

    os.environ['TAILSEEKER_DIR'] = tailseeker_dir
    os.environ['TAILSEEKER_SKIP_BANNER'] = 'yes'

    check_configuration()
    proxy_to_snakemake(tailseeker_dir)


if __name__ == '__main__':
    main()
示例#10
0
def main_full():
    snakefile = get_snakefile()
    options = argv[1:]
    options.append("-s")
    options.append(snakefile)
    snakemake.main(options)
示例#11
0
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3

# -*- coding: utf-8 -*-
import re
import sys

from snakemake import main

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    sys.exit(main())