Search code examples
biopythonfastq

FastqGeneralIterator Output


I'm using FastqGeneralIterator, but I find that it removes the @ from the 1st line of a fastq file and also the information for the 3rd line (it removes the entire 3rd line). I added the @ in the 1st line in the following way:

for line in open("prova_FiltraN_CE_filt.fastq"):
fout.write(line.replace('SEQ', '@SEQ'))

I want to add also the 3rd line, that starts with + and there is nothing after that. For example:

    @SEQILMN0
    TCATCGTA....
    +
    #<BBBFFF.....

Can someone help me?


Solution

  • you can use, String Formatting Operations %

    from Bio.SeqIO.QualityIO import FastqGeneralIterator
    with open("prova_FiltraN_CE_filt.fastq", "rU") as handle:
        for (title, sequence, quality) in FastqGeneralIterator(handle):
            print("@%s\n%s\n+\n%s" % (title, sequence, quality))
    

    you get fastq print format, using FastqGeneralIterator

    @SEQILMN0
    TCATCGTA....
    +
    #<BBBFFF....