67 lines
1.7 KiB
Cython
67 lines
1.7 KiB
Cython
#cython: language_level=3
|
|
|
|
from obitools3.dms.dms cimport DMS # TODO cimport doesn't work
|
|
from obitools3.dms.view.view cimport View # TODO cimport doesn't work
|
|
|
|
|
|
# TODO with URIs
|
|
|
|
__title__="Less equivalent"
|
|
|
|
default_config = { 'inputview' : None,
|
|
}
|
|
|
|
def addOptions(parser):
|
|
|
|
# TODO put this common group somewhere else but I don't know where
|
|
group=parser.add_argument_group('DMS and view 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('--view','-v',
|
|
action="store", dest="obi:view",
|
|
metavar='<VIEW NAME>',
|
|
default=None,
|
|
type=str,
|
|
help="Name of the view to print.")
|
|
|
|
|
|
group=parser.add_argument_group('obi less specific options')
|
|
|
|
group.add_argument('--print', '-n',
|
|
action="store", dest="less:print",
|
|
metavar='<N>',
|
|
default=10,
|
|
type=int,
|
|
help="Print N sequences (default: 10)")
|
|
|
|
|
|
def run(config):
|
|
|
|
cdef DMS d
|
|
cdef View view
|
|
cdef int n
|
|
|
|
# Open DMS
|
|
d = DMS.open(config['obi']['defaultdms'])
|
|
|
|
# Open input view
|
|
view = View.open(d, config['obi']['view'])
|
|
|
|
if config['less']['print'] > len(view) :
|
|
n = len(view)
|
|
else :
|
|
n = config['less']['print']
|
|
|
|
# Print
|
|
for i in range(n) :
|
|
print(repr(view[i]))
|
|
|
|
d.close()
|
|
|