Minor improvements to obi export command

This commit is contained in:
Celine Mercier
2016-08-19 17:46:55 +02:00
parent 2d0a714e37
commit b34769b27c

View File

@ -5,7 +5,7 @@ from obitools3.utils cimport bytes2str
import time
import re
__title__="Export a NUC_SEQS view to a fasta file"
__title__="Export a NUC_SEQS view to a fasta or fastq file"
default_config = { 'inputview' : None,
@ -60,21 +60,25 @@ def run(config):
i=0
for seq in iview :
#pb(i)
toprint = ">"+seq.get_id()+" "
for col_name in seq :
if col_name != NUC_SEQUENCE_COLUMN and col_name != ID_COLUMN and col_name != DEFINITION_COLUMN and col_name != QUALITY_COLUMN :
toprint = toprint + col_name + "=" + str(seq[col_name]) + "; "
if DEFINITION_COLUMN in seq :
toprint = toprint + seq.get_definition()
nucseq = bytes2str(seq.get_sequence())
if config['export']['format'] == "fasta" :
nucseq = re.sub("(.{60})", "\\1\n", nucseq, 0, re.DOTALL)
toprint = toprint + "\n" + nucseq
elif config['export']['format'] == "fastq" :
toprint = toprint + "\n" + nucseq
toprint = toprint + "\n" + "+"
toprint = toprint + "\n" + seq.get_str_quality()
toprint = toprint + "\n" + nucseq
if config['export']['format'] == "fastq" :
toprint = toprint + "\n" + "+" + "\n" + seq.get_str_quality()
print(toprint)
i+=1