Example #1
0
def main():
    option_parser, opts, args = parse_command_line_parameters(**script_info)

    if opts.show_metrics:
        print("Known metrics are: %s\n"
              % (', '.join(list_known_metrics()),))
        exit(0)

    almost_required_options = ['input_path', 'output_dir', 'metrics']
    for option in almost_required_options:
        if getattr(opts, option) is None:
            option_parser.error('Required option --%s omitted.' % option)

    if opts.output_dir.endswith('.txt'):
        stderr.write('output must be a directory, files will be named' +
                     ' automatically.  And we refuse to make .txt directories\n')
        exit(1)

    if opts.tree_path == "None":
        opts.tree_path = None

    try:
        os.makedirs(opts.output_dir)
    except OSError:
        pass  # hopefully dir already exists

    if os.path.isdir(opts.input_path):
        multiple_file_beta(opts.input_path, opts.output_dir, opts.metrics,
                           opts.tree_path, opts.rows, full_tree=opts.full_tree)
    elif os.path.isfile(opts.input_path):
        single_file_beta(opts.input_path, opts.metrics, opts.tree_path,
                         opts.output_dir, opts.rows, full_tree=opts.full_tree)
    else:
        stderr.write("io error, input path not valid.  Does it exist?")
        exit(1)
Example #2
0
def main():
    option_parser, opts, args = parse_command_line_parameters(**script_info)

    if opts.show_metrics:
        print("Known metrics are: %s\n"
              % (', '.join(list_known_metrics()),))
        exit(0)

    almost_required_options = ['input_path', 'output_dir', 'metrics']
    for option in almost_required_options:
        if getattr(opts, option) is None:
            option_parser.error('Required option --%s omitted.' % option)

    if opts.output_dir.endswith('.txt'):
        stderr.write('output must be a directory, files will be named' +
                     ' automatically.  And we refuse to make .txt directories\n')
        exit(1)

    if opts.tree_path == "None":
        opts.tree_path = None

    try:
        os.makedirs(opts.output_dir)
    except OSError:
        pass  # hopefully dir already exists

    if os.path.isdir(opts.input_path):
        multiple_file_beta(opts.input_path, opts.output_dir, opts.metrics,
                           opts.tree_path, opts.rows, full_tree=opts.full_tree)
    elif os.path.isfile(opts.input_path):
        single_file_beta(opts.input_path, opts.metrics, opts.tree_path,
                         opts.output_dir, opts.rows, full_tree=opts.full_tree)
    else:
        stderr.write("io error, input path not valid.  Does it exist?")
        exit(1)
    "output_description"
] = """The output of %prog is a folder containing\
 text files, each a distance matrix between samples."""

script_info["required_options"] = [
    make_option("-i", "--input_path", type="existing_path", help="input path, must be directory [REQUIRED]"),
    make_option("-o", "--output_path", type="new_dirpath", help="output path, must be directory [REQUIRED]"),
]

script_info["optional_options"] = [
    make_option(
        "-m",
        "--metrics",
        default="unweighted_unifrac,weighted_unifrac",
        type="multiple_choice",
        mchoices=list_known_metrics(),
        help="Beta-diversity metric(s) to use. A comma-separated list should be"
        + " provided when multiple metrics are specified. [default: %default]",
    ),
    make_option(
        "-t",
        "--tree_path",
        type="existing_filepath",
        help="path to newick tree file, required for phylogenetic metrics" + " [default: %default]",
    ),
    options_lookup["retain_temp_files"],
    options_lookup["suppress_submit_jobs"],
    options_lookup["poll_directly"],
    options_lookup["cluster_jobs_fp"],
    options_lookup["suppress_polling"],
    options_lookup["job_prefix"],
Example #4
0
 table."""
script_info['required_options'] = []
script_info['optional_options']=[
    make_option('-i', '--input_path',
     help='Input OTU table in biom format or input directory containing OTU ' +\
     'tables in biom format for batch processing.',
     type='existing_path'),
    make_option('-r', '--rows', default=None, type='string',
     help='Compute for only these rows of the distance matrix.' +\
      ' User should pass a list of sample names (e.g. "s1,s3")' +\
      ' [default: %default; full n x n matrix is generated]'),
    make_option('-o', '--output_dir',
     help="Output directory. One will be created if it doesn't exist.",
     type='new_dirpath'),
    make_option('-m', '--metrics', default='unweighted_unifrac,weighted_unifrac',
     type='multiple_choice', mchoices=list_known_metrics(),
     help='Beta-diversity metric(s) to use. A comma-separated list should' +\
     ' be provided when multiple metrics are specified. [default: %default]'),
    make_option('-s', '--show_metrics', action='store_true', default=False,
     help='Show the available beta-diversity metrics and exit. Metrics' +\
     ' starting with' +\
     ' "binary..." specifies that a metric is qualitative, and considers' +\
     ' only the presence or absence of each taxon [default: %default]'),
    make_option('-t', '--tree_path', default=None,
     help='Input newick tree filepath, which is required when phylogenetic' +\
     ' metrics are specified. [default: %default]',
     type='existing_filepath'),
    make_option('-f', '--full_tree', action="store_true", default=False,
     help='By default, tips not corresponding to OTUs in the OTU table are '+\
     'removed from the tree for diversity calculations. ' +\
     'Pass to skip this step if you\'re already passing a minimal tree.' +\
("""Apply beta_diversity.py in parallel to a single otu table""",""" """,
"""%prog -i $PWD/otu_table.biom -o $PWD/bdiv_single/ -t $PWD/rep_set.tre"""))

script_info['output_description']="""The output of %prog is a folder containing\
 text files, each a distance matrix between samples."""

script_info['required_options'] = [\
 make_option('-i', '--input_path',type='existing_path',
        help='input path, must be directory [REQUIRED]'),\
 make_option('-o', '--output_path',type='new_dirpath',
        help='output path, must be directory [REQUIRED]'),
]

script_info['optional_options'] = [
 make_option('-m', '--metrics', default='unweighted_unifrac,weighted_unifrac',
     type='multiple_choice', mchoices=list_known_metrics(),
     help='Beta-diversity metric(s) to use. A comma-separated list should be' +\
     ' provided when multiple metrics are specified. [default: %default]'),
 make_option('-t', '--tree_path', type='existing_filepath',
        help='path to newick tree file, required for phylogenetic metrics'+\
        ' [default: %default]'),\
 options_lookup['retain_temp_files'],
 options_lookup['suppress_submit_jobs'],
 options_lookup['poll_directly'],
 options_lookup['cluster_jobs_fp'],
 options_lookup['suppress_polling'],
 options_lookup['job_prefix'],
 options_lookup['seconds_to_sleep'],
 options_lookup['jobs_to_start'],
 make_option('-f', '--full_tree', action="store_true",
     help='By default, each job removes calls _fast_unifrac_setup to remove\
Example #6
0
             default=None,
             type='string',
             help='Compute for only these rows of the distance matrix.' +
             ' User should pass a list of sample names (e.g. "s1,s3")' +
             ' [default: %default; full n x n matrix is generated]'),
 make_option(
     '-o',
     '--output_dir',
     help="Output directory. One will be created if it doesn't exist.",
     type='new_dirpath'),
 make_option(
     '-m',
     '--metrics',
     default='unweighted_unifrac,weighted_unifrac',
     type='multiple_choice',
     mchoices=list_known_metrics(),
     help='Beta-diversity metric(s) to use. A comma-separated list should' +
     ' be provided when multiple metrics are specified. [default: %default]'
 ),
 make_option(
     '-s',
     '--show_metrics',
     action='store_true',
     default=False,
     help='Show the available beta-diversity metrics and exit. Metrics' +
     ' starting with' +
     ' "binary..." specifies that a metric is qualitative, and considers' +
     ' only the presence or absence of each taxon [default: %default]'),
 make_option(
     '-t',
     '--tree_path',