本文整理汇总了Python中qiime.util.get_qiime_project_dir函数的典型用法代码示例。如果您正苦于以下问题:Python get_qiime_project_dir函数的具体用法?Python get_qiime_project_dir怎么用?Python get_qiime_project_dir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_qiime_project_dir函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
"""define some top-level data"""
qiime_dir = get_qiime_project_dir()
self.key = 'qiime_test'
self.project_id = 'qiime_test'
self.sample_id = 'qiime_sample1'
self.params = [('key', self.key), ('sample', self.sample_id),
('project', self.project_id)]
test_dir = path.dirname(path.abspath(__file__))
self.seq_file = path.join(test_dir, 'test_support_files',
'qiime_tutorial_split_lib_seqs_subset.fna')
self.output_dir = mkdtemp()
self.sample_file = [('file', 'qiime_test.fna', fasta_example)]
self._paths_to_clean_up = []
self._dirs_to_clean_up = []
# make the webfile directory
try:
mkdir(self.output_dir)
except OSError:
pass
# define directory to clean up
self._dirs_to_clean_up = [self.output_dir]
示例2: setUp
def setUp(self):
self.test_map = {"1": ("a", "b", "c"), "2": ("d", "e", "f")}
self.labels = [
"Uneven1_1 FV9NWLF.01.EVGI8 orig_bc=TCGAGCGAATCT new_bc=TCGAGCGAATCT bc_diffs=0",
"Even1_2 FV9NWLF.01.DROG9 orig_bc=TAGTTGCGAGTC new_bc=TAGTTGCGAGTC bc_diffs=0",
"Uneven1_3 FV9NWLF.01.DZTVJ orig_bc=TCGAGCGAATCT new_bc=TCGAGCGAATCT bc_diffs=0",
"Uneven3_4 FV9NWLF.01.DI8SC orig_bc=TCTGCTAGATGT new_bc=TCTGCTAGATGT bc_diffs=0",
"Even3_5 FV9NWLF.01.DW381 orig_bc=TCATCGCGATAT new_bc=TCATCGCGATAT bc_diffs=0",
"Even3_6 FV9NWLF01DP96S orig_bc=TCATCGCGATAT new_bc=TCATCGCGATAT bc_diffs=0",
"Uneven2_7 FV9NWLF01BOY7E orig_bc=TCGTTCACATGA new_bc=TCGTTCACATGA bc_diffs=0",
"Even1_8 FV9NWLF01A0OG1 orig_bc=TAGTTGCGAGTC new_bc=TAGTTGCGAGTC bc_diffs=0",
"Even2_9 FV9NWLF01DJZFF orig_bc=TCACGATTAGCG new_bc=TCACGATTAGCG bc_diffs=0",
"Uneven1_10 FV9NWLF01D4LTB orig_bc=TCGAGCGAATCT new_bc=TCGAGCGAATCT bc_diffs=0",
]
self.invalid_sequence_identifiers = [
["Uneven1_1 FV9NWLF_01_EVGI8 orig_bc=TCGAGCGAATCT new_bc=TCGAGCGAATCT bc_diffs=0"],
["Even1_2 FV9NWLF_01_DROG9 orig_bc=TAGTTGCGAGTC new_bc=TAGTTGCGAGTC bc_diffs=0"],
["Even1_8 FV9NWLF-01-A0OG1 orig_bc=TAGTTGCGAGTC new_bc=TAGTTGCGAGTC bc_diffs=0"],
["Even2_9 FV9NWLF_01-DJZFF orig_bc=TCACGATTAGCG new_bc=TCACGATTAGCG bc_diffs=0"],
["Uneven1_10 FV9NWLF_01.D4LTB orig_bc=TCGAGCGAATCT new_bc=TCGAGCGAATCT bc_diffs=0"],
]
self.tiny_test = get_qiime_project_dir() + "/qiime/support_files/denoiser/TestData/tiny_test.sff.txt"
示例3: setUp
def setUp(self):
self.test_map = {'1': ('a', 'b', 'c'),
'2': ('d', 'e', 'f')}
self.labels = [
'Uneven1_1 FV9NWLF.01.EVGI8 orig_bc=TCGAGCGAATCT new_bc=TCGAGCGAATCT bc_diffs=0',
'Even1_2 FV9NWLF.01.DROG9 orig_bc=TAGTTGCGAGTC new_bc=TAGTTGCGAGTC bc_diffs=0',
'Uneven1_3 FV9NWLF.01.DZTVJ orig_bc=TCGAGCGAATCT new_bc=TCGAGCGAATCT bc_diffs=0',
'Uneven3_4 FV9NWLF.01.DI8SC orig_bc=TCTGCTAGATGT new_bc=TCTGCTAGATGT bc_diffs=0',
'Even3_5 FV9NWLF.01.DW381 orig_bc=TCATCGCGATAT new_bc=TCATCGCGATAT bc_diffs=0',
'Even3_6 FV9NWLF01DP96S orig_bc=TCATCGCGATAT new_bc=TCATCGCGATAT bc_diffs=0',
'Uneven2_7 FV9NWLF01BOY7E orig_bc=TCGTTCACATGA new_bc=TCGTTCACATGA bc_diffs=0',
'Even1_8 FV9NWLF01A0OG1 orig_bc=TAGTTGCGAGTC new_bc=TAGTTGCGAGTC bc_diffs=0',
'Even2_9 FV9NWLF01DJZFF orig_bc=TCACGATTAGCG new_bc=TCACGATTAGCG bc_diffs=0',
'Uneven1_10 FV9NWLF01D4LTB orig_bc=TCGAGCGAATCT new_bc=TCGAGCGAATCT bc_diffs=0']
self.invalid_sequence_identifiers = [
['Uneven1_1 FV9NWLF_01_EVGI8 orig_bc=TCGAGCGAATCT new_bc=TCGAGCGAATCT bc_diffs=0'],
['Even1_2 FV9NWLF_01_DROG9 orig_bc=TAGTTGCGAGTC new_bc=TAGTTGCGAGTC bc_diffs=0'],
['Even1_8 FV9NWLF-01-A0OG1 orig_bc=TAGTTGCGAGTC new_bc=TAGTTGCGAGTC bc_diffs=0'],
['Even2_9 FV9NWLF_01-DJZFF orig_bc=TCACGATTAGCG new_bc=TCACGATTAGCG bc_diffs=0'],
['Uneven1_10 FV9NWLF_01.D4LTB orig_bc=TCGAGCGAATCT new_bc=TCGAGCGAATCT bc_diffs=0']]
self.tiny_test = get_qiime_project_dir() +\
"/qiime/support_files/denoiser/TestData/tiny_test.sff.txt"
示例4: test_for_obsolete_values
def test_for_obsolete_values(self):
"""local qiime_config has no extra params"""
qiime_project_dir = get_qiime_project_dir()
orig_config = parse_qiime_config_file(open(qiime_project_dir +
'/qiime/support_files/qiime_config'))
#check the env qiime_config
qiime_config_env_filepath = getenv('QIIME_CONFIG_FP')
if qiime_config_env_filepath:
qiime_config_via_env= parse_qiime_config_file(open(qiime_config_env_filepath))
extra_vals = []
for key in qiime_config_via_env:
if key not in orig_config:
extra_vals.append(key)
if extra_vals:
self.fail("The qiime_config file set via QIIME_CONFIG_FP"+
"enviroment variable contains obsolete parameters:\n"+
", ".join(extra_vals))
# check the qiime_config in $HOME/.qiime_config
home_dir = getenv('HOME')
if (exists(home_dir+"/.qiime_config")):
qiime_config_home = parse_qiime_config_file(open(home_dir+"/.qiime_config"))
extra_vals = []
for key in qiime_config_home:
if key not in orig_config:
extra_vals.append(key)
if extra_vals:
self.fail("The .qiime_config in your HOME contains obsolete "+
"parameters:\n" + ", ".join(extra_vals))
示例5: test_for_unrecognized_values
def test_for_unrecognized_values(self):
"""qiime_config has no extra values"""
error_msg_fragment = (" contains unrecognized values:\n%s\nYou can "
"safely remove these values from your QIIME "
"config file as they will be ignored by QIIME.")
qiime_project_dir = get_qiime_project_dir()
orig_config = parse_qiime_config_file(open(qiime_project_dir +
'/qiime/support_files/qiime_config'))
# check the env qiime_config
qiime_config_env_filepath = getenv('QIIME_CONFIG_FP')
if qiime_config_env_filepath:
qiime_config_via_env = parse_qiime_config_file(
open(qiime_config_env_filepath))
extra_vals = []
for key in qiime_config_via_env:
if key not in orig_config:
extra_vals.append(key)
if extra_vals:
self.fail("The QIIME config file set via the QIIME_CONFIG_FP "
"environment variable" +
error_msg_fragment % ", ".join(extra_vals))
# check the qiime_config in $HOME/.qiime_config
home_dir = getenv('HOME')
if (exists(home_dir + "/.qiime_config")):
qiime_config_home = parse_qiime_config_file(
open(home_dir + "/.qiime_config"))
extra_vals = []
for key in qiime_config_home:
if key not in orig_config:
extra_vals.append(key)
if extra_vals:
self.fail("The .qiime_config in your HOME" +
error_msg_fragment % ", ".join(extra_vals))
示例6: test_support_files_available
def test_support_files_available(self):
"""support_files are available """
# check that the qiime/support_files directory exists
support_files_dir = \
join(get_qiime_project_dir(),'qiime','support_files')
self.assertTrue(exists(support_files_dir))
# check that a file in qiime/support_files exists
default_qiime_config_fp = join(support_files_dir,'qiime_config')
self.assertTrue(exists(default_qiime_config_fp))
示例7: test_generate_heatmap_plots
def test_generate_heatmap_plots(self):
"""generate_heatmap_plots: create default output files"""
# create directories and move js files to verify everything works
# in the script file
dir_path = join(self.output_dir, 'test')
create_dir(dir_path)
js_dir_path = join(dir_path, 'js')
create_dir(js_dir_path)
self._folders_to_cleanup.append(dir_path)
qiime_dir = get_qiime_project_dir()
js_path = join(qiime_dir, 'qiime/support_files/js')
shutil.copyfile(join(js_path, 'overlib.js'),
join(js_dir_path, 'overlib.js'))
shutil.copyfile(join(js_path, 'otu_count_display.js'),
join(js_dir_path, 'otu_count_display.js'))
shutil.copyfile(join(js_path, 'jquery.js'),
join(js_dir_path, 'jquery.js'))
shutil.copyfile(join(js_path, 'jquery.tablednd_0_5.js'),
join(js_dir_path, 'jquery.tablednd_0_5.js'))
# generate otu_table object
orig_data = array([[0, 1, 2], [1000, 0, 0]])
orig_otu_table = table_factory(orig_data,
['Sample1', 'Sample2', 'Sample3'],
['OTU1', 'OTU2'],
[None, None, None],
[{"taxonomy": ["Bacteria"]},
{"taxonomy": ["Archaea"]}])
# put in an OTU sort order and sample order
otu_sort = ['OTU2', 'OTU1']
sample_sort = ['Sample2', 'Sample1', 'Sample3']
num_otu_hits = 3
# generate test files
generate_heatmap_plots(num_otu_hits, orig_otu_table, otu_sort,
sample_sort, dir_path, js_dir_path,
'test', fractional_values=False)
self.assertEqual(open(join(js_dir_path, 'test.js'), 'U').read(),
exp_js_output_file)
示例8: setUp
def setUp(self):
self.data = dict({"0": "ab", "1":"abababa", "2":"abab",
"3":"baba", "4":"ababaa","5":"a", "6":"abababa",
"7":"bab", "8":"babba"})
self.mapping = {"1":["0","2","5","6"],
"3":[],
"4":[],
"8":["7"]}
self.test_map = {'1': ('a','b','c'),
'2': ('d','e','f')}
#realistic test file
self.tiny_test = get_qiime_project_dir() +\
"/qiime/support_files/denoiser/TestData/tiny_test.sff.txt"
#set up test file
open("/tmp/denoiser_utils_dummy.tmp","w")
self.files_to_remove=["/tmp/denoiser_utils_dummy.tmp"]
self.tmpdir=""
示例9: setUp
def setUp(self):
"""define some top-level data"""
qiime_dir = get_qiime_project_dir()
self.key = "qiime_test"
self.project_id = "qiime_test"
self.sample_id = "qiime_sample1"
self.params = [("key", self.key), ("sample", self.sample_id), ("project", self.project_id)]
test_dir = path.dirname(path.abspath(__file__))
self.seq_file = path.join(test_dir, "test_support_files", "qiime_tutorial_split_lib_seqs_subset.fna")
self.output_dir = get_random_directory_name(output_dir="/tmp/")
self.sample_file = [("file", "qiime_test.fna", fasta_example)]
self._paths_to_clean_up = []
self._dirs_to_clean_up = []
# make the webfile directory
try:
mkdir(self.output_dir)
except OSError:
pass
# define directory to clean up
self._dirs_to_clean_up = [self.output_dir]
示例10: test_get_qiime_project_dir
def test_get_qiime_project_dir(self):
"""getting the qiime project directory functions as expected """
# Do an explicit check on whether the file system containing
# the current file is case insensitive. This is in response
# to SF bug #2945548, where this test would fail on certain
# unusual circumstances on case-insensitive file systems
# because the case of abspath(__file__) was inconsistent.
# (If you don't believe this, set case_insensitive_filesystem
# to False, and rename your top-level Qiime directory as
# qiime on OS X. That sould cause this test to fail as
# actual will be path/to/qiime and expected will be
# path/to/Qiime.) Note that we don't need to change anything
# in the get_qiime_project_dir() function as if the
# file system is case insenstive, the case of the returned
# string is irrelevant.
case_insensitive_filesystem = \
exists(__file__.upper()) and exists(__file__.lower())
actual = get_qiime_project_dir()
# I base the expected here off the imported location of
# qiime/util.py here, to handle cases where either the user has
# Qiime in their PYTHONPATH, or when they've installed it with
# setup.py.
# If util.py moves this test will fail -- that
# is what we want in this case, as the get_qiime_project_dir()
# function would need to be modified.
import qiime.util
util_py_filepath = abspath(abspath(qiime.util.__file__))
expected = dirname(dirname(util_py_filepath))
if case_insensitive_filesystem:
# make both lowercase if the file system is case insensitive
actual = actual.lower()
expected = expected.lower()
self.assertEqual(actual,expected)
示例11: main
def main():
option_parser, opts, args = parse_command_line_parameters(**script_info)
matplotlib_version = re.split("[^\d]", matplotlib.__version__)
matplotlib_version_info = tuple([int(i) for i in matplotlib_version if \
i.isdigit()])
if matplotlib_version_info != (1,1,0):
print "This code was only tested with Matplotlib-1.1.0"
data = {}
prefs,data,background_color,label_color,ball_scale, arrow_colors= \
sample_color_prefs_and_map_data_from_options(opts)
data['ellipsoid_method']=opts.ellipsoid_method
if 0.00 <= opts.ellipsoid_opacity <= 1.00:
data['alpha']=opts.ellipsoid_opacity
else:
raise ValueError, 'The opacity must be a value between 0 and 1!'
#Open and get coord data
if os.path.isdir(opts.coord_fname) and opts.master_pcoa:
data['coord'],data['support_pcoas'] = load_pcoa_files(opts.coord_fname)
data['coord']=get_coord(opts.master_pcoa)
elif os.path.isdir(opts.coord_fname):
data['coord'],data['support_pcoas'] = load_pcoa_files(opts.coord_fname)
else:
data['coord'] = get_coord(opts.coord_fname)
filepath=opts.coord_fname
basename,extension=os.path.splitext(filepath)
filename='%s_2D_PCoA_plots' % (basename)
qiime_dir=get_qiime_project_dir()
js_path=os.path.join(qiime_dir,'qiime','support_files','js')
if opts.output_dir:
if os.path.exists(opts.output_dir):
dir_path=opts.output_dir
else:
try:
os.mkdir(opts.output_dir)
dir_path=opts.output_dir
except OSError:
pass
else:
dir_path='./'
html_dir_path=dir_path
data_dir_path = get_random_directory_name(output_dir=dir_path)
try:
os.mkdir(data_dir_path)
except OSError:
pass
js_dir_path = os.path.join(html_dir_path,'js')
try:
os.mkdir(js_dir_path)
except OSError:
pass
shutil.copyfile(os.path.join(js_path,'overlib.js'), \
os.path.join(js_dir_path,'overlib.js'))
try:
action = generate_2d_plots
except NameError:
action = None
#Place this outside try/except so we don't mask NameError in action
if action:
action(prefs,data,html_dir_path,data_dir_path,filename,background_color,
label_color,opts.scree)
示例12: get_flowgram_ali_exe
def get_flowgram_ali_exe():
"""Return the path to the flowgram alignment prog
"""
fp = get_qiime_project_dir() +\
"/qiime/support_files/denoiser/bin/FlowgramAli_4frame"
return fp
示例13: check_mapping_file
def check_mapping_file(mapping_fp,
output_dir=".",
has_barcodes=True,
char_replace="_",
verbose=True,
variable_len_barcodes=False,
disable_primer_check=False,
added_demultiplex_field=None,
suppress_html=False):
""" Main program function for checking mapping file
Checks mapping file for errors, warnings, writes log file, html file,
and corrected mapping file.
mapping_fp: path to metadata mapping file
output_dir: output directory for log, html, corrected mapping file.
has_barcodes: If True, will test for perform barcodes test (presence,
uniqueness, valid IUPAC DNA chars).
char_replace: Character used to replace invalid characters in data
fields. SampleIDs always use periods to be MIENS compliant.
verbose: If True, a message about warnings and/or errors will be printed
to stdout.
variable_len_barcodes: If True, suppresses warnings about barcodes of
varying length.
disable_primer_check: If True, disables tests for valid primer sequences.
added_demultiplex_field: If specified, references a field in the mapping
file to use for demultiplexing. These are to be read from fasta labels
during the actual demultiplexing step. All combinations of barcodes,
primers, and the added_demultiplex_field must be unique."""
header, mapping_data, run_description, errors, warnings =\
process_id_map(open(mapping_fp, 'U'), disable_primer_check,
has_barcodes, char_replace, variable_len_barcodes,
added_demultiplex_field, strip_quotes=False, suppress_stripping=True)
if not suppress_html:
formatted_html = format_mapping_html_data(header, mapping_data,
errors, warnings)
output_html = join(output_dir +
basename(mapping_fp).replace('.txt', '') + ".html")
html_f = open(output_html, "w")
html_f.write(formatted_html)
# get QIIME directory
qiime_dir = get_qiime_project_dir()
# Write javascript file necessary for mouseover tooltips.
# move javascript file to javascript output directory
copyfile(join(qiime_dir, 'qiime', 'support_files',
'js/overlib.js'), join(output_dir, 'overlib.js'))
corrected_mapping_data = correct_mapping_data(mapping_data,
header, char_replace)
output_corrected_fp = join(output_dir +
basename(mapping_fp).replace('.txt', '') + "_corrected.txt")
write_corrected_mapping(output_corrected_fp, header, run_description,
corrected_mapping_data)
output_log_fp = join(output_dir +
basename(mapping_fp).replace('.txt', '') + ".log")
write_log_file(output_log_fp, errors, warnings)
if verbose:
if errors or warnings:
print "Errors and/or warnings detected in mapping file. Please " +\
"check the log and html file for details."
else:
print "No errors or warnings were found in mapping file."
示例14: _get_R_script_dir
def _get_R_script_dir(self):
"""Returns the path to the qiime R source directory
"""
qiime_dir = get_qiime_project_dir()
script_dir = join(qiime_dir,'qiime','support_files','R')
return script_dir
示例15: main
def main():
option_parser, opts, args = parse_command_line_parameters(**script_info)
# Some code for error checking of input args:
# Check if distance_matrix_file is valid:
try:
d_header, d_mat = parse_distmat(open(opts.distance_matrix_file, "U"))
except:
option_parser.error(
"This does not look like a valid distance matrix file. Please supply a valid distance matrix file using the -d option."
)
if not is_symmetric_and_hollow(d_mat):
option_parser.error("The distance matrix must be symmetric and " "hollow.")
# Check if map_fname is valid:
try:
mapping, m_header, m_comments = parse_mapping_file(open(opts.map_fname, "U"))
except QiimeParseError:
option_parser.error(
"This does not look like a valid metadata mapping file. Please supply a valid mapping file using the -m option."
)
# make sure background_color is valid
if opts.background_color not in ["black", "white"]:
option_parser.error(
"'%s' is not a valid background color. Please pass in either 'black' or 'white' using the -k option."
% (opts.background_color)
)
# make sure prefs file is valid if it exists
if opts.prefs_path is not None:
try:
prefs_file = open(opts.prefs_path, "U").read()
except IOError:
option_parser.error(
"Provided prefs file, '%s', does not exist. Please pass in a valid prefs file with the -p option."
% (opts.prefs_path)
)
if opts.prefs_path is not None:
prefs = parse_prefs_file(prefs_file)
else:
prefs = None
color_prefs, color_data, background_color, label_color, ball_scale, arrow_colors = sample_color_prefs_and_map_data_from_options(
opts
)
# list of labelname, groups, colors, data_colors, data_color_order
groups_and_colors = list(iter_color_groups(mapping=color_data["map"], prefs=color_prefs))
# dict mapping labelname to list of: [groups, colors, data_colors,
# data_color_order]
field_to_colors = {}
for color_info in groups_and_colors:
field_to_colors[color_info[0]] = color_info[1:]
qiime_dir = get_qiime_project_dir() + "/qiime/support_files/"
fields = opts.fields
if fields is not None:
fields = map(strip, fields.split(","))
fields = [i.strip('"').strip("'") for i in fields]
elif prefs is not None:
fields = prefs.get("FIELDS", None)
else:
fields = get_interesting_mapping_fields(mapping, m_header)
# Check that all provided fields are valid:
if fields is not None:
for f in fields:
if f not in m_header:
option_parser.error(
"The field, %s, is not in the provided mapping file. Please supply correct fields (using the -f option or providing a 'FIELDS' list in the prefs file) corresponding to fields in mapping file."
% (f)
)
within_distances, between_distances, dmat = group_distances(
mapping_file=opts.map_fname,
dmatrix_file=opts.distance_matrix_file,
fields=fields,
dir_prefix=get_random_directory_name(output_dir=opts.dir_path, prefix="distances"),
)
if not opts.suppress_html_output:
# histograms output path
histograms_path = path.join(opts.dir_path, "histograms")
try:
mkdir(histograms_path)
except OSError: # raised if dir exists
pass
# draw all histograms
distances_dict, label_to_histogram_filename = draw_all_histograms(
single_field=within_distances,
paired_field=between_distances,
dmat=dmat,
histogram_dir=histograms_path,
#.........这里部分代码省略.........