예제 #1
0
파일: Runner.py 프로젝트: mskec/WaveletTree
    fasta_file = FASTA(sys.argv[1])
    fasta_file.read()

    alphabet = list(set(fasta_file.data))
    alphabet.sort()

    tree = WaveletTree()
    tree.build(alphabet, fasta_file.data)

    if task == 'access':
        index = int(sys.argv[4])
        result = tree.access(index)

    elif task == 'rank':
        position = int(sys.argv[4])
        character = sys.argv[5]
        result = tree.rank(position, character)

    elif task == 'select':
        nth_occurence = int(sys.argv[4])
        character = sys.argv[5]
        result = tree.select(nth_occurence, character)

    elif task == 'build':
        result = 'OK'

    # Save result to out file
    out_file = open(sys.argv[2], 'w')
    out_file.write(str(result))
    out_file.close()
예제 #2
0
    fasta_file = FASTA(sys.argv[1])
    fasta_file.read()

    alphabet = list(set(fasta_file.data))
    alphabet.sort()

    tree = WaveletTree()
    tree.build(alphabet, fasta_file.data)

    if task == 'access':
        index = int(sys.argv[4])
        result = tree.access(index)

    elif task == 'rank':
        position = int(sys.argv[4])
        character = sys.argv[5]
        result = tree.rank(position, character)

    elif task == 'select':
        nth_occurence = int(sys.argv[4])
        character = sys.argv[5]
        result = tree.select(nth_occurence, character)

    elif task == 'build':
        result = 'OK'

    # Save result to out file
    out_file = open(sys.argv[2], 'w')
    out_file.write(str(result))
    out_file.close()
예제 #3
0
            # Access
            stopwatch.restart()
            stopwatch.start()
            tree.access(test_idx)
            stopwatch.stop()
            time_access = time_access + stopwatch.elapsed_ms()

            # Select
            stopwatch.restart()
            stopwatch.start()
            tree.select(test_nth_occurence, test_character)
            stopwatch.stop()
            time_select = time_select + stopwatch.elapsed_ms()
            stopwatch.restart()

            # Rank
            stopwatch.start()
            tree.rank(test_idx, test_character)
            stopwatch.stop()
            time_rank += stopwatch.elapsed_ms()

        time_select /= test_runs
        time_rank /= test_runs
        time_access /= test_runs

        report_3(read_stopwatch, build_stopwatch, time_select, time_rank,
                 time_access)

    else:
        report_2(read_stopwatch, build_stopwatch)
예제 #4
0
파일: Tester.py 프로젝트: mskec/WaveletTree
            # Access
            stopwatch.restart()
            stopwatch.start()
            tree.access(test_idx)
            stopwatch.stop()
            time_access = time_access + stopwatch.elapsed_ms()

            # Select
            stopwatch.restart()
            stopwatch.start()
            tree.select(test_nth_occurence, test_character)
            stopwatch.stop()
            time_select = time_select + stopwatch.elapsed_ms()
            stopwatch.restart()

            # Rank
            stopwatch.start()
            tree.rank(test_idx, test_character)
            stopwatch.stop()
            time_rank += stopwatch.elapsed_ms()

        time_select /= test_runs
        time_rank /= test_runs
        time_access /= test_runs

        report_3(read_stopwatch, build_stopwatch, time_select, time_rank, time_access)

    else:
        report_2(read_stopwatch, build_stopwatch)