-
Notifications
You must be signed in to change notification settings - Fork 1
/
demo_online_decode.py
62 lines (54 loc) · 2.89 KB
/
demo_online_decode.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/python
import argparse
from norec4dna.OnlineDecoder import OnlineDecoder
from norec4dna.ErrorCorrection import nocode, get_error_correction_decode
STATIC_NUM_CHUNKS = 231
NULL_IS_TERMINATOR = True
PRINT_TO_OUTPUT = False
ID_LEN_FORMAT = "H"
NUMBER_OF_CHUNKS_LEN_FORMAT = "H"
PACKET_LEN_FORMAT = "H"
CRC_LEN_FORMAT = "L"
class demo_decode:
@staticmethod
def decode(file, error_correction=nocode, null_is_terminator=NULL_IS_TERMINATOR, mode_1_bmp=False,
number_of_chunks=STATIC_NUM_CHUNKS, use_header_chunk=False, id_len_format=ID_LEN_FORMAT,
number_of_chunks_len_format=NUMBER_OF_CHUNKS_LEN_FORMAT, packet_len_format=PACKET_LEN_FORMAT,
crc_len_format=CRC_LEN_FORMAT, read_all=False, distribution_cfg_str="", return_decoder=False,
checksum_len_str=None):
def _internal(decoder):
decoder.decode(quality_len_format="B", check_block_number_len_format=id_len_format,
number_of_chunks_len_format=number_of_chunks_len_format, crc_len_format=crc_len_format)
x = OnlineDecoder(file, error_correction=error_correction, use_headerchunk=use_header_chunk,
static_number_of_chunks=number_of_chunks, read_all=read_all, checksum_len_str=checksum_len_str)
print("[1/2] Approximation Decode")
_internal(x)
x.saveDecodedFile(null_is_terminator=null_is_terminator, print_to_output=PRINT_TO_OUTPUT)
if return_decoder:
return x
if __name__ == "__main__":
try:
parser = argparse.ArgumentParser()
parser.add_argument(
"filename", metavar="file", type=str, help="the file / folder to Decode"
)
parser.add_argument("--error_correction", metavar="error_correction", type=str, required=False,
default="nocode",
help="Error Correction Method to use; possible values: \
nocode, crc, reedsolomon (default=nocode)")
parser.add_argument("--header_crc_str", metavar="header_crc_str", required=False, type=str, default="")
parser.add_argument("--repair_symbols", metavar="repair_symbols", type=int, required=False, default=2,
help="number of repairsymbols for ReedSolomon (default=2)")
args = parser.parse_args()
_file = args.filename
_repair_symbols = args.repair_symbols
_header_crc_str = args.header_crc_str
_error_correction = get_error_correction_decode(args.error_correction, _repair_symbols)
print("Zu dekodierende Datei / Ordner: " + str(_file))
demo = demo_decode()
demo.decode(_file, error_correction=_error_correction, checksum_len_str=_header_crc_str)
# else:
# print("Please add the file you want to Encode as an Argument")
except Exception as e:
raise e
# input("Press Enter to continue ...")