Exemplo n.º 1
0
 def test_letter_code_not_str(self):
     with pytest.raises(TypeError):
         LetterCode(1)
     with pytest.raises(TypeError):
         LetterCode([])
     with pytest.raises(TypeError):
         LetterCode(LetterCode('A'))
Exemplo n.º 2
0
    def test_letter_type_incorrect(self):
        with pytest.raises(TypeError):
            LetterCode('A', 1)

        with pytest.raises(TypeError):
            LetterCode('A', [])

        with pytest.raises(TypeError):
            LetterCode('A', '')

        with pytest.raises(TypeError):
            LetterCode('A', 'aminoacidnucleotide')
Exemplo n.º 3
0
 def test_letter_code_lower_case(self):
     letter_code = LetterCode('a', 'nucleotide')
     assert letter_code.letter_code == 'A'
     assert letter_code.letter_type == 'nucleotide'
     assert letter_code.description == 'adenosine'
     assert letter_code.degenerate is False
     assert letter_code.supported is True
     assert letter_code.in_fasta_spec is True
Exemplo n.º 4
0
 def test_lettercode_good(self, nucleotide_good):
     new = LetterCode.from_lettercode(nucleotide_good)
     assert new is not nucleotide_good
     assert new.letter_code == nucleotide_good.letter_code
     assert new.letter_type == nucleotide_good.letter_type
     assert new.description == nucleotide_good.description
     assert new.degenerate == nucleotide_good.degenerate
     assert new.supported == nucleotide_good.supported
     assert new.in_fasta_spec == nucleotide_good.in_fasta_spec
Exemplo n.º 5
0
 def test_letter_type_none(self, letter_type_none):
     with pytest.warns(UserWarning):
         complement = letter_type_none.complement()
     assert complement.letter_code == 'T'
     assert complement.letter_type is None
     assert complement.description == ''
     assert complement.degenerate is None
     assert complement.supported is False
     assert complement.in_fasta_spec is True
     # aminoacid letter code that is not also a nucleotide
     with pytest.warns(UserWarning):
         aminoacid = LetterCode('X').complement()
     assert aminoacid.letter_code == 'X'
     assert aminoacid.letter_type is None
     assert aminoacid.description == ''
     assert aminoacid.degenerate is None
     assert aminoacid.supported is False
     assert aminoacid.in_fasta_spec is True
Exemplo n.º 6
0
def letter_codes_unknown(unknown_characters):
    letter_codes = [LetterCode(character) for character in unknown_characters]
    return zip(letter_codes, unknown_characters)
Exemplo n.º 7
0
def letter_type_none():
    return LetterCode('A')
Exemplo n.º 8
0
 def test_lettercode(self, nucleotide_good):
     assert nucleotide_good == LetterCode('A')
     assert nucleotide_good.__eq__(LetterCode('A'))
     assert not nucleotide_good == LetterCode('C')
Exemplo n.º 9
0
def aminoacid_degenerate():
    return LetterCode('-', 'aminoacid')
Exemplo n.º 10
0
def aminoacid_good():
    return LetterCode('H', 'aminoacid')
Exemplo n.º 11
0
 def test_letter_code_multiple_characters(self):
     with pytest.raises(TypeError):
         LetterCode('AC')
Exemplo n.º 12
0
 def test_lettercode_wrong_type(self):
     with pytest.raises(TypeError):
         LetterCode.from_lettercode('A')
     with pytest.raises(TypeError):
         LetterCode.from_lettercode(1)
Exemplo n.º 13
0
def nucleotide_good():
    return LetterCode('A', 'nucleotide')
Exemplo n.º 14
0
 def test_letter_code_empty_str(self):
     with pytest.raises(TypeError):
         LetterCode('')
Exemplo n.º 15
0
def letter_codes_unknown_nucleotide(unknown_characters):
    letter_codes = [
        LetterCode(character, 'nucleotide') for character in unknown_characters
    ]
    return zip(letter_codes, unknown_characters)
Exemplo n.º 16
0
def letter_codes_unknown_aminoacid(unknown_characters):
    letter_codes = [
        LetterCode(character, 'aminoacid') for character in unknown_characters
    ]
    return zip(letter_codes, unknown_characters)
Exemplo n.º 17
0
def nucleotide_degenerate():
    return LetterCode('K', 'nucleotide')