diff --git a/python/obitools3/apps/optiongroups/__init__.py b/python/obitools3/apps/optiongroups/__init__.py index 6bd6d50..c32c93b 100644 --- a/python/obitools3/apps/optiongroups/__init__.py +++ b/python/obitools3/apps/optiongroups/__init__.py @@ -7,7 +7,7 @@ def __addInputOption(optionManager): group = optionManager.add_argument_group("Restriction to a sub-part options", - "Allow to limit analysis to a sub-part of the data file") + "Allows to limit analysis to a sub-part of the input") group.add_argument('--skip', action="store", dest="obi:skip", @@ -22,61 +22,55 @@ def __addInputOption(optionManager): default=None, type=int, help="treat only N sequences") - - group.add_argument('--na-string', - action="store", dest="obi:nastring", - default="NA", - type=str, - help="String associated to Non Available (NA) values") -def __addSequenceInputOption(optionManager): - group = optionManager.add_argument_group("Input format options for sequence files") +def __addImportInputOption(optionManager): + group = optionManager.add_argument_group("Input format options for imported files") - group.add_argument('--fasta', - action="store_const", dest="obi:format", + group.add_argument('--fasta-input', + action="store_const", dest="obi:inputformat", default=None, const=b'fasta', help="Input file is in sanger fasta format") - group.add_argument('--fastq', - action="store_const", dest="obi:format", + group.add_argument('--fastq-input', + action="store_const", dest="obi:inputformat", default=None, const=b'fastq', help="Input file is in fastq format") - group.add_argument('--embl', - action="store_const", dest="obi:format", + group.add_argument('--embl-input', + action="store_const", dest="obi:inputformat", default=None, const=b'embl', help="Input file is in embl nucleic format") - group.add_argument('--genbank', - action="store_const", dest="obi:format", + group.add_argument('--genbank-input', + action="store_const", dest="obi:inputformat", default=None, const=b'genbank', help="Input file is in genbank nucleic format") - group.add_argument('--ngsfilter', - action="store_const", dest="obi:format", + group.add_argument('--ngsfilter-input', + action="store_const", dest="obi:inputformat", default=None, const=b'ngsfilter', help="Input file is an ngsfilter file") - group.add_argument('--ecopcr-result', - action="store_const", dest="obi:format", + group.add_argument('--ecopcr-result-input', + action="store_const", dest="obi:inputformat", default=None, const=b'ecopcr', help="Input file is the result of an ecoPCR (version 2)") - group.add_argument('--ecoprimers-result', - action="store_const", dest="obi:format", + group.add_argument('--ecoprimers-result-input', + action="store_const", dest="obi:inputformat", default=None, const=b'ecoprimers', help="Input file is the result of an ecoprimers") - group.add_argument('--tabular', - action="store_const", dest="obi:format", + group.add_argument('--tabular-input', + action="store_const", dest="obi:inputformat", default=None, const=b'tabular', help="Input file is a tabular file") @@ -114,6 +108,13 @@ def __addSequenceInputOption(optionManager): default=None, const=b'pep', help="Input file contains protein sequences") + + group.add_argument('--input-na-string', + action="store", dest="obi:inputnastring", + default="NA", + type=str, + help="String associated with Non Available (NA) values in the input") + def __addTabularInputOption(optionManager): group = optionManager.add_argument_group("Input format options for tabular files") @@ -151,7 +152,17 @@ def __addTabularInputOption(optionManager): type=str, help="Lines starting by this char are considered as comment") -def __addTaxonomyInputOption(optionManager): + +def __addTaxdumpInputOption(optionManager): # TODO maybe not the best way to do it + group = optionManager.add_argument_group("Input format options for taxdump") + + group.add_argument('--taxdump', + action="store_true", dest="obi:taxdump", + default=False, + help="Whether the input is a taxdump") + + +def __addTaxonomyOption(optionManager): group = optionManager.add_argument_group("Input format options for taxonomy") group.add_argument('--taxonomy', @@ -161,46 +172,46 @@ def __addTaxonomyInputOption(optionManager): #TODO option bool to download taxo if URI doesn't exist -def __addTaxdumpInputOption(optionManager): - group = optionManager.add_argument_group("Input format options for taxdump") - - group.add_argument('--taxdump', - action="store_true", dest="obi:taxdump", - default=False, - help="Whether the input is a taxdump") def addMinimalInputOption(optionManager): __addInputOption(optionManager) + -def addSequenceInputOption(optionManager): +def addImportInputOption(optionManager): __addInputOption(optionManager) - __addSequenceInputOption(optionManager) - + __addImportInputOption(optionManager) + + def addTabularInputOption(optionManager): - #__addInputOption(optionManager) # TODO discuss conflict __addTabularInputOption(optionManager) -def addTaxonomyInputOption(optionManager): - __addTaxonomyInputOption(optionManager) + +def addTaxonomyOption(optionManager): + __addTaxonomyOption(optionManager) + def addTaxdumpInputOption(optionManager): __addTaxdumpInputOption(optionManager) + def addAllInputOption(optionManager): __addInputOption(optionManager) - __addSequenceInputOption(optionManager) + __addImportInputOption(optionManager) __addTabularInputOption(optionManager) - __addTaxonomyInputOption(optionManager) + __addTaxonomyOption(optionManager) __addTaxdumpInputOption(optionManager) - + + def __addOutputOption(optionManager): optionManager.add_argument( dest='obi:outputURI', metavar='OUTPUT', help='Data destination URI') - - group = optionManager.add_argument_group("Management of DMS for output") + + +def __addDMSOutputOption(optionManager): + group = optionManager.add_argument_group("Output options for DMS data") group.add_argument('--no-create-dms', action="store_true", dest="obi:nocreatedms", @@ -218,5 +229,44 @@ def __addOutputOption(optionManager): "is greater than N, the values are stored as character strings") +def __addExportOutputOption(optionManager): + group = optionManager.add_argument_group("Output format options for exported files") + + group.add_argument('--fasta-output', + action="store_const", dest="obi:outputformat", + default=None, + const=b'fasta', + help="Output file is in sanger fasta format") + + group.add_argument('--fastq-output', + action="store_const", dest="obi:outputformat", + default=None, + const=b'fastq', + help="Output file is in fastq format") + + group.add_argument('--print-na', + action="store_true", dest="obi:printna", + default=False, + help="Print Non Available (NA) values in the output") + + group.add_argument('--output-na-string', + action="store", dest="obi:outputnastring", + default="NA", + type=str, + help="String associated with Non Available (NA) values in the output") + + def addMinimalOutputOption(optionManager): __addOutputOption(optionManager) + __addDMSOutputOption(optionManager) + +def addExportOutputOption(optionManager): + __addOutputOption(optionManager) + __addExportOutputOption(optionManager) + + +def addAllOutputOption(optionManager): + __addOutputOption(optionManager) + __addDMSOutputOption(optionManager) + __addExportOutputOption(optionManager) + diff --git a/python/obitools3/commands/alignpairedend.pyx b/python/obitools3/commands/alignpairedend.pyx index 8e09ea1..803827f 100644 --- a/python/obitools3/commands/alignpairedend.pyx +++ b/python/obitools3/commands/alignpairedend.pyx @@ -8,7 +8,7 @@ from obitools3.dms.view.typed_view.view_NUC_SEQS cimport View_NUC_SEQS from obitools3.dms.column.column cimport Column, Column_line from obitools3.dms.capi.obiview cimport QUALITY_COLUMN, COUNT_COLUMN, NUC_SEQUENCE_COLUMN, ID_COLUMN from obitools3.dms.capi.obitypes cimport OBI_INT, OBI_STR, index_t, OBI_QUAL -from obitools3.apps.optiongroups import addSequenceInputOption, addMinimalOutputOption +from obitools3.apps.optiongroups import addMinimalInputOption, addMinimalOutputOption from obitools3.uri.decode import open_uri from obitools3.apps.config import logger from obitools3.align._qsassemble import QSolexaReverseAssemble @@ -29,7 +29,7 @@ __title__="Aligns paired-ended reads" def addOptions(parser): - addSequenceInputOption(parser) + addMinimalInputOption(parser) addMinimalOutputOption(parser) group = parser.add_argument_group('obi alignpairedend specific options') diff --git a/python/obitools3/commands/annotate.pyx b/python/obitools3/commands/annotate.pyx index 3b4e5da..7e8b3c4 100644 --- a/python/obitools3/commands/annotate.pyx +++ b/python/obitools3/commands/annotate.pyx @@ -4,7 +4,7 @@ from obitools3.apps.progress cimport ProgressBar # @UnresolvedImport from obitools3.dms import DMS from obitools3.dms.view.view cimport View, Line_selection from obitools3.uri.decode import open_uri -from obitools3.apps.optiongroups import addMinimalInputOption, addTaxonomyInputOption, addMinimalOutputOption +from obitools3.apps.optiongroups import addMinimalInputOption, addTaxonomyOption, addMinimalOutputOption from obitools3.dms.view import RollbackException from functools import reduce from obitools3.apps.config import logger @@ -29,7 +29,7 @@ SPECIAL_COLUMNS = [NUC_SEQUENCE_COLUMN, ID_COLUMN, DEFINITION_COLUMN, QUALITY_CO def addOptions(parser): addMinimalInputOption(parser) - addTaxonomyInputOption(parser) + addTaxonomyOption(parser) addMinimalOutputOption(parser) group=parser.add_argument_group('obi annotate specific options') diff --git a/python/obitools3/commands/clean.pyx b/python/obitools3/commands/clean.pyx index 41df108..51103f7 100644 --- a/python/obitools3/commands/clean.pyx +++ b/python/obitools3/commands/clean.pyx @@ -5,7 +5,7 @@ from obitools3.dms.dms cimport DMS from obitools3.dms.capi.obidms cimport OBIDMS_p from obitools3.dms.view import RollbackException from obitools3.dms.capi.obiclean cimport obi_clean -from obitools3.apps.optiongroups import addSequenceInputOption, addMinimalOutputOption +from obitools3.apps.optiongroups import addMinimalInputOption, addMinimalOutputOption from obitools3.uri.decode import open_uri from obitools3.apps.config import logger from obitools3.utils cimport tobytes @@ -20,7 +20,7 @@ __title__="Tag a set of sequences for PCR and sequencing errors identification" def addOptions(parser): - addSequenceInputOption(parser) + addMinimalInputOption(parser) addMinimalOutputOption(parser) group = parser.add_argument_group('obi clean specific options') diff --git a/python/obitools3/commands/count.pyx b/python/obitools3/commands/count.pyx index f1996b9..44b6b30 100644 --- a/python/obitools3/commands/count.pyx +++ b/python/obitools3/commands/count.pyx @@ -4,7 +4,7 @@ from obitools3.uri.decode import open_uri from obitools3.apps.config import logger from obitools3.dms import DMS -from obitools3.apps.optiongroups import addSequenceInputOption +from obitools3.apps.optiongroups import addMinimalInputOption from obitools3.dms.capi.obiview cimport COUNT_COLUMN @@ -13,7 +13,7 @@ __title__="Counts sequence records" def addOptions(parser): - addSequenceInputOption(parser) + addMinimalInputOption(parser) group = parser.add_argument_group('obi count specific options') diff --git a/python/obitools3/commands/ecopcr.pyx b/python/obitools3/commands/ecopcr.pyx index cd05623..a170116 100644 --- a/python/obitools3/commands/ecopcr.pyx +++ b/python/obitools3/commands/ecopcr.pyx @@ -5,7 +5,7 @@ from obitools3.dms.dms cimport DMS from obitools3.dms.capi.obidms cimport OBIDMS_p from obitools3.dms.view import RollbackException from obitools3.dms.capi.obiecopcr cimport obi_ecopcr -from obitools3.apps.optiongroups import addSequenceInputOption, addMinimalOutputOption, addTaxonomyInputOption +from obitools3.apps.optiongroups import addMinimalInputOption, addMinimalOutputOption, addTaxonomyOption from obitools3.uri.decode import open_uri from obitools3.apps.config import logger from obitools3.utils cimport tobytes @@ -24,9 +24,9 @@ __title__="in silico PCR" # TODO: add option to output unique ids def addOptions(parser): - addSequenceInputOption(parser) + addMinimalInputOption(parser) + addTaxonomyOption(parser) addMinimalOutputOption(parser) - addTaxonomyInputOption(parser) group = parser.add_argument_group('obi ecopcr specific options') diff --git a/python/obitools3/commands/grep.pyx b/python/obitools3/commands/grep.pyx index 75115b4..f659821 100644 --- a/python/obitools3/commands/grep.pyx +++ b/python/obitools3/commands/grep.pyx @@ -4,7 +4,7 @@ from obitools3.apps.progress cimport ProgressBar # @UnresolvedImport from obitools3.dms import DMS from obitools3.dms.view.view cimport View, Line_selection from obitools3.uri.decode import open_uri -from obitools3.apps.optiongroups import addMinimalInputOption, addTaxonomyInputOption, addMinimalOutputOption +from obitools3.apps.optiongroups import addMinimalInputOption, addTaxonomyOption, addMinimalOutputOption from obitools3.dms.view import RollbackException from obitools3.apps.config import logger from obitools3.utils cimport tobytes @@ -24,7 +24,7 @@ __title__="Grep view lines that match the given predicates" def addOptions(parser): addMinimalInputOption(parser) - addTaxonomyInputOption(parser) + addTaxonomyOption(parser) addMinimalOutputOption(parser) group=parser.add_argument_group("obi grep specific options") diff --git a/python/obitools3/commands/import.pyx b/python/obitools3/commands/import.pyx index d9406c3..4c7d8b5 100644 --- a/python/obitools3/commands/import.pyx +++ b/python/obitools3/commands/import.pyx @@ -22,10 +22,10 @@ from obitools3.dms.capi.obitypes cimport obitype_t, \ from obitools3.dms.capi.obierrno cimport obi_errno -from obitools3.apps.optiongroups import addSequenceInputOption, \ +from obitools3.apps.optiongroups import addImportInputOption, \ addTabularInputOption, \ - addMinimalOutputOption, \ - addTaxdumpInputOption + addTaxdumpInputOption, \ + addMinimalOutputOption from obitools3.uri.decode import open_uri @@ -45,10 +45,10 @@ default_config = { 'destview' : None, def addOptions(parser): - addSequenceInputOption(parser) + addImportInputOption(parser) addTabularInputOption(parser) - addMinimalOutputOption(parser) addTaxdumpInputOption(parser) + addMinimalOutputOption(parser) def run(config): @@ -123,7 +123,7 @@ def run(config): entries = input[1] - NA_value = tobytes(config['obi']['nastring']) # TODO + NA_value = tobytes(config['obi']['inputnastring']) NUC_SEQS_view = False if isinstance(output[1], View) : diff --git a/python/obitools3/commands/less.pyx b/python/obitools3/commands/less.pyx index 08a04e7..18b3c51 100644 --- a/python/obitools3/commands/less.pyx +++ b/python/obitools3/commands/less.pyx @@ -1,6 +1,6 @@ #cython: language_level=3 -from obitools3.apps.optiongroups import addSequenceInputOption +from obitools3.apps.optiongroups import addMinimalInputOption from obitools3.uri.decode import open_uri from obitools3.dms import DMS @@ -10,7 +10,7 @@ __title__="Less equivalent" def addOptions(parser): - addSequenceInputOption(parser) + addMinimalInputOption(parser) group=parser.add_argument_group('obi less specific options') diff --git a/python/obitools3/commands/ngsfilter.pyx b/python/obitools3/commands/ngsfilter.pyx index bb94136..d46ef4a 100644 --- a/python/obitools3/commands/ngsfilter.pyx +++ b/python/obitools3/commands/ngsfilter.pyx @@ -5,7 +5,7 @@ from obitools3.dms import DMS from obitools3.dms.view import RollbackException from obitools3.dms.view.typed_view.view_NUC_SEQS cimport View_NUC_SEQS from obitools3.dms.column.column cimport Column, Column_line -from obitools3.apps.optiongroups import addSequenceInputOption, addMinimalOutputOption +from obitools3.apps.optiongroups import addMinimalInputOption, addMinimalOutputOption from obitools3.uri.decode import open_uri from obitools3.apps.config import logger from obitools3.align._freeendgapfm import FreeEndGapFullMatch @@ -26,7 +26,7 @@ __title__="Assigns sequence records to the corresponding experiment/sample based def addOptions(parser): - addSequenceInputOption(parser) + addMinimalInputOption(parser) addMinimalOutputOption(parser) group = parser.add_argument_group('obi ngsfilter specific options') @@ -38,13 +38,6 @@ def addOptions(parser): default=None, help="URI to the view containing the samples definition (with tags, primers, sample names,...)") -# group.add_argument('-F', '--forward-reads', -# action="store", dest="ngsfilter:forward", -# metavar="", -# default=None, -# type=str, -# help="URI to the forward reads if the paired-end reads haven't been aligned yet") - group.add_argument('-R', '--reverse-reads', action="store", dest="ngsfilter:reverse", metavar="", diff --git a/python/obitools3/commands/uniq.pyx b/python/obitools3/commands/uniq.pyx index 9073ea8..0da9cb3 100644 --- a/python/obitools3/commands/uniq.pyx +++ b/python/obitools3/commands/uniq.pyx @@ -9,7 +9,7 @@ from obitools3.dms.view.typed_view.view_NUC_SEQS cimport View_NUC_SEQS from obitools3.dms.column.column cimport Column, Column_line from obitools3.dms.capi.obiview cimport QUALITY_COLUMN, COUNT_COLUMN, NUC_SEQUENCE_COLUMN, ID_COLUMN from obitools3.dms.capi.obitypes cimport OBI_INT, OBI_STR, index_t -from obitools3.apps.optiongroups import addSequenceInputOption, addMinimalOutputOption, addTaxonomyInputOption +from obitools3.apps.optiongroups import addMinimalInputOption, addMinimalOutputOption, addTaxonomyOption from obitools3.uri.decode import open_uri from obitools3.apps.config import logger from obitools3.utils cimport tobytes @@ -23,9 +23,9 @@ __title__="Group sequence records together" def addOptions(parser): - addSequenceInputOption(parser) + addMinimalInputOption(parser) + addTaxonomyOption(parser) addMinimalOutputOption(parser) - addTaxonomyInputOption(parser) group = parser.add_argument_group('obi uniq specific options')