本文整理汇总了Python中qiime.util.create_dir函数的典型用法代码示例。如果您正苦于以下问题:Python create_dir函数的具体用法?Python create_dir怎么用?Python create_dir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_dir函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: main
def main():
option_parser, opts, args = parse_command_line_parameters(**script_info)
create_dir(opts.output_dir)
generate_passwords(open(opts.personal_ids_fp, 'U'), opts.results_dir,
opts.password_dir, opts.output_dir)
开发者ID:biocore,项目名称:my-microbes,代码行数:7,代码来源:generate_passwords.py
示例2: copy_support_files
def copy_support_files(file_path):
"""Copy the support files to a named destination
file_path: path where you want the support files to be copied to
Will raise EmperorSupportFilesError if a problem is found whilst trying to
copy the files.
"""
file_path = join(file_path, "emperor_required_resources")
if exists(file_path) == False:
create_dir(file_path, False)
# shutil.copytree does not provide an easy way to copy the contents of a
# directory into another existing directory, hence the system call.
# use double quotes for the paths to escape any invalid chracter(s)/spaces
cmd = 'cp -R "%s/"* "%s"' % (get_emperor_support_files_dir(), abspath(file_path))
cmd_o, cmd_e, cmd_r = qiime_system_call(cmd)
if cmd_e:
raise EmperorSupportFilesError, "Error found whilst trying to copy " + "the support files:\n%s\n Could not execute: %s" % (
cmd_e,
cmd,
)
return
开发者ID:jessicalmetcalf,项目名称:emperor,代码行数:26,代码来源:util.py
示例3: main
def main():
option_parser, opts, args =\
parse_command_line_parameters(**script_info)
mapping_fp = opts.mapping_fp
fasta_dir = opts.fasta_dir
output_dir = opts.output_dir
count_start = int(opts.count_start)
filename_column = opts.filename_column
# Check input filepaths
try:
test_mapping_f = open(mapping_fp, "U")
except IOError:
raise IOError,("Cannot open mapping filepath "+\
"%s, please check filepath and permissions." % mapping_fp)
if not isdir(fasta_dir):
raise IOError,("Specified fasta dir "+
"%s, does not exist" % fasta_dir)
# Create output directory, check path/access to mapping file
create_dir(output_dir)
add_qiime_labels(open(mapping_fp, "U"), fasta_dir, filename_column,
output_dir, count_start)
开发者ID:Jorge-C,项目名称:qiime,代码行数:26,代码来源:add_qiime_labels.py
示例4: test_plot_rank_abundance_graphs
def test_plot_rank_abundance_graphs(self):
"""plot_rank_abundance_graphs works with any number of samples"""
self.otu_table = otu_table_fake.split("\n")
self.dir = get_tmp_filename(tmp_dir=self.tmp_dir, prefix="test_plot_rank_abundance", suffix="/")
create_dir(self.dir)
self._dirs_to_remove.append(self.dir)
# test empty sample name
self.assertRaises(ValueError, plot_rank_abundance_graphs, "", iter(self.otu_table), self.dir)
# test invalid sample name
self.assertRaises(ValueError, plot_rank_abundance_graphs, "Invalid_sample_name", iter(self.otu_table), self.dir)
# test with two samples
file_type = "pdf"
plot_rank_abundance_graphs("S3,S5", iter(self.otu_table), self.dir, file_type=file_type)
tmp_file = abspath(self.dir + "rank_abundance_cols_0_2." + file_type)
self.assertTrue(exists(tmp_file))
self.files_to_remove.append(tmp_file)
# test with all samples
plot_rank_abundance_graphs("*", iter(self.otu_table), self.dir, file_type=file_type)
tmp_file = abspath(self.dir + "rank_abundance_cols_0_1_2." + file_type)
self.files_to_remove.append(tmp_file)
self.assertTrue(exists(tmp_file))
开发者ID:Ecogenomics,项目名称:FrankenQIIME,代码行数:25,代码来源:test_plot_rank_abundance_graph.py
示例5: main
def main():
option_parser, opts, args = parse_command_line_parameters(**script_info)
output_dir = opts.output_dir
if output_dir:
create_dir(output_dir)
else:
if isfile(opts.input_dir):
# if output_dir is empty after the split, then a relative path was
# passed, and the input file is in the current directory
output_dir = split(opts.input_dir)[0] or '.'
else: # opts.input_dir is a directory
output_dir = opts.input_dir
if opts.no_trim and not opts.use_sfftools:
raise ValueError(
"When using the --no_trim option you must have the sfftools installed and must also pass the --use_sfftools option")
prep_sffs_in_dir(
opts.input_dir,
output_dir,
make_flowgram=opts.make_flowgram,
convert_to_flx=opts.convert_to_FLX,
use_sfftools=opts.use_sfftools,
no_trim=opts.no_trim)
开发者ID:ElDeveloper,项目名称:qiime,代码行数:27,代码来源:process_sff.py
示例6: split_otu_table_on_taxonomy_to_files
def split_otu_table_on_taxonomy_to_files(otu_table_fp,
level,
output_dir,
md_identifier='taxonomy',
md_processor=process_md_as_list):
""" Split OTU table by taxonomic level, writing otu tables to output dir
"""
results = []
otu_table = parse_biom_table(open(otu_table_fp,'U'))
create_dir(output_dir)
def split_f(obs_md):
try:
result = md_processor(obs_md,md_identifier,level)
except KeyError:
raise KeyError,\
"Metadata identifier (%s) is not associated with all (or any) observerations. You can modify the key with the md_identifier parameter." % md_identifier
except TypeError:
raise TypeError,\
"Can't correctly process the metadata string. If your input file was generated from QIIME 1.4.0 or earlier you may need to pass --md_as_string."
except AttributeError:
raise AttributeError,\
"Metadata category not found. If your input file was generated from QIIME 1.4.0 or earlier you may need to pass --md_identifier \"Consensus Lineage\"."
return result
for bin, sub_otu_table in otu_table.binObservationsByMetadata(split_f):
output_fp = '%s/otu_table_%s.biom' % (output_dir,bin)
output_f = open(output_fp,'w')
output_f.write(format_biom_table(sub_otu_table))
output_f.close()
results.append(output_fp)
return results
开发者ID:Jorge-C,项目名称:qiime,代码行数:33,代码来源:split_otu_table_by_taxonomy.py
示例7: split_otu_table_on_taxonomy_to_files
def split_otu_table_on_taxonomy_to_files(otu_table_fp, level, output_dir,
md_identifier='taxonomy',
md_processor=process_md_as_list):
""" Split OTU table by taxonomic level, writing otu tables to output dir
"""
results = []
otu_table = load_table(otu_table_fp)
create_dir(output_dir)
def split_f(id_, obs_md):
try:
result = md_processor(obs_md, md_identifier, level)
except KeyError:
raise KeyError("Metadata identifier (%s) is not associated with "
"all (or any) observerations. You can modify the "
"key with the md_identifier parameter." %
md_identifier)
except TypeError:
raise TypeError("Can't correctly process the metadata string. If "
"your input file was generated from QIIME 1.4.0 or"
" earlier you may need to pass --md_as_string.")
except AttributeError:
raise AttributeError("Metadata category not found. If your input "
"file was generated from QIIME 1.4.0 or "
"earlier you may need to pass --md_identifier"
" \"Consensus Lineage\".")
return result
for bin, sub_otu_table in otu_table.partition(split_f, axis='observation'):
output_fp = '%s/otu_table_%s.biom' % (output_dir, bin)
write_biom_table(sub_otu_table, output_fp)
results.append(output_fp)
return results
开发者ID:AhmedAbdelfattah,项目名称:qiime,代码行数:35,代码来源:split_otu_table_by_taxonomy.py
示例8: test_make_plots
def test_make_plots(self):
"""make_plots: tests whether the average plots are generated and if
dictionary for the html generation is properly formatted"""
filename1='/tmp/test/testcol_0_row_0_ave.png'
filename2='/tmp/test/testcol_0_row_0_raw.png'
folder1='/tmp/test/'
self._paths_to_clean_up = [filename1,filename2]
self._folders_to_cleanup=[folder1]
exp1={'SampleID': {'Sample1': {'test': {'ave': [' 7.000', ' 2.052'], 'err': [' nan', ' 0.000']}}}}
exp2={'test': {'groups': {'SampleID': {'Sample1': {'groupcolor': '#ff0000', 'raw_link': 'html_plots/testcol_0_row_0_raw.png', 'groupsamples': ['Sample1'], 'ave_link': 'html_plots/testcol_0_row_0_ave.png'}}}, 'samples': {'Sample1': {'color': '#ff0000', 'link': 'html_plots/testcol_0_row_0.png'}}}}
create_dir('/tmp/test/',False)
obs1,obs2 = make_plots(self.background_color,self.label_color, \
self.rare_data,self.ymax, self.xmax,'/tmp/test/', \
self.resolution, self.imagetype,self.groups,\
self.colors,self.data_colors,self.metric_name,\
self.labelname,self.rarefaction_data_mat, \
self.rarefaction_legend_mat,self.sample_dict, \
self.data_colors,self.colors2,self.mapping_lookup)
self.assertEqual(obs1,exp1)
self.assertEqual(obs2,exp2)
self.assertTrue(exists(filename1))
self.assertTrue(exists(filename2))
self.assertTrue(exists(folder1))
开发者ID:DDomogala3,项目名称:qiime,代码行数:29,代码来源:test_make_rarefaction_plots.py
示例9: test_plot_rank_abundance_graphs_dense
def test_plot_rank_abundance_graphs_dense(self):
"""plot_rank_abundance_graphs works with any number of samples (DenseOTUTable)"""
self.otu_table = parse_biom_table_str(otu_table_dense)
self.dir = get_tmp_filename(tmp_dir=self.tmp_dir,
prefix="test_plot_rank_abundance",
suffix="/")
create_dir(self.dir)
self._dirs_to_remove.append(self.dir)
#test empty sample name
self.assertRaises(ValueError, plot_rank_abundance_graphs, '',
self.otu_table, self.dir)
#test invalid sample name
self.assertRaises(ValueError, plot_rank_abundance_graphs,
'Invalid_sample_name',
self.otu_table, self.dir)
#test with two samples
file_type="pdf"
plot_rank_abundance_graphs('S3,S5', self.otu_table, self.dir,
file_type=file_type)
tmp_file = abspath(self.dir+"rank_abundance_cols_0_2."+file_type)
self.assertTrue(exists(tmp_file))
self.files_to_remove.append(tmp_file)
# test with all samples
plot_rank_abundance_graphs('*', self.otu_table, self.dir,
file_type=file_type)
tmp_file = abspath(self.dir+"rank_abundance_cols_0_1_2."+file_type)
self.files_to_remove.append(tmp_file)
self.assertTrue(exists(tmp_file))
开发者ID:jeycin,项目名称:qiime,代码行数:32,代码来源:test_plot_rank_abundance_graph.py
示例10: test_truncate_fasta_qual
def test_truncate_fasta_qual(self):
""" Test for overall module functionality """
base_pos = 80
output_dir = '/tmp/truncate_fasta_qual_test/'
create_dir(output_dir)
truncate_fasta_qual(self.fasta_fp, self.qual_fp, output_dir, base_pos)
actual_trunc_fasta_fp = output_dir +\
basename(self.fasta_fp).replace(".fasta", "_filtered.fasta")
actual_trunc_fasta_fp = open(actual_trunc_fasta_fp, "U")
actual_trunc_fasta = [line.strip() for line in actual_trunc_fasta_fp]
self.assertEqual(actual_trunc_fasta, expected_fasta_seqs)
actual_trunc_qual_fp = output_dir +\
basename(self.qual_fp).replace(".qual", "_filtered.qual")
actual_trunc_qual_fp = open(actual_trunc_qual_fp, "U")
actual_trunc_qual = [line.strip() for line in actual_trunc_qual_fp]
self.assertEqual(actual_trunc_qual, expected_qual_scores)
开发者ID:Jorge-C,项目名称:qiime,代码行数:27,代码来源:test_truncate_fasta_qual_files.py
示例11: main
def main():
option_parser, opts, args = parse_command_line_parameters(**script_info)
otu_table_fp = opts.otu_table_fp
mapping_fp = opts.mapping_fp
mapping_field = opts.mapping_field
output_dir = opts.output_dir
# column_rename_ids = opts.column_rename_ids
# include_repeat_cols = opts.include_repeat_cols
create_dir(output_dir)
# split mapping file
mapping_f = open(mapping_fp, 'U')
for fp_str, sub_mapping_s in split_mapping_file_on_field(mapping_f, mapping_field):
mapping_output_fp = join(output_dir, 'mapping_%s.txt' % fp_str)
open(mapping_output_fp, 'w').write(sub_mapping_s)
# split otu table
otu_table_base_name = splitext(split(otu_table_fp)[1])[0]
mapping_f = open(mapping_fp, 'U')
otu_table = load_table(otu_table_fp)
try:
for fp_str, sub_otu_table_s in split_otu_table_on_sample_metadata(
otu_table,
mapping_f,
mapping_field):
otu_table_output_fp = join(output_dir, '%s_%s.biom' % (
otu_table_base_name, fp_str))
write_biom_table(sub_otu_table_s, otu_table_output_fp)
except OTUTableSplitError as e:
option_parser.error(e)
开发者ID:Honglongwu,项目名称:qiime,代码行数:35,代码来源:split_otu_table.py
示例12: main
def main():
option_parser, opts, args =\
parse_command_line_parameters(**script_info)
fasta_fp = opts.fasta_fp
mapping_fp = opts.mapping_fp
output_dir = opts.output_dir
truncate_option = opts.truncate_option
primer_mismatches = int(opts.primer_mismatches)
create_dir(output_dir)
if truncate_option not in ['truncate_only', 'truncate_remove']:
raise ValueError('-z option must be either truncate_only or ' +
'truncate_remove')
try:
fasta_f = open(fasta_fp, "U")
fasta_f.close()
except IOError:
raise IOError("Unable to open fasta file, please check path/" +
"permissions.")
try:
mapping_f = open(fasta_fp, "U")
mapping_f.close()
except IOError:
raise IOError("Unable to open mapping file, please check path/" +
"permissions.")
truncate_reverse_primer(fasta_fp, mapping_fp, output_dir, truncate_option,
primer_mismatches)
开发者ID:ElDeveloper,项目名称:qiime,代码行数:31,代码来源:truncate_reverse_primer.py
示例13: main
def main():
option_parser, opts, args =\
parse_command_line_parameters(**script_info)
otu_table_fp = opts.otu_table_fp
mapping_fp = opts.mapping_fp
mapping_field = opts.mapping_field
output_dir = opts.output_dir
otu_table_base_name = splitext(split(otu_table_fp)[1])[0]
mapping_data, headers, comments = parse_mapping_file(open(mapping_fp,'U'))
try:
field_index = headers.index(mapping_field)
except ValueError:
option_parser.error("Field is not in mapping file (search is case "+\
"and white-space sensitive). \n\tProvided field: "+\
"%s. \n\tValid fields: %s" % (mapping_field,' '.join(headers)))
mapping_values = set([e[field_index] for e in mapping_data])
create_dir(output_dir)
for v in mapping_values:
v_fp_str = v.replace(' ','_')
otu_table_output_fp = join(output_dir,'%s_%s.txt' % (otu_table_base_name, v_fp_str))
mapping_output_fp = join(output_dir,'mapping_%s.txt' % v_fp_str)
filter_otus_and_map(open(mapping_fp,'U'),
open(otu_table_fp,'U'),
open(mapping_output_fp,'w'),
open(otu_table_output_fp,'w'),
valid_states_str="%s:%s" % (mapping_field,v),
num_seqs_per_otu=1)
开发者ID:Ecogenomics,项目名称:FrankenQIIME,代码行数:33,代码来源:split_otu_table.py
示例14: setUp
def setUp(self):
""" """
self.test_data = get_test_data_fps()
self.files_to_remove = []
self.dirs_to_remove = []
# Create example output directory
tmp_dir = get_qiime_temp_dir()
self.test_out = get_tmp_filename(tmp_dir=tmp_dir,
prefix='core_qiime_analyses_test_',
suffix='',
result_constructor=str)
self.dirs_to_remove.append(self.test_out)
create_dir(self.test_out)
self.qiime_config = load_qiime_config()
self.params = parse_qiime_parameters(params_f1)
# suppress stderr during tests (one of the systems calls in the
# workflow prints a warning, and we can't suppress that warning with
# warnings.filterwarnings) here because it comes from within the code
# executed through the system call. Found this trick here:
# http://stackoverflow.com/questions/9949633/suppressing-print-as-stdout-python
self.saved_stderr = sys.stderr
sys.stderr = StringIO()
initiate_timeout(180)
开发者ID:gxenomics,项目名称:qiime,代码行数:27,代码来源:test_downstream.py
示例15: __call__
def __call__(self,
query_fasta_fp,
database_fasta_fp,
output_dir,
observation_metadata_fp=None,
params=None,
HALT_EXEC=False):
if params is None:
params = {}
""" Call the DatabaseMapper """
create_dir(output_dir)
raw_output_fp = self._get_raw_output_fp(output_dir,
params)
output_observation_map_fp = '%s/observation_map.txt' % output_dir
output_biom_fp = '%s/observation_table.biom' % output_dir
log_fp = '%s/observation_table.log' % output_dir
self._assign_dna_reads_to_database(
query_fasta_fp=query_fasta_fp,
database_fasta_fp=database_fasta_fp,
raw_output_fp=raw_output_fp,
temp_dir=get_qiime_temp_dir(),
params=params,
HALT_EXEC=HALT_EXEC)
self._process_raw_output(raw_output_fp,
log_fp,
output_observation_map_fp)
self._generate_biom_output(output_observation_map_fp,
output_biom_fp,
observation_metadata_fp)
开发者ID:AhmedAbdelfattah,项目名称:qiime,代码行数:34,代码来源:map_reads_to_reference.py
示例16: main
def main():
option_parser, opts, args =\
parse_command_line_parameters(suppress_verbose=True, **script_info)
mapping_fp = opts.mapping_fp
has_barcodes = not opts.not_barcoded
variable_len_barcodes = opts.variable_len_barcodes
output_dir = opts.output_dir + "/"
char_replace = opts.char_replace
verbose = opts.verbose
disable_primer_check = opts.disable_primer_check
added_demultiplex_field = opts.added_demultiplex_field
# Create output directory, check path/access to mapping file
create_dir(output_dir)
# Test for valid replacement characters
valid_replacement_chars = digits + letters + "_" + "."
if char_replace not in valid_replacement_chars:
option_parser.error('-c option requires alphanumeric, period, or '+\
'underscore character.')
if len(char_replace) != 1:
option_parser.error('-c parameter must be a single character.')
check_mapping_file(mapping_fp, output_dir, has_barcodes, char_replace,\
verbose, variable_len_barcodes,
disable_primer_check, added_demultiplex_field)
开发者ID:clozupone,项目名称:qiime,代码行数:27,代码来源:check_id_map.py
示例17: main
def main():
option_parser, opts, args = parse_command_line_parameters(**script_info)
output_dir = opts.output_dir
create_dir(output_dir)
otu_table_fp = opts.otu_table
otu_table_fh = open(otu_table_fp, 'U')
otu_table = parse_biom_table(otu_table_fh)
otu_table_fh.close()
tree_fh = open(opts.tree_file, 'U')
tree = DndParser(tree_fh)
tree_fh.close()
mapping_fp = opts.mapping_fp
if mapping_fp:
mapping_f = open(mapping_fp, 'U')
input_map_basename = splitext(split(mapping_fp)[1])[0]
else:
mapping_f = None
input_map_basename = None
input_table_basename = splitext(split(otu_table_fp)[1])[0]
simsam_range_to_files(otu_table,
tree,
simulated_sample_sizes=map(int, opts.num.split(',')),
dissimilarities=map(float, opts.dissim.split(',')),
output_dir=output_dir,
mapping_f=mapping_f,
output_table_basename=input_table_basename,
output_map_basename=input_map_basename)
开发者ID:Bonder-MJ,项目名称:qiime,代码行数:33,代码来源:simsam.py
示例18: setUp
def setUp(self):
self._files_to_remove = []
self.fasta_file_path = get_tmp_filename(prefix='fastq_', \
suffix='.fastq')
fastq_file = open(self.fasta_file_path, 'w')
fastq_file.write(fastq_test_string)
fastq_file.close()
#Error testing files
false_fasta_file = '/'
false_qual_file = '/'
self.read_only_output_dir = get_tmp_filename(prefix = 'read_only_', \
suffix = '/')
create_dir(self.read_only_output_dir)
chmod(self.read_only_output_dir, 0577)
self.output_dir = get_tmp_filename(prefix = 'convert_fastaqual_fastq_',\
suffix = '/')
self.output_dir += sep
create_dir(self.output_dir)
self._files_to_remove.append(self.fasta_file_path)
开发者ID:DDomogala3,项目名称:qiime,代码行数:26,代码来源:test_convert_fastaqual_fastq.py
示例19: main
def main():
option_parser, opts, args = parse_command_line_parameters(**script_info)
out_dir = opts.output_dir
create_dir(out_dir)
if opts.type == 'gradient':
subset_fn = choose_gradient_subset
elif opts.type == 'cluster':
subset_fn = choose_cluster_subsets
subset_otu_table, subset_map_str = subset_fn(open(opts.otu_table_fp, 'U'),
open(opts.map_fp, 'U'), opts.category, opts.num_total_samples)
subset_otu_table_fp = join(out_dir, basename(opts.otu_table_fp))
subset_otu_table_f = open(subset_otu_table_fp, 'w')
subset_otu_table.getBiomFormatJsonString('choose_data_subset.py '
'(microbiogeo)',
subset_otu_table_f)
subset_otu_table_f.close()
subset_map_fp = join(out_dir, basename(opts.map_fp))
subset_map_f = open(subset_map_fp, 'w')
subset_map_f.write(subset_map_str)
subset_map_f.close()
开发者ID:gregcaporaso,项目名称:microbiogeo,代码行数:25,代码来源:choose_data_subset.py
示例20: main
def main():
option_parser, opts, args = \
parse_command_line_parameters(suppress_verbose=True, **script_info)
input_dir = opts.input_dir
parameter_fp = opts.parameter_fp
read1_indicator = opts.read1_indicator
read2_indicator = opts.read2_indicator
match_barcodes = opts.match_barcodes
barcode_indicator = opts.barcode_indicator
leading_text = opts.leading_text
trailing_text = opts.trailing_text
include_input_dir_path = opts.include_input_dir_path
output_dir = abspath(opts.output_dir)
remove_filepath_in_name = opts.remove_filepath_in_name
print_only = opts.print_only
if remove_filepath_in_name and not include_input_dir_path:
option_parser.error("If --remove_filepath_in_name is enabled, "
"--include_input_dir_path must also be enabled.")
if opts.parameter_fp:
with open(opts.parameter_fp, 'U') as parameter_f:
params_dict = parse_qiime_parameters(parameter_f)
params_str = get_params_str(params_dict['join_paired_ends'])
else:
params_dict = {}
params_str = ""
create_dir(output_dir)
all_files = []
extensions = ['.fastq.gz', '.fastq', '.fq.gz', '.fq']
for root, dir, fps in walk(input_dir):
for fp in fps:
for extension in extensions:
if fp.endswith(extension):
all_files += [abspath(join(root, fp))]
pairs, bc_pairs = get_pairs(all_files, read1_indicator, read2_indicator,
match_barcodes, barcode_indicator)
commands = create_commands_jpe(pairs, output_dir,
params_str, leading_text, trailing_text, include_input_dir_path,
remove_filepath_in_name, match_barcodes, bc_pairs)
qiime_config = load_qiime_config()
if print_only:
command_handler = print_commands
else:
command_handler = call_commands_serially
logger = WorkflowLogger(generate_log_fp(output_dir),
params=params_dict,
qiime_config=qiime_config)
# Call the command handler on the list of commands
command_handler(commands,
status_update_callback=no_status_updates,
logger=logger,
close_logger_on_success=True)
开发者ID:Springbudder,项目名称:qiime,代码行数:60,代码来源:multiple_join_paired_ends.py
注:本文中的qiime.util.create_dir函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论