From b34769b27c85fe3edf43ceb220cb35d308b6e7cf Mon Sep 17 00:00:00 2001 From: Celine Mercier Date: Fri, 19 Aug 2016 17:46:55 +0200 Subject: [PATCH] Minor improvements to obi export command --- python/obitools3/commands/export.pyx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/python/obitools3/commands/export.pyx b/python/obitools3/commands/export.pyx index ee65d40..50f1c9f 100644 --- a/python/obitools3/commands/export.pyx +++ b/python/obitools3/commands/export.pyx @@ -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