Commit 024d8a1f by Eric Coissac

add two new scripts :

	fastaHead and fastaTail
parent d2fdf6bf
#!/usr/local/bin/python
'''
Created on 15 dŽc. 2009
@author: coissac
'''
from obitools.fasta import fastaIterator,formatFasta
from obitools.options import getOptionManager
import sys
def addHeadOptions(optionManager):
optionManager.add_option('-n','--sequence-count',
action="store", dest="count",
metavar="###",
type="int",
default=10,
help="Count of first sequences to print")
if __name__ == '__main__':
optionParser = getOptionManager([addHeadOptions],
entryIterator=fastaIterator
)
(options, entries) = optionParser()
i=0
for s in entries:
if i < options.count:
print formatFasta(s)
i+=1
else:
sys.exit(0)
#!/usr/local/bin/python
'''
Created on 15 dŽc. 2009
@author: coissac
'''
from obitools.fasta import fastaIterator,formatFasta
from obitools.options import getOptionManager
import collections
def addHeadOptions(optionManager):
optionManager.add_option('-n','--sequence-count',
action="store", dest="count",
metavar="###",
type="int",
default=10,
help="Count of first sequences to print")
if __name__ == '__main__':
optionParser = getOptionManager([addHeadOptions],
entryIterator=fastaIterator
)
(options, entries) = optionParser()
i=0
queue = collections.deque()
for s in entries:
queue.append(s)
if len(queue) > options.count:
queue.popleft()
while queue:
print formatFasta(queue.popleft())
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment