Basic obi less command
This commit is contained in:
57
python/obitools3/commands/less.pyx
Normal file
57
python/obitools3/commands/less.pyx
Normal file
@ -0,0 +1,57 @@
|
||||
#cython: language_level=3
|
||||
|
||||
from obitools3.dms.dms import DMS # TODO cimport doesn't work
|
||||
from obitools3.dms.view.view import 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):
|
||||
|
||||
# Open DMS
|
||||
d = DMS.open(config['obi']['defaultdms'])
|
||||
|
||||
# Open input view
|
||||
iview = View.open(d, config['obi']['inputview'])
|
||||
|
||||
# Print
|
||||
for i in range(config['less']['print']) :
|
||||
print(repr(iview[i]))
|
||||
|
||||
d.close()
|
||||
|
Reference in New Issue
Block a user