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 time
import re 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, default_config = { 'inputview' : None,
@ -60,21 +60,25 @@ def run(config):
i=0 i=0
for seq in iview : for seq in iview :
#pb(i) #pb(i)
toprint = ">"+seq.get_id()+" " toprint = ">"+seq.get_id()+" "
for col_name in seq : 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 : 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]) + "; " toprint = toprint + col_name + "=" + str(seq[col_name]) + "; "
if DEFINITION_COLUMN in seq : if DEFINITION_COLUMN in seq :
toprint = toprint + seq.get_definition() toprint = toprint + seq.get_definition()
nucseq = bytes2str(seq.get_sequence()) nucseq = bytes2str(seq.get_sequence())
if config['export']['format'] == "fasta" : if config['export']['format'] == "fasta" :
nucseq = re.sub("(.{60})", "\\1\n", nucseq, 0, re.DOTALL) 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" + nucseq
toprint = toprint + "\n" + "+" if config['export']['format'] == "fastq" :
toprint = toprint + "\n" + seq.get_str_quality() toprint = toprint + "\n" + "+" + "\n" + seq.get_str_quality()
print(toprint) print(toprint)
i+=1 i+=1