Cython API: updated the test command for the new API and deactivated the
other commands for now
This commit is contained in:
@ -1,130 +1,133 @@
|
||||
from obitools3.apps.progress cimport ProgressBar # @UnresolvedImport
|
||||
from obitools3.files.universalopener cimport uopen
|
||||
from obitools3.parsers.fasta import fastaIterator
|
||||
from obitools3.parsers.fastq import fastqIterator
|
||||
from obitools3.dms.dms import OBIDMS # TODO cimport doesn't work
|
||||
# from obitools3.apps.progress cimport ProgressBar # @UnresolvedImport
|
||||
# from obitools3.files.universalopener cimport uopen
|
||||
# from obitools3.parsers.fasta import fastaIterator
|
||||
# from obitools3.parsers.fastq import fastqIterator
|
||||
# from obitools3.dms.dms import OBIDMS # TODO cimport doesn't work
|
||||
#
|
||||
# import time
|
||||
#
|
||||
|
||||
import time
|
||||
|
||||
|
||||
__title__="Counts sequences in a sequence set"
|
||||
|
||||
|
||||
default_config = { 'destview' : None,
|
||||
'skip' : 0,
|
||||
'only' : None,
|
||||
'skiperror' : False,
|
||||
'seqinformat' : None,
|
||||
'moltype' : 'nuc',
|
||||
'filename' : None
|
||||
}
|
||||
|
||||
def addOptions(parser):
|
||||
parser.add_argument(dest='import:filename',
|
||||
metavar='<FILENAME>',
|
||||
nargs='?',
|
||||
default=None,
|
||||
help='sequence file name to be imported' )
|
||||
|
||||
group=parser.add_argument_group('obi import specific options')
|
||||
|
||||
group.add_argument('--default-dms','-d',
|
||||
action="store", dest="obi:defaultdms",
|
||||
metavar='<DMS NAME>',
|
||||
default=None,
|
||||
type=str,
|
||||
help="Name of the default DMS for reading and writing data")
|
||||
|
||||
group.add_argument('--destination-view','-v',
|
||||
action="store", dest="import:destview",
|
||||
metavar='<VIEW NAME>',
|
||||
default=None,
|
||||
type=str,
|
||||
required=True,
|
||||
help="Name of the default DMS for reading and writing data")
|
||||
|
||||
group.add_argument('--skip',
|
||||
action="store", dest="import:skip",
|
||||
metavar='<N>',
|
||||
default=None,
|
||||
type=int,
|
||||
help="skip the N first sequences")
|
||||
|
||||
group.add_argument('--only',
|
||||
action="store", dest="import:only",
|
||||
metavar='<N>',
|
||||
default=None,
|
||||
type=int,
|
||||
help="treat only N sequences")
|
||||
|
||||
group.add_argument('--skip-on-error',
|
||||
action="store_true", dest="import:skiperror",
|
||||
default=None,
|
||||
help="Skip sequence entries with parse error")
|
||||
|
||||
group.add_argument('--fasta',
|
||||
action="store_const", dest="import:seqinformat",
|
||||
default=None,
|
||||
const='fasta',
|
||||
help="Input file is in fasta nucleic format (including obitools fasta extentions)")
|
||||
|
||||
group.add_argument('--fastq',
|
||||
action="store_const", dest="import:seqinformat",
|
||||
default=None,
|
||||
const='fastq',
|
||||
help="Input file is in sanger fastq nucleic format (standard fastq)")
|
||||
|
||||
group.add_argument('--nuc',
|
||||
action="store_const", dest="import:moltype",
|
||||
default=None,
|
||||
const='nuc',
|
||||
help="Input file contains nucleic sequences")
|
||||
|
||||
group.add_argument('--prot',
|
||||
action="store_const", dest="import:moltype",
|
||||
default=None,
|
||||
const='pep',
|
||||
help="Input file contains protein sequences")
|
||||
|
||||
|
||||
|
||||
# TODO: Handling of NA values
|
||||
def run(config):
|
||||
pb = ProgressBar(35000000, config, seconde=5) # TODO should be number of records in file
|
||||
|
||||
inputs = uopen(config['import']['filename'])
|
||||
|
||||
get_quality = False
|
||||
if config['import']['seqinformat']=='fasta':
|
||||
iseq = fastaIterator(inputs)
|
||||
view_type="NUC_SEQS_VIEW"
|
||||
elif config['import']['seqinformat']=='fastq':
|
||||
iseq = fastqIterator(inputs)
|
||||
view_type="NUC_SEQS_VIEW"
|
||||
get_quality = True
|
||||
else:
|
||||
raise RuntimeError('No file format specified')
|
||||
|
||||
# Create DMS
|
||||
d = OBIDMS(config['obi']['defaultdms'])
|
||||
|
||||
# Create view
|
||||
# view = d.new_view(config['import']['destview'], view_type=view_type, quality_column=get_quality)
|
||||
pass
|
||||
|
||||
# __title__="Counts sequences in a sequence set"
|
||||
#
|
||||
#
|
||||
# default_config = { 'destview' : None,
|
||||
# 'skip' : 0,
|
||||
# 'only' : None,
|
||||
# 'skiperror' : False,
|
||||
# 'seqinformat' : None,
|
||||
# 'moltype' : 'nuc',
|
||||
# 'filename' : None
|
||||
# }
|
||||
#
|
||||
# def addOptions(parser):
|
||||
# parser.add_argument(dest='import:filename',
|
||||
# metavar='<FILENAME>',
|
||||
# nargs='?',
|
||||
# default=None,
|
||||
# help='sequence file name to be imported' )
|
||||
#
|
||||
# group=parser.add_argument_group('obi import specific options')
|
||||
#
|
||||
# group.add_argument('--default-dms','-d',
|
||||
# action="store", dest="obi:defaultdms",
|
||||
# metavar='<DMS NAME>',
|
||||
# default=None,
|
||||
# type=str,
|
||||
# help="Name of the default DMS for reading and writing data")
|
||||
#
|
||||
# i = 0
|
||||
# for seq in iseq:
|
||||
# pb(i)
|
||||
# view[i].id = seq['id']
|
||||
# view[i].definition = seq['definition']
|
||||
# view[i].nuc_seq = seq['sequence']
|
||||
# if get_quality :
|
||||
# view[i].quality = seq['quality']
|
||||
# for tag in seq['tags'] :
|
||||
# view[i][tag] = seq['tags'][tag]
|
||||
# i+=1
|
||||
# group.add_argument('--destination-view','-v',
|
||||
# action="store", dest="import:destview",
|
||||
# metavar='<VIEW NAME>',
|
||||
# default=None,
|
||||
# type=str,
|
||||
# required=True,
|
||||
# help="Name of the default DMS for reading and writing data")
|
||||
#
|
||||
# group.add_argument('--skip',
|
||||
# action="store", dest="import:skip",
|
||||
# metavar='<N>',
|
||||
# default=None,
|
||||
# type=int,
|
||||
# help="skip the N first sequences")
|
||||
#
|
||||
# #print(view.__repr__())
|
||||
# group.add_argument('--only',
|
||||
# action="store", dest="import:only",
|
||||
# metavar='<N>',
|
||||
# default=None,
|
||||
# type=int,
|
||||
# help="treat only N sequences")
|
||||
#
|
||||
# view.close()
|
||||
d.close()
|
||||
|
||||
# group.add_argument('--skip-on-error',
|
||||
# action="store_true", dest="import:skiperror",
|
||||
# default=None,
|
||||
# help="Skip sequence entries with parse error")
|
||||
#
|
||||
# group.add_argument('--fasta',
|
||||
# action="store_const", dest="import:seqinformat",
|
||||
# default=None,
|
||||
# const='fasta',
|
||||
# help="Input file is in fasta nucleic format (including obitools fasta extentions)")
|
||||
#
|
||||
# group.add_argument('--fastq',
|
||||
# action="store_const", dest="import:seqinformat",
|
||||
# default=None,
|
||||
# const='fastq',
|
||||
# help="Input file is in sanger fastq nucleic format (standard fastq)")
|
||||
#
|
||||
# group.add_argument('--nuc',
|
||||
# action="store_const", dest="import:moltype",
|
||||
# default=None,
|
||||
# const='nuc',
|
||||
# help="Input file contains nucleic sequences")
|
||||
#
|
||||
# group.add_argument('--prot',
|
||||
# action="store_const", dest="import:moltype",
|
||||
# default=None,
|
||||
# const='pep',
|
||||
# help="Input file contains protein sequences")
|
||||
#
|
||||
#
|
||||
#
|
||||
# # TODO: Handling of NA values
|
||||
# def run(config):
|
||||
# pb = ProgressBar(35000000, config, seconde=5) # TODO should be number of records in file
|
||||
#
|
||||
# inputs = uopen(config['import']['filename'])
|
||||
#
|
||||
# get_quality = False
|
||||
# if config['import']['seqinformat']=='fasta':
|
||||
# iseq = fastaIterator(inputs)
|
||||
# view_type="NUC_SEQS_VIEW"
|
||||
# elif config['import']['seqinformat']=='fastq':
|
||||
# iseq = fastqIterator(inputs)
|
||||
# view_type="NUC_SEQS_VIEW"
|
||||
# get_quality = True
|
||||
# else:
|
||||
# raise RuntimeError('No file format specified')
|
||||
#
|
||||
# # Create DMS
|
||||
# d = OBIDMS(config['obi']['defaultdms'])
|
||||
#
|
||||
# # Create view
|
||||
# # view = d.new_view(config['import']['destview'], view_type=view_type, quality_column=get_quality)
|
||||
# #
|
||||
# # i = 0
|
||||
# # for seq in iseq:
|
||||
# # pb(i)
|
||||
# # view[i].id = seq['id']
|
||||
# # view[i].definition = seq['definition']
|
||||
# # view[i].nuc_seq = seq['sequence']
|
||||
# # if get_quality :
|
||||
# # view[i].quality = seq['quality']
|
||||
# # for tag in seq['tags'] :
|
||||
# # view[i][tag] = seq['tags'][tag]
|
||||
# # i+=1
|
||||
# #
|
||||
# # #print(view.__repr__())
|
||||
# #
|
||||
# # view.close()
|
||||
# d.close()
|
||||
#
|
||||
|
Reference in New Issue
Block a user