Пример #1
0
def main():
    problem_dataset_dir = os.path.join('Problems', 'Problem2')
    solution_dir = os.path.join("Problems", "Problem2Solution")

    data_reader = DataReader(problem_dataset_dir)
    training_data, testing_data = data_reader.get_data()
    codons_table = data_reader.get_rna_codon_table()

    for sample in training_data:
        dna_string = sample[0][0]
        amino_acid = sample[0][1]
        output = sample[1]
        dna = DNA(dna_string)
        dna.set_codon_table(codons_table)
        candidates = dna.get_dna_to_amino_acid_candidates(amino_acid)

        if set(candidates) != set(output):
            raise Exception("Output not matched!\nExpecting: " + str(output) +
                            "\nFound: " + str(candidates))

    print("Passed training data..\n\n")

    writer = DataWriter(solution_dir)
    usage = Usage()

    for sample in testing_data:
        usage.start()
        dna_string = sample[0][0]
        amino_acid = sample[0][1]
        dna = DNA(dna_string)
        dna.set_codon_table(codons_table)
        candidates = dna.get_dna_to_amino_acid_candidates(amino_acid)
        usage.end()

        writer.write_data((dna_string, amino_acid), candidates,
                          usage.get_execution_time(), usage.get_memory_usage())
        print("DNA:\n" + dna_string)
        print("Protein\n" + amino_acid)

        print("\n\nOutput")
        print("=====")

        print(str(len(candidates)))
        for substring in candidates:
            print(substring)

        print("\n\nExecution Time: " + str(usage.get_execution_time()) + " s")
        print("Memory Usage: " + str(usage.get_memory_usage()) + " MB")
Пример #2
0
def main():
    problem_dataset_dir = os.path.join('Problems', 'Problem2')
    solution_dir = os.path.join("Problems", "Problem2Solution")

    data_reader = DataReader(problem_dataset_dir)
    training_data, testing_data = data_reader.get_data()
    codons_table = data_reader.get_rna_codon_table()

    for sample in training_data:
        dna_string = sample[0][0]
        amino_acid = sample[0][1]
        output = sample[1]
        dna = DNA(dna_string)
        dna.set_codon_table(codons_table)
        candidates = dna.get_dna_to_amino_acid_candidates(amino_acid)

        if set(candidates) != set(output):
            raise Exception("Output not matched!\nExpecting: " + str(output) + "\nFound: " + str(candidates))

    print("Passed training data..\n\n")

    writer = DataWriter(solution_dir)
    usage = Usage()

    for sample in testing_data:
        usage.start()
        dna_string = sample[0][0]
        amino_acid = sample[0][1]
        dna = DNA(dna_string)
        dna.set_codon_table(codons_table)
        candidates = dna.get_dna_to_amino_acid_candidates(amino_acid)
        usage.end()

        writer.write_data((dna_string, amino_acid), candidates, usage.get_execution_time(), usage.get_memory_usage())
        print("DNA:\n" + dna_string)
        print("Protein\n" + amino_acid)

        print("\n\nOutput")
        print("=====")

        print(str(len(candidates)))
        for substring in candidates:
            print(substring)

        print("\n\nExecution Time: " + str(usage.get_execution_time()) + " s")
        print("Memory Usage: " + str(usage.get_memory_usage()) + " MB")
Пример #3
0
def main():
    problem_dataset_dir = os.path.join('Problems', 'Problem1')
    solution_dir = os.path.join("Problems", "Problem1Solution")

    data_reader = DataReader(problem_dataset_dir)
    training_data, testing_data = data_reader.get_data()
    codons_table = data_reader.get_rna_codon_table()

    for sample in training_data:
        rna_string = sample[0]
        output = sample[1]
        rna = RNA(rna_string)
        rna.set_codons_table(codons_table)
        amino_acid = rna.to_amino_acid()

        if amino_acid != output:
            raise Exception("Output not matched!\nExpecting: " + output +
                            "\nFound: " + amino_acid)

    print("Passed training data..\n\n")

    writer = DataWriter(solution_dir)
    usage = Usage()

    for sample in testing_data:
        usage.start()
        rna_string = sample[0]
        rna = RNA(rna_string)
        rna.set_codons_table(codons_table)
        amino_acid = rna.to_amino_acid()
        usage.end()

        writer.write_data(rna_string, amino_acid, usage.get_execution_time(),
                          usage.get_memory_usage())

        print("RNA:\n" + rna_string)
        print("Protein:\n" + amino_acid)
        print("\n\nExecution Time: " + str(usage.get_execution_time()) + " s")
        print("Memory Usage: " + str(usage.get_memory_usage()) + " MB")