def read_sequences(seqfilename, qualityfilename, colorspace, fileformat): """ Read sequences and (if available) quality information from either: * seqfilename in FASTA format (qualityfilename must be None) * seqfilename in FASTQ format (qualityfilename must be None) * seqfilename in .csfasta format and qualityfilename in .qual format (SOLiD color space) Return a generator over tuples (description, sequence, qualities). qualities is None if no qualities are available. qualities are ASCII-encoded (chr(quality) + 33). """ #if ftype == 'FASTQ' and qualityfilename is not None: #raise ValueError("If a FASTQ file is given, no quality file can be provided.") if qualityfilename is not None: if colorspace: # read from .(CS)FASTA/.QUAL return seqio.ColorspaceFastaQualReader(seqfilename, qualityfilename) else: return seqio.FastaQualReader(seqfilename, qualityfilename) else: # read from FASTA or FASTQ return seqio.SequenceReader(seqfilename, colorspace, fileformat)
def test_invalid_quality_value(): fasta = StringIO(">name\nACG") qual = StringIO(">name\n3 xx 7") list(seqio.FastaQualReader(fasta, qual))
def test_mismatching_read_names(): fasta = StringIO(">name\nACG") qual = StringIO(">nome\n3 5 7") list(seqio.FastaQualReader(fasta, qual))