[Biopython] When is a SeqRecord a SeqRecord

Dilara Ally dilara.ally at gmail.com
Tue Jul 17 22:24:07 UTC 2012


Hi

I've modified my code but why does the inclusion of return None and the
subsequent code if filtered_rec is not None solve the problem? Thanks!

Dilara

q_threshold=20

def check_meanQ(rec, q_threshold):
    seqlen=len(rec)
    quality_scores=array(rec.letter_annotations["phred_quality"])
    if round(quality_scores.mean()) <= q_threshold:
        print "Discarded ", rec.id, "because mean Q was",
round(quality_scores.mean())
        return None
    if round(quality_scores.mean()) > q_threshold:
        return rec


from Bio import SeqIO
for rec in SeqIO.parse("test.fastq", "fastq"):
    #print rec.id
    filtered_rec= check_meanQ(rec, q_threshold)
    if filtered_rec is not None:
        print filtered_rec.id
        print filtered_rec.letter_annotations



More information about the Biopython mailing list