コード例 #1
0
ファイル: test_cmdparse.py プロジェクト: golharam/genomics
 def test_add_dry_run_option_with_argparse(self):
     """add_dry_run_option enables '--dry-run' with ArgumentParser
     """
     p = ArgumentParser()
     add_dry_run_option(p)
     args = p.parse_args(['--dry-run'])
     self.assertTrue(args.dry_run)
コード例 #2
0
def add_archive_command(cmdparser):
    """Create a parser for the 'archive' command
    """
    p = cmdparser.add_command('archive',help="Copy analyses to 'archive' area",
                              usage="%prog archive [OPTIONS] [ANALYSIS_DIR]",
                              version="%prog "+__version__,
                              description="Copy sequencing analysis data directory "
                              "ANALYSIS_DIR to 'archive' destination.")
    p.add_option('--archive_dir',action='store',
                 dest='archive_dir',default=None,
                 help="specify top-level archive directory to copy data under. "
                 "ARCHIVE_DIR can be a local directory, or a remote location in the "
                 "form '[[user@]host:]directory'. Overrides the default settings.")
    p.add_option('--platform',action='store',
                 dest='platform',default=None,
                 help="specify the platform e.g. 'hiseq', 'miseq' etc (overrides "
                 "automatically determined platform, if any). Use 'other' for cases "
                 "where the platform is unknown.")
    p.add_option('--year',action='store',
                 dest='year',default=None,
                 help="specify the year e.g. '2014' (default is the current year)")
    default_group = __settings.archive.group
    p.add_option('--group',action='store',dest='group',default=default_group,
                 help="specify the name of group for the archived files NB only works "
                 "when the archive is a local directory (default: %s)" % default_group)
    default_chmod = __settings.archive.chmod
    p.add_option('--chmod',action='store',dest='chmod',default=default_chmod,
                 help="specify chmod operations for the archived files (default: "
                 "%s)" % default_chmod)
    p.add_option('--force',action='store_true',dest='force',default=False,
                 help="perform archiving operation even if key metadata items are "
                 "not set")
    add_dry_run_option(p)
    add_debug_option(p)
コード例 #3
0
ファイル: test_cmdparse.py プロジェクト: golharam/genomics
 def test_add_dry_run_option(self):
     """add_dry_run_option enables '--dry-run'
     """
     # Skip the test if optparse not available
     if not OPTPARSE_AVAILABLE:
         raise unittest.SkipTest("'optparse' not available")
     p = OptionParser()
     add_dry_run_option(p)
     options, args = p.parse_args(['--dry-run'])
     self.assertTrue(options.dry_run)
コード例 #4
0
def add_merge_fastq_dirs_command(cmdparser):
    """Create a parser for the 'merge_fastq_dirs' command
    """
    p = cmdparser.add_command('merge_fastq_dirs',help="Combine bcl-to-fastq runs",
                              usage="%prog merge_fastq_dirs [OPTIONS] [ANALYSIS_DIR]",
                              description="Automatically merge fastq directories from "
                              "multiple bcl-to-fastq runs within ANALYSIS_DIR. Use this "
                              "command if 'make_fastqs' step was run multiple times to "
                              "process subsets of lanes.")
    p.add_option('--primary-unaligned-dir',action='store',
                 dest='unaligned_dir',default='bcl2fastq',
                 help="merge fastqs from additional bcl-to-fastq directories into "
                 "UNALIGNED_DIR. Original data will be moved out of the way first. "
                 "Defaults to 'bcl2fastq'.")
    add_dry_run_option(p)
    add_debug_option(p)
コード例 #5
0
 # Add info command
 p.add_command('info',help="Get information about ANALYSIS_DIR",
               usage="%prog info [OPTIONS] ANALYSIS_DIR",
               description="Report information on processed Illumina "
               "sequence data in ANALYSIS_DIR.")
 add_debug_option(p.parser_for('info'))
 # Add copy command
 p.add_command('copy',help="Copy fastqs from ANALYSIS_DIR",
               usage="%prog copy [OPTIONS] ANALYSIS_DIR DEST_DIR",
               description="Copy fastqs from ANALYSIS_DIR to DEST_DIR.")
 p.parser_for('copy').add_option('--projects',action='store',dest='projects',default=None,
                                 help="Restrict copying to projects matching the "
                                 "supplied pattern")
 p.parser_for('copy').add_option('--fastq-dir',action='store',dest='fastq_dir',default=None,
                                 help="Only copy fastqs from the specified FASTQ_DIR")
 add_dry_run_option(p.parser_for('copy'))
 add_debug_option(p.parser_for('copy'))
 # Process the command line
 cmd,options,args = p.parse_args()
 if len(args) < 1:
     p.error("Need to supply a directory to examine")
 if options.debug:
     logging.getLogger().setLevel(logging.DEBUG)
 # Acquire data for putative analysis directory
 dirn = os.path.abspath(args[0])
 print "Examining %s" % dirn
 analysis_dir = utils.AnalysisDir(dirn)
 if not (analysis_dir.n_projects and analysis_dir.n_sequencing_data):
     logging.warning("Not an analysis directory")
     sys.exit()
 # Deal with commands