def test_call(self): def func(a, b, c, d): return 42 obs = QiitaCommand("Test cmd", "Some description", func, self.exp_req, self.exp_opt, self.exp_out, self.exp_dflt) self.assertEqual(obs('a', 'b', 'c', 'd'), 42)
def test_call(self): def func(qclient, job_id, job_params, working_dir): fp = join(working_dir, 'test.fastq') with open(fp, 'w') as f: f.write('') res = ArtifactInfo('out1', 'Demultiplexed', [[fp, 'preprocessed_fastq']]) return True, "", [res] tester = QiitaPlugin("NewPlugin", "0.0.1", "description") cmd = QiitaCommand("NewCmd", "Desc", func, {'p1': ('artifact', ['FASTQ'])}, {'p2': ('string', 'dflt')}, {'out1': 'Demultiplexed'}) tester.register_command(cmd) a_cmd = QiitaCommand("NewCmdAnalysis", "Desc", func, {'p1': ('artifact', ['FASTQ'])}, {'p2': ('string', 'dflt')}, {'out1': 'Demultiplexed'}) tester.register_command(a_cmd) tester.generate_config('ls', 'echo', server_cert=self.server_cert) self.qclient.post('/apitest/reload_plugins/') tester("https://localhost:21174", 'register', 'ignored') obs = self.qclient.get('/qiita_db/plugins/NewPlugin/0.0.1/') self.assertEqual(obs['name'], 'NewPlugin') self.assertEqual(obs['version'], '0.0.1') # I can't use assertItemsEqual because it is not available in py3 # and I can't user assertCountEqual because it is not avaialable in py2 self.assertEqual(sorted(obs['commands']), sorted(['NewCmd', 'NewCmdAnalysis'])) # Create a new job data = {'command': dumps(['NewPlugin', '0.0.1', 'NewCmd']), 'parameters': dumps({'p1': '1', 'p2': 'a'}), 'status': 'queued'} job_id = self.qclient.post('/apitest/processing_job/', data=data)['job'] tester("https://localhost:21174", job_id, self.outdir) status = self._wait_for_running_job(job_id) self.assertEqual(status, 'success')
def test_init(self): # Create a test function def func(a, b, c, d): return 42 obs = QiitaCommand("Test cmd", "Some description", func, self.exp_req, self.exp_opt, self.exp_out, self.exp_dflt) self.assertEqual(obs.name, "Test cmd") self.assertEqual(obs.description, "Some description") self.assertEqual(obs.function, func) self.assertEqual(obs.required_parameters, self.exp_req) self.assertEqual(obs.optional_parameters, self.exp_opt) self.assertEqual(obs.outputs, self.exp_out) self.assertEqual(obs.default_parameter_sets, self.exp_dflt) self.assertFalse(obs.analysis_only) obs = QiitaCommand("Test cmd analysis", "Some description", func, self.exp_req, self.exp_opt, self.exp_out, self.exp_dflt, analysis_only=True) self.assertEqual(obs.name, "Test cmd analysis") self.assertEqual(obs.description, "Some description") self.assertEqual(obs.function, func) self.assertEqual(obs.required_parameters, self.exp_req) self.assertEqual(obs.optional_parameters, self.exp_opt) self.assertEqual(obs.outputs, self.exp_out) self.assertEqual(obs.default_parameter_sets, self.exp_dflt) self.assertTrue(obs.analysis_only) with self.assertRaises(TypeError): QiitaCommand("Name", "Desc", "func", self.exp_req, self.exp_opt, self.exp_out, self.exp_dflt) def func(a, b, c): return 42 with self.assertRaises(ValueError): QiitaCommand("Name", "Desc", func, self.exp_req, self.exp_opt, self.exp_out, self.exp_dflt)
# ----------------------------------------------------------------------------- # Copyright (c) 2014--, The Qiita Development Team. # # Distributed under the terms of the BSD 3-clause License. # # The full license is in the file LICENSE, distributed with this software. # ----------------------------------------------------------------------------- from qiita_client import QiitaCommand from .utils import (generate_filter_dflt_params, get_dbs_list) from .filter import filter from os.path import join from os import environ __all__ = ['filter'] # Define the filter command default_db = join(environ["QC_FILTER_DB_DP"], 'phix', 'phix') default_db_list = get_dbs_list(environ["QC_FILTER_DB_DP"]) req_params = {'input': ('artifact', ['per_sample_FASTQ'])} opt_params = { 'Bowtie2 database to filter': ["choice: [%s]" % default_db_list, default_db], 'Number of threads': ['integer', '4'] } outputs = {'Filtered files': 'per_sample_FASTQ'} dflt_param_set = generate_filter_dflt_params() filter_cmd = QiitaCommand('QC_Filter', "Sequence QC - Filtering", filter, req_params, opt_params, outputs, dflt_param_set)
name = "Metadata column to use" opt_params[name] = ('string', '') name = 'qp-hide-param' + name opt_params[name] = ('string', 'qp-hide-metadata-field') else: ename = '%s (%s)' % (element.description, pname) if element.has_default(): opt_params[ename] = (data_type, default) # we need to add the actual name of the parameter so we # can retrieve later opt_params['qp-hide-param' + ename] = ('string', pname) else: default = (default if default is not element.NOVALUE else 'None') opt_params[ename] = (data_type, default) # we need to add the actual name of the parameter so we # can retrieve later opt_params['qp-hide-param' + ename] = ('string', pname) qiime_cmd = QiitaCommand("%s [%s]" % (m.name, mid), m.description, call_qiime2, req_params, opt_params, outputs_params, {'Default': {}}, analysis_only=True) plugin.register_command(qiime_cmd) plugin.register_command(qiime_cmd)
# min length after trimming 'Minimum trimmed read length': ['integer', '80'], # drop pairs whose mates are filtered out 'Pair-end read required to match': ['choice:["any", "both"]', 'any'], # maximum Ns to drop sequence 'Maximum number of N bases in a read to keep it': ['integer', '80'], # trim Ns on end of read 'Trim Ns on ends of reads': ['boolean', 'True'], # Threads used 'Number of threads used': ['integer', '4'], # NextSeq-specific quality trimming 'NextSeq-specific quality trimming': ['boolean', 'False'], } outputs = {'Adapter trimmed files': 'per_sample_FASTQ'} dflt_param_set = { 'KAPA HyperPlus with iTru': { 'Fwd read adapter': 'GATCGGAAGAGCACACGTCTGAACTCCAGTCAC', 'Rev read adapter': 'GATCGGAAGAGCGTCGTGTAGGGAAAGGAGTGT', 'Trim low-quality bases': 15, 'Minimum trimmed read length': 80, 'Pair-end read required to match': 'any', 'Maximum number of N bases in a read to keep it': 80, 'Trim Ns on ends of reads': True, 'NextSeq-specific quality trimming': False, 'Number of threads used': 4 } } trim_cmd = QiitaCommand('Atropos v1.1.15', "Sequence QC - adapter trimming", trim, req_params, opt_params, outputs, dflt_param_set)
from os import environ # Initialize the plugin plugin = QiitaPlugin(**plugin_details) db_list = list(get_dbs(environ["QC_WOLTKA_DB_DP"]).values()) req_params = {'input': ('artifact', ['per_sample_FASTQ'])} opt_params = { # database 'Database': [ "choice: [%s]" % ','.join([f'"{db}"' for db in db_list]), # making the first option default and rm quotes db_list[0] ], } outputs = { 'Alignment Profile': 'BIOM', 'Taxonomic Predictions - phylum': 'BIOM', 'Taxonomic Predictions - genus': 'BIOM', 'Taxonomic Predictions - species': 'BIOM', 'Per genome Predictions': 'BIOM', 'Per gene Predictions': 'BIOM', } dflt_param_set = generate_woltka_dflt_params() woltka_cmd = QiitaCommand('Woltka v0.1.1', "Functional and Taxonomic Predictions", woltka, req_params, opt_params, outputs, dflt_param_set) plugin.register_command(woltka_cmd)
plugin = QiitaPlugin(**plugin_details) # Define the command dbs = get_dbs_list() dbs_without_extension = [splitext(db)[0] for db in dbs] dbs_defaults = ', '.join([f'"{x}"' for x in dbs_without_extension]) req_params = {'input': ('artifact', ['per_sample_FASTQ'])} opt_params = { 'reference': [f'choice:["None", {dbs_defaults}]', dbs_without_extension[0]], 'threads': ['integer', f'{THREADS}'] } outputs = {'Filtered files': 'per_sample_FASTQ'} default_params = { 'auto-detect adapters only filtering [not recommended]': { 'reference': "None", 'threads': THREADS } } for db in dbs_without_extension: name = f'auto-detect adapters and {db} + phix filtering' default_params[name] = {'reference': db, 'threads': THREADS} fastp_minimap2_cmd = QiitaCommand('Adapter and host filtering', "Sequence adapter and host filtering", fastp_minimap2, req_params, opt_params, outputs, default_params) plugin.register_command(fastp_minimap2_cmd)
0.01, 'Maximum number of insertion/deletion (indel)': 3, 'Sequence trim length (-1 for no trimming)': -1, # the default min-reads is 10, however to ensure that deblur # is actually per-sample, min-reads must be set to 0 otherwise # filtering is applied over the samples included in a single # run 'Minimum dataset-wide read threshold': 0, 'Minimum per-sample read threshold': 2, 'Threads per sample': 1, 'Jobs to start': 1, 'Reference phylogeny for SEPP': 'Greengenes_13.8' } } deblur_cmd = QiitaCommand("Deblur", "deblurring workflow", deblur, req_params, opt_params, outputs, dflt_param_set) plugin.register_command(deblur_cmd) _ROOT = os.path.abspath(os.path.dirname(__file__)) def get_data(path): return os.path.join(_ROOT, '..', 'support_files', path)
# Define the shogun command default_db = join(environ["QC_SHOGUN_DB_DP"], 'rep82') default_db_list = get_dbs_list(environ["QC_SHOGUN_DB_DP"]) req_params = {'input': ('artifact', ['per_sample_FASTQ'])} opt_params = { # database 'Database': ["choice: [%s]" % default_db_list, default_db], # aligner 'Aligner tool': ['choice:[' + '"utree", ' + '"burst", ' + '"bowtie2"]', 'bowtie2'], # threads 'Number of threads': ['integer', '5'], 'Capitalist': ['boolean', 'False'], 'Percent identity': ['float', '0.95'], } outputs = { 'Shogun Alignment Profile': 'BIOM', 'Taxonomic Predictions - phylum': 'BIOM', 'Taxonomic Predictions - genus': 'BIOM', 'Taxonomic Predictions - species': 'BIOM', } dflt_param_set = generate_shogun_dflt_params() shogun_cmd = QiitaCommand( 'Shogun v1.0.7', "Functional and Taxonomic Predictions", shogun, req_params, opt_params, outputs, dflt_param_set)
}, 'no merging + isolate': { 'type': 'isolate', 'merging': 'no merge', 'threads': THREADS, 'memory': MEMORY, 'k-mers': KMERS }, 'merge flash 65% + meta': { 'type': 'meta', 'merging': 'flash 65%', 'threads': THREADS, 'memory': MEMORY, 'k-mers': KMERS }, 'merge flash 65% + isolate': { 'type': 'isolate', 'merging': 'flash 65%', 'threads': THREADS, 'memory': MEMORY, 'k-mers': KMERS } } spades_cmd = QiitaCommand("spades", "Isolate and Metagenomic processing via spades", spades, req_params, opt_params, outputs, default_params) plugin.register_command(spades_cmd)
'max-memory': ['string', '500m'], # max memory in mb [ DEFAULT : 500m ] # leaving as empty string to simply. note that in tests is not empty. 'trimmomatic-options': ['string', ''], # Bowtie2 options # 'bowtie2-options': ['string', '--very-sensitive'] # BMTagger options # # TRF options # 'match': ['integer', '2'], # matching weight # 'mismatch': ['integer', '7'], # mismatching penalty # 'delta': ['integer', '7'], # indel penalty # 'pm': ['integer', '80'], # match probability # 'pi': ['integer', '10'], # indel probability # 'minscore': ['integer', '50'], # mimimum alignment score to report # 'maxperiod': ['integer', '500m'] # maximum period size to report # FastQC options } outputs = {'KneadData files': 'per_sample_FASTQ'} dflt_param_set = { 'Defaults': { 'reference-db': 'default', 'bypass-trim': False, 'threads': 1, 'processes': 1, 'quality-scores': 'phred33', 'run-bmtagger': False, 'run-trf': False, 'run-fastqc-start': True, 'run-fastqc-end': False, 'max-memory': '500m', 'trimmomatic-options': '' } } kneaddata_cmd = QiitaCommand( 'KneadData 0.5.1', "Sequence QC - Human sequence removal", kneaddata, req_params, opt_params, outputs, dflt_param_set)