def receive(self, encoded):

        huffman_encoded_text, huffman_root, key, encrypted, dictionary = encoded

        # Huffman decoding
        huffman_decoded_text = huffman_decode(huffman_encoded_text, huffman_root)
        print "Huffman decoded"
        print huffman_decoded_text

        ###### Decryption ######
        b = ReducedArrayDecryption(huffman_decoded_text,key,encrypted[0]) 
        decrypted_text = b.decrypt()
        print "Decrypted text"
        print decrypted_text
        ########################

        # Run-length decoding
        rle_decoded_text = invert_rle(decrypted_text)
        print "RLE inverse"
        print rle_decoded_text    

        # Burrows-Wheeler Transform
        bwt_decoded_text = invert_BWT(rle_decoded_text)
        print "BWT inverse"
        print bwt_decoded_text

        # Dictionary decoding
        decoded_text = dictionary_decoding(bwt_decoded_text, dictionary)
        #print "Dictionary decoded"
        #print decoded_text
        with open('dictionary_decoding_output.txt', 'w') as f:
            f.write(decoded_text)

        return decoded_text
from BWT import BWT, invert_BWT
from RLE import rle, invert_rle

string = "^BANANA@"
transformed_string = BWT(string)
original_string = invert_BWT(transformed_string)

print string
print transformed_string
print original_string

rle_string = rle(transformed_string)
print rle_string
rle_original = invert_rle(rle_string)
print rle_original