[Biopython] Writing fasta+qual files and adjusting adapter clip positions in sff files
Martin Mokrejs
mmokrejs at fold.natur.cuni.cz
Tue Apr 5 09:21:10 EDT 2011
Hi Peter,
I was looking into the Tutorial for a way to write fasta+qual files
but couldn't find it. I wanted to trim my objects assembled through
SeqIO.QualityIO.PairedFastaQualIterator. Could
_record[_start:_stop]
be used?
Anyways, I found that there is a way to convert sff files into re-trimmed
sff files which is even closer to my goal. Here is the help text from SffIO:
>>> from Bio import SeqIO
>>> def filter_and_trim(records, primer):
... for record in records:
... if record.seq[record.annotations["clip_qual_left"]:].startswith(primer):
... record.annotations["clip_qual_left"] += len(primer)
... yield record
>>> records = SeqIO.parse("Roche/E3MFGYR02_random_10_reads.sff", "sff")
>>> count = SeqIO.write(filter_and_trim(records,"AAAGA"),
... "temp_filtered.sff", "sff")
>>> print "Selected %i records" % count
Selected 2 records
And this code from the Tutorial:
>>> from Bio import SeqIO
>>> SeqIO.convert("E3MFGYR02_random_10_reads.sff", "sff-trim", "trimmed.fasta", "fasta")
10
>>> SeqIO.convert("E3MFGYR02_random_10_reads.sff", "sff-trim", "trimmed.qual", "qual")
10
>>> SeqIO.convert("E3MFGYR02_random_10_reads.sff", "sff-trim", "trimmed.fastq", "fastq")
10
My questions is: could I provide readnames with clip_adapter_right directly to
SeqIO.convert()? Well I will probably stick to 'sfffile -t trimpositions.txt myfile.sff'
anyways hoping it will be faster. ;)
Martin
More information about the Biopython
mailing list