本文整理汇总了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函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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]
开发者ID:AhmedAbdelfattah,项目名称:qiime,代码行数:26,代码来源:test_submit_to_mgrast.py
示例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"
开发者ID:davidsoergel,项目名称:qiime,代码行数:25,代码来源:test_flowgram_filter.py
示例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"
开发者ID:ElDeveloper,项目名称:qiime,代码行数:25,代码来源:test_flowgram_filter.py
示例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))
开发者ID:cmhill,项目名称:qiime,代码行数:30,代码来源:print_qiime_config.py
示例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))
开发者ID:Bonder-MJ,项目名称:qiime,代码行数:35,代码来源:print_qiime_config.py
示例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))
开发者ID:carze,项目名称:clovr-base,代码行数:10,代码来源:test_util.py
示例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)
开发者ID:Bonder-MJ,项目名称:qiime,代码行数:47,代码来源:test_make_otu_heatmap_html.py
示例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=""
开发者ID:Jorge-C,项目名称:qiime,代码行数:19,代码来源:test_utils.py
示例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]
开发者ID:ranjit58,项目名称:qiime,代码行数:24,代码来源:test_submit_to_mgrast.py
示例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)
开发者ID:carze,项目名称:clovr-base,代码行数:36,代码来源:test_util.py
示例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)
开发者ID:cmhill,项目名称:qiime,代码行数:76,代码来源:make_2d_plots.py
示例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
开发者ID:Ecogenomics,项目名称:FrankenQIIME,代码行数:6,代码来源:utils.py
示例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."
开发者ID:ElDeveloper,项目名称:qiime,代码行数:73,代码来源:check_id_map.py
示例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
开发者ID:rob-knight,项目名称:qiime,代码行数:6,代码来源:supervised_learning.py
示例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,
#.........这里部分代码省略.........
开发者ID:qinjunjie,项目名称:qiime,代码行数:101,代码来源:make_distance_histograms.py
示例16: main
def main():
option_parser, opts, args = parse_command_line_parameters(**script_info)
# get QIIME directory
qiime_dir = get_qiime_project_dir()
if not opts.counts_fname:
option_parser.error("A list of input files must be specified")
# get color preferences
color_prefs, color_data, background_color, label_color = taxonomy_color_prefs_and_map_data_from_options(opts)
colorby = opts.colorby
if colorby == None:
colorby = []
for c in color_data["counts"].values():
colorby.extend(c[0])
else:
colorby = colorby.strip().strip("'").split(",")
counts_fname = opts.counts_fname
# Define labels to use
labels = opts.labels
if not opts.labels:
new_labels = []
# create an empty list since the user didn't specify labels
for i in counts_fname:
new_labels.append("")
labels = ",".join(new_labels)
data = [(label, f.strip()) for f, label in zip(counts_fname, labels.split(","))]
filepath = data[0][1]
filename = filepath.strip().rpartition("/")[0]
num_categories = int(opts.num_categories)
if num_categories <= 0:
raise ValueError, "The number of categories has to be greater than 0!"
# create directory path
dir_path = os.getcwd()
if opts.dir_path:
dir_path = opts.dir_path
try:
create_dir(opts.dir_path)
except OSError:
pass
# make javascript output directory
javascript_path = os.path.join(dir_path, "js")
try:
create_dir(javascript_path)
except OSError: # raised if dir exists
pass
# make raw_data output directory
raw_data_path = os.path.join(dir_path, "raw_data")
try:
create_dir(raw_data_path)
except OSError: # raised if dir exists
pass
# move javascript file to javascript output directory
shutil.copyfile(
os.path.join(qiime_dir, "qiime", "support_files", "js/overlib.js"), os.path.join(javascript_path, "overlib.js")
)
# make css output directory
css_path = os.path.join(dir_path, "css")
try:
create_dir(css_path)
except OSError: # raised if dir exists
pass
# move css file to css output directory
shutil.copyfile(
os.path.join(qiime_dir, "qiime", "support_files", "css/qiime_style.css"),
os.path.join(css_path, "qiime_style.css"),
)
# verify all parameters are valid
plot_width = float(opts.x_width)
if plot_width <= 0:
raise ValueError, "The width of the plot has to be greater than 0!"
plot_height = float(opts.y_height)
if plot_height <= 0:
raise ValueError, "The height of the plot has to be greater than 0!"
bar_width = float(opts.bar_width)
if bar_width <= 0 or bar_width > 1:
raise ValueError, "The bar width of the plot has to be between 0 and 1!"
dpi = float(opts.dpi)
if dpi <= 0:
raise ValueError, "The dpi of the plot has to be greater than 0!"
resize_nth_label = int(opts.resize_nth_label)
if resize_nth_label < 0:
#.........这里部分代码省略.........
开发者ID:rob-knight,项目名称:qiime,代码行数:101,代码来源:plot_taxa_summary.py
示例17: get_qiime_project_dir
import signal
import os
from os import remove, rmdir
from shutil import rmtree
from subprocess import Popen, PIPE, STDOUT
from cogent.util.unit_test import TestCase, main
from cogent.parse.fasta import MinimalFastaParser
from qiime.util import get_qiime_project_dir, get_qiime_scripts_dir
from qiime.denoiser.utils import check_flowgram_ali_exe
from qiime.denoiser.preprocess import make_tmp_name
PROJECT_HOME = get_qiime_project_dir()
# timeout handling taken from test_workflow.py
class TimeExceededError(Exception):
pass
allowed_seconds_per_test = 240
def timeout(signum, frame):
raise TimeExceededError, "Test failed to run in allowed time (%d seconds)." % allowed_seconds_per_test
class DenoiserTests(TestCase):
def setUp(self):
开发者ID:davidsoergel,项目名称:qiime,代码行数:30,代码来源:test_denoiser.py
示例18: main
#.........这里部分代码省略.........
# checks specific for the modified first difference algorithm
if add_vectors["vectors_algorithm"] == "wdiff":
try:
add_vectors["window_size"] = int(opts.window_size)
except TypeError:
raise TypeError, "Specify --window_size as an integer"
# sanity check as the value can only be greater or equal to one
if add_vectors["window_size"] < 1:
raise ValueError, "The value of window_size is invalid, " + "the value must be greater than zero, not %d" % add_vectors[
"window_size"
]
else:
add_vectors["vectors_algorithm"] = None
add_vectors["vectors_path"] = opts.vectors_path
else:
add_vectors = None
if opts.taxa_fname != None:
# get taxonomy counts
# get list of sample_ids that haven't been removed
sample_ids = data["coord"][0]
# get taxa summaries for all sample_ids
lineages, taxa_counts = get_taxa(opts.taxa_fname, sample_ids)
data["taxa"] = {}
data["taxa"]["lineages"] = lineages
data["taxa"]["counts"] = taxa_counts
# get average relative abundance of taxa
data["taxa"]["prevalence"] = get_taxa_prevalence(data["taxa"]["counts"])
remove_rare_taxa(data["taxa"], nkeep=opts.n_taxa_keep)
# get coordinates of taxa (weighted mean of sample scores)
data["taxa"]["coord"] = get_taxa_coords(data["taxa"]["counts"], data["coord"][1])
data["taxa"]["coord"]
# write taxa coords if requested
if not opts.biplot_output_file is None:
output = make_biplot_scores_output(data["taxa"])
fout = open(opts.biplot_output_file, "w")
fout.write("\n".join(output))
fout.close()
if opts.output_dir:
create_dir(opts.output_dir, False)
dir_path = opts.output_dir
else:
dir_path = "./"
qiime_dir = get_qiime_project_dir()
jar_path = os.path.join(qiime_dir, "qiime/support_files/jar/")
data_dir_path = get_random_directory_name(output_dir=dir_path, return_absolute_path=False)
try:
os.mkdir(data_dir_path)
except OSError:
pass
data_file_path = data_dir_path
jar_dir_path = os.path.join(dir_path, "jar")
try:
os.mkdir(jar_dir_path)
except OSError:
pass
shutil.copyfile(os.path.join(jar_path, "king.jar"), os.path.join(jar_dir_path, "king.jar"))
filepath = opts.coord_fname
if os.path.isdir(filepath):
coord_files = [fname for fname in os.listdir(filepath) if not fname.startswith(".")]
filename = os.path.split(coord_files[0])[-1]
else:
filename = os.path.split(filepath)[-1]
try:
action = generate_3d_plots
except NameError:
action = None
# Place this outside try/except so we don't mask NameError in action
if action:
action(
prefs,
data,
custom_axes,
background_color,
label_color,
dir_path,
data_file_path,
filename,
ellipsoid_prefs=ellipsoid_prefs,
add_vectors=add_vectors,
plot_scaled=plot_scaled,
plot_unscaled=plot_unscaled,
)
开发者ID:qinjunjie,项目名称:qiime,代码行数:101,代码来源:make_3d_plots.py
示例19: main
def main():
print "\nWarning: compare_3d_plots.py is being deprecated in favor of make_emperor.py, and will no longer be available in QIIME 1.8.0-dev.\n"
option_parser, opts, args = parse_command_line_parameters(**script_info)
prefs, data, background_color, label_color, ball_scale, arrow_colors = sample_color_prefs_and_map_data_from_options(
opts
)
if len(opts.coord_fnames) < 2 and opts.edges_file is None:
option_parser.error("Please provide at least two " + "coordinate files or a custom edges file")
# Open and get coord data (for multiple coords files)
coord_files = opts.coord_fnames
coord_files_valid = validate_coord_files(coord_files)
if not coord_files_valid:
option_parser.error("Every line of every coord file must " + "have the same number of columns.")
num_coord_files = len(coord_files)
data["edges"], data["coord"] = get_multiple_coords(coord_files, opts.edges_file, opts.serial)
# if the edges file wasn't supplied, we appended _i to each file's samples
# therefore we now add duplicated samples with _0, _1,... to mapping file
if opts.edges_file is None:
newmap = [data["map"][0]]
for i in xrange(len(coord_files)):
for sample in data["map"][1:]:
newsample = ["%s_%d" % (sample[0], i)]
newsample.extend(sample[1:])
newmap.append(newsample)
data["map"] = newmap
# remove any samples not present in mapping file
remove_unmapped_samples(data["map"], data["coord"], data["edges"])
if len(data["coord"][1]) == 0:
raise ValueError, "\n\nError: None of the sample IDs in the coordinates files were present in the mapping file.\n"
# process custom axes, if present.
custom_axes = None
if opts.custom_axes:
custom_axes = process_custom_axes(opts.custom_axes)
get_custom_coords(custom_axes, data["map"], data["coord"])
remove_nans(data["coord"])
scale_custom_coords(custom_axes, data["coord"])
# Generate random output file name and create directories
if opts.output_dir:
create_dir(opts.output_dir)
dir_path = opts.output_dir
else:
dir_path = "./"
qiime_dir = get_qiime_project_dir()
jar_path = os.path.join(qiime_dir, "qiime/support_files/jar/")
data_dir_path = get_random_directory_name(output_dir=dir_path, return_absolute_path=False)
try:
os.mkdir(data_dir_path)
except OSError:
pass
jar_dir_path = os.path.join(dir_path, "jar")
try:
os.mkdir(jar_dir_path)
except OSError:
pass
shutil.copyfile(os.path.join(jar_path, "king.jar"), os.path.join(jar_dir_path, "king.jar"))
filepath = coord_files[0]
filename = filepath.strip().split("/")[-1]
try:
action = generate_3d_plots
except NameError:
action = None
# Place this outside try/except so we don't mask NameError in action
if action:
generate_3d_plots(
prefs,
data,
custom_axes,
background_color,
label_color,
dir_path,
data_dir_path,
filename,
ball_scale=ball_scale,
arrow_colors=arrow_colors,
user_supplied_edges=not (opts.edges_file is None),
)
开发者ID:Jorge-C,项目名称:qiime,代码行数:95,代码来源:compare_3d_plots.py
示例20: main
def main():
option_parser, opts, args = parse_command_line_parameters(**script_info)
data = {}
#Op
|
请发表评论