Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(5)  |  Call(4)  |  Derive(0)  |  Import(1)
Returns a Sanger FASTQ encoded quality string (PRIVATE).

>>> from Bio.Seq import Seq
>>> from Bio.SeqRecord import SeqRecord
>>> r = SeqRecord(Seq("ACGTAN"), id="Test",
...               letter_annotations = {"phred_quality":[50, 40, 30, 20, 10, 0]})
>>> _get_sanger_quality_str(r)
'SI?5+!'

If as in the above example (or indeed a SeqRecord parser with Bio.SeqIO),(more...)

        def _get_sanger_quality_str(record):
    """Returns a Sanger FASTQ encoded quality string (PRIVATE).

    >>> from Bio.Seq import Seq
    >>> from Bio.SeqRecord import SeqRecord
    >>> r = SeqRecord(Seq("ACGTAN"), id="Test",
    ...               letter_annotations = {"phred_quality":[50, 40, 30, 20, 10, 0]})
    >>> _get_sanger_quality_str(r)
    'SI?5+!'

    If as in the above example (or indeed a SeqRecord parser with Bio.SeqIO),
    the PHRED qualities are integers, this function is able to use a very fast
    pre-cached mapping. However, if they are floats which differ slightly, then
    it has to do the appropriate rounding - which is slower:

    >>> r2 = SeqRecord(Seq("ACGTAN"), id="Test2",
    ...      letter_annotations = {"phred_quality":[50.0, 40.05, 29.99, 20, 9.55, 0.01]})
    >>> _get_sanger_quality_str(r2)
    'SI?5+!'

    If your scores include a None value, this raises an exception:

    >>> r3 = SeqRecord(Seq("ACGTAN"), id="Test3",
    ...               letter_annotations = {"phred_quality":[50, 40, 30, 20, 10, None]})
    >>> _get_sanger_quality_str(r3)
    Traceback (most recent call last):
       ...
    TypeError: A quality value of None was found

    If (strangely) your record has both PHRED and Solexa scores, then the PHRED
    scores are used in preference:

    >>> r4 = SeqRecord(Seq("ACGTAN"), id="Test4",
    ...               letter_annotations = {"phred_quality":[50, 40, 30, 20, 10, 0],
    ...                                     "solexa_quality":[-5, -4, 0, None, 0, 40]})
    >>> _get_sanger_quality_str(r4)
    'SI?5+!'

    If there are no PHRED scores, but there are Solexa scores, these are used
    instead (after the approriate conversion):

    >>> r5 = SeqRecord(Seq("ACGTAN"), id="Test5",
    ...      letter_annotations = {"solexa_quality":[40, 30, 20, 10, 0, -5]})
    >>> _get_sanger_quality_str(r5)
    'I?5+$"'

    Again, integer Solexa scores can be looked up in a pre-cached mapping making
    this very fast. You can still use approximate floating point scores:

    >>> r6 = SeqRecord(Seq("ACGTAN"), id="Test6",
    ...      letter_annotations = {"solexa_quality":[40.1, 29.7, 20.01, 10, 0.0, -4.9]})
    >>> _get_sanger_quality_str(r6)
    'I?5+$"'

    Notice that due to the limited range of printable ASCII characters, a
    PHRED quality of 93 is the maximum that can be held in an Illumina FASTQ
    file (using ASCII 126, the tilde). This function will issue a warning
    in this situation.
    """
    #TODO - This functions works and is fast, but it is also ugly
    #and there is considerable repetition of code for the other
    #two FASTQ variants.
    try:
        #These take priority (in case both Solexa and PHRED scores found)
        qualities = record.letter_annotations["phred_quality"]
    except KeyError:
        #Fall back on solexa scores...
        pass
    else:
        #Try and use the precomputed mapping:
        try:
            return "".join(_phred_to_sanger_quality_str[qp]
                           for qp in qualities)
        except KeyError:
            #Could be a float, or a None in the list, or a high value.
            pass
        if None in qualities:
            raise TypeError("A quality value of None was found")
        if max(qualities) >= 93.5:
            warnings.warn("Data loss - max PHRED quality 93 in Sanger FASTQ",
                          BiopythonWarning)
        #This will apply the truncation at 93, giving max ASCII 126
        return "".join(chr(min(126, int(round(qp)) + SANGER_SCORE_OFFSET))
                       for qp in qualities)
    #Fall back on the Solexa scores...
    try:
        qualities = record.letter_annotations["solexa_quality"]
    except KeyError:
        raise ValueError("No suitable quality scores found in "
                         "letter_annotations of SeqRecord (id=%s)."
                         % record.id)
    #Try and use the precomputed mapping:
    try:
        return "".join(_solexa_to_sanger_quality_str[qs]
                       for qs in qualities)
    except KeyError:
        #Either no PHRED scores, or something odd like a float or None
        pass
    if None in qualities:
        raise TypeError("A quality value of None was found")
    #Must do this the slow way, first converting the PHRED scores into
    #Solexa scores:
    if max(qualities) >= 93.5:
        warnings.warn("Data loss - max PHRED quality 93 in Sanger FASTQ",
                      BiopythonWarning)
    #This will apply the truncation at 93, giving max ASCII 126
    return "".join(chr(min(126, int(round(phred_quality_from_solexa(qs))) + SANGER_SCORE_OFFSET))
                   for qs in qualities)
        


src/p/i/picobio-HEAD/blooming_reads/re_pair_circular_sam.py   picobio(Download)
 
from Bio import SeqIO
from Bio.SeqIO.QualityIO import _get_sanger_quality_str as qual_str
 
def sys_exit(msg, error_level=1):
            flag = 0x1 + 0x4 + 0x40 #Paired, this is unmapped, first in pair
            rec = raw_dict[qname + "/1"]
            rest = "255\t*\t%s\t%s\t0\t%s\t%s\n" % (rname, pos, rec.seq, qual_str(rec))
            reads1 = [(qname, flag, "*", "0", rest)]
        elif not reads2:
            flag = 0x1 + 0x4 + 0x80 #Paired, this is unmapped, second in pair
            rec = raw_dict[qname + "/2"]
            rest = "255\t*\t%s\t%s\t0\t%s\t%s\n" % (rname, pos, rec.seq, qual_str(rec))
            reads2 = [(qname, flag, "*", "0", rest)]
        else:

src/c/a/capsid-1.4.3/capsid/qfilter.py   capsid(Download)
            description = record.single.description,
            seq = record.single.seq,
            quality = SeqIO.QualityIO._get_sanger_quality_str(record.single))
            )
 
    if fq_pair:
        fq_pair.write('@{description}\t{seq}\t+{description}\t{quality}\n'.format(
                description = record.pair.description,
                seq = record.pair.seq,
                quality = SeqIO.QualityIO._get_sanger_quality_str(record.pair))