<commit_before>from Bio.Seq import translate
from Bio.Data.IUPACData import (
    ambiguous_dna_complement, ambiguous_rna_complement)


def _makeComplementTable(complementData):
    """
    Make a sequence complement table.

    @param complementData: A C{dict} whose keys and values are strings of
        length one. A key, value pair indicates a substitution that should
        be performed during complementation.
    @return: A 256 character string that can be used as a translation table
        by the C{translate} method of a Python string.
    """
    table = range(256)
    for _from, to in complementData.iteritems():
        table[ord(_from[0])] = ord(to[0])
    return ''.join(map(chr, table))


_TRANSLATION_TABLE = {
    'dna': _makeComplementTable(ambiguous_dna_complement),
    'rna': _makeComplementTable(ambiguous_rna_complement),
}


class Read(object):
    """
    Hold information about a single read.

    @param id: A C{str} describing the read.
    @param sequence: A C{str} of sequence information (might be
        nucleotides or proteins).
    @param quality: An optional C{str} of phred quality scores. If not C{None},
        it must be the same length as C{sequence}.
    @param type: A C{str}, either 'dna', 'rna', or 'aa' to indicate the type
        of the sequence, either DNA, RNA, or amino acids.
    @raise ValueError: if the length of the quality string (if any) does not
        match the length of the sequence, or if the passed type is invalid.
    """
    def __init__(self, id, sequence, quality=None, type='dna'):
        if quality is not None and len(quality) != len(sequence):
            raise ValueError(
                'Invalid read: sequence length (%d) != quality length (%d)' %
                (len(sequence), len(quality)))
        if type not in ('aa', 'dna', 'rna'):
            raise ValueError('Unknown sequence type %r' % type)

        self.id = id
        self.sequence = sequence.upper()
        self.quality = quality
        self.type = type

    def __eq__(self, other):
        return (self.id == other.id and
                self.sequence == other.sequence and
                self.quality == other.quality and
                self.type == other.type)

    def __ne__(self, other):
        return not self == other

    def __len__(self):
        return len(self.sequence)<commit_msg>added properties to be a type in Reads<commit_after>from Bio.Seq import translate
from Bio.Data.IUPACData import (
    ambiguous_dna_complement, ambiguous_rna_complement)


def _makeComplementTable(complementData):
    """
    Make a sequence complement table.

    @param complementData: A C{dict} whose keys and values are strings of
        length one. A key, value pair indicates a substitution that should
        be performed during complementation.
    @return: A 256 character string that can be used as a translation table
        by the C{translate} method of a Python string.
    """
    table = range(256)
    for _from, to in complementData.iteritems():
        table[ord(_from[0])] = ord(to[0])
    return ''.join(map(chr, table))


_TRANSLATION_TABLE = {
    'dna': _makeComplementTable(ambiguous_dna_complement),
    'rna': _makeComplementTable(ambiguous_rna_complement),
}


class Read(object):
    """
    Hold information about a single read.

    @param id: A C{str} describing the read.
    @param sequence: A C{str} of sequence information (might be
        nucleotides or proteins).
    @param quality: An optional C{str} of phred quality scores. If not C{None},
        it must be the same length as C{sequence}.
    @param type: A C{str}, either 'dna', 'rna', or 'aa' to indicate the type
        of the sequence, either DNA, RNA, or amino acids.
    @raise ValueError: if the length of the quality string (if any) does not
        match the length of the sequence, or if the passed type is invalid.
    """
    def __init__(self, id, sequence, quality=None, type='dna'):
        if quality is not None and len(quality) != len(sequence):
            raise ValueError(
                'Invalid read: sequence length (%d) != quality length (%d)' %
                (len(sequence), len(quality)))
        if type not in ('aa', 'dna', 'rna', 'properties'):
            raise ValueError('Unknown sequence type %r' % type)

        self.id = id
        self.sequence = sequence.upper()
        self.quality = quality
        self.type = type

    def __eq__(self, other):
        return (self.id == other.id and
                self.sequence == other.sequence and
                self.quality == other.quality and
                self.type == other.type)

    def __ne__(self, other):
        return not self == other

    def __len__(self):
        return len(self.sequence)
{'fraction_non_alphanumeric': 0.09753528544343797, 'fraction_numerical': 0.0033705498209395408, 'mean_word_length': 2.6607555898226676, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4173701', 'n_tokens_mistral': 1364, 'n_tokens_neox': 1312, 'n_words': 503}