Example #1
0
def test_decodability(args):
    e_correction = args[0]
    repair_symbols = int(args[1])
    cmp_str = b"AAAAAACHZACHEFAKLF(24z98"
    assert get_error_correction_decode(e_correction, repair_symbols)(
        get_error_correction_encode(e_correction,
                                    repair_symbols)(cmp_str)) == cmp_str
Example #2
0
                        required=False,
                        type=bool,
                        default=False)
    parser.add_argument("--save_number_of_chunks",
                        metavar="save_number_of_chunks",
                        required=False,
                        type=bool,
                        default=False)
    parser.add_argument("--as_mode_1_bmp", required=False, action="store_true")
    overhead = 6.0
    args = parser.parse_args()
    arg_file = args.filename
    arg_chunk_size = args.chunk_size
    arg_number_of_chunks = args.number_of_chunks
    arg_as_dna = args.as_dna
    e_correction = args.error_correction
    norepair_symbols = args.repair_symbols
    arg_insert_header = args.insert_header
    save_number_of_chunks = args.save_number_of_chunks
    arg_mode_1_bmp = args.as_mode_1_bmp
    if arg_chunk_size == arg_number_of_chunks == 0:
        print("Please set either a chunk_size or a number_of_chunks")
        exit()
    arg_error_correction = get_error_correction_encode(e_correction,
                                                       norepair_symbols)
    print("File to encode: " + str(arg_file))
    main(arg_file, arg_number_of_chunks, arg_chunk_size, arg_as_dna,
         arg_error_correction, arg_insert_header, save_number_of_chunks,
         arg_mode_1_bmp)
    print("File encoded.")
Example #3
0
 parser.add_argument("--drop_upper_bound", metavar="drop_upper_bound", required=False, type=float, default=0.5,
                     help="upper bound for calculated error probability of packet before dropping")
 parser.add_argument("--overhead", metavar="overhead", required=False, type=float, default=0.40,
                     help="desired overhead of packets")
 parser.add_argument("--epsilon", metavar="epsilon", required=False, type=float, default=0.068,
                     help="epsilon value of the coding")
 parser.add_argument("--quality", metavar="quality", required=False, type=int, default=7,
                     help="quality value of the coding")
 args = parser.parse_args()
 _file = args.filename
 #_chunk_size = args.chunk_size
 _no_repair_symbols = args.repair_symbols
 _insert_header = args.insert_header
 _save_number_of_chunks = args.save_number_of_chunks
 _upper_bound = args.drop_upper_bound
 _error_correction = get_error_correction_encode(args.error_correction, _no_repair_symbols)
 _save_as_fasta = args.save_as_fasta
 _save_as_zip = args.save_as_zip
 _overhead = args.overhead
 _epsilon = args.epsilon
 _quality = args.quality
 # for _file in input_files:
 print("File to encode: " + str(_file))
 demo = demo_online_encode()
 encoder_instance = demo.encode(_file, error_correction=_error_correction,
                                insert_header=_insert_header, save_number_of_chunks_in_packet=_save_number_of_chunks,
                                save_as_fasta=_save_as_fasta, save_as_zip=_save_as_zip, overhead=_overhead,
                                epsilon=_epsilon, quality=_quality, upper_bound=_upper_bound)
 conf = {'error_correction': args.error_correction, 'repair_symbols': _no_repair_symbols, 'asdna': True,
         'number_of_splits': 0, 'quality': encoder_instance.quality, 'epsilon': encoder_instance.epsilon,
         'find_minimum_mode': False, 'seq_seed': False}
Example #4
0
def plot_numbers(counter: typing.List[int], save_str):
    plt.plot(counter)
    plt.xlabel("Chunk")
    plt.ylabel("# Occurrences")
    plt.savefig(save_str + '.svg')


if __name__ == "__main__":
    file = "logo.jpg"
    number_of_chunks = 400
    insert_header = True
    rules = FastDNARules()
    norepair_symbols = 4
    error_correction_str = "reedsolomon"
    error_correction = get_error_correction_encode(error_correction_str, norepair_symbols)
    PACKET_LEN_FORMAT = "I"
    CRC_LEN_FORMAT = "I"
    NUMBER_OF_CHUNKS_LEN_FORMAT = "I"
    ID_LEN_FORMAT = "I"
    save_number_of_chunks_in_packet = False
    upper_bound = 0.9
    encoder = RU10Encoder(file, number_of_chunks, RaptorDistribution(number_of_chunks=number_of_chunks),
                          insert_header=insert_header, pseudo_decoder=None,
                          chunk_size=0, rules=rules, error_correction=error_correction,
                          packet_len_format=PACKET_LEN_FORMAT,
                          crc_len_format=CRC_LEN_FORMAT, number_of_chunks_len_format=NUMBER_OF_CHUNKS_LEN_FORMAT,
                          id_len_format=ID_LEN_FORMAT, save_number_of_chunks_in_packet=save_number_of_chunks_in_packet,
                          mode_1_bmp=False, prepend="", append="", drop_upper_bound=upper_bound)
    encoder.set_overhead_limit(0.40)
    # encoder.encode_to_packets()