Michael Mächtel пре 8 година
родитељ
комит
e978d9fd45
3 измењених фајлова са 81 додато и 0 уклоњено
  1. 5
    0
      files/hw2.txt
  2. 40
    0
      hw2/task1/README.md
  3. 36
    0
      hw2/task1/tests/task1.rs

+ 5
- 0
files/hw2.txt Прегледај датотеку

@@ -3,3 +3,8 @@
3 3
 ./hw2/simu1/QUESTIONS.md
4 4
 ./hw2/simu1/null.c
5 5
 
6
+./hw2/task1/README.md
7
+./hw2/task1/Cargo.toml
8
+./hw2/task1/tests/task1.rs
9
+./hw2/task1/src/lib.rs
10
+

+ 40
- 0
hw2/task1/README.md Прегледај датотеку

@@ -0,0 +1,40 @@
1
+# Homework hw2 task1
2
+
3
+## prepare your task
4
+
5
+Run the cargo command to prepare your task1/ directory as a library
6
+
7
+## task
8
+
9
+Calculate the Hamming difference between two DNA strands.
10
+
11
+A mutation is simply a mistake that occurs during the creation or
12
+copying of a nucleic acid, in particular DNA. Because nucleic acids are
13
+vital to cellular functions, mutations tend to cause a ripple effect
14
+throughout the cell. Although mutations are technically mistakes, a very
15
+rare mutation may equip the cell with a beneficial attribute. In fact,
16
+the macro effects of evolution are attributable by the accumulated
17
+result of beneficial microscopic mutations over many generations.
18
+
19
+The simplest and most common type of nucleic acid mutation is a point
20
+mutation, which replaces one base with another at a single nucleotide.
21
+
22
+By counting the number of differences between two homologous DNA strands
23
+taken from different genomes with a common ancestor, we get a measure of
24
+the minimum number of point mutations that could have occurred on the
25
+evolutionary path between the two strands.
26
+
27
+This is called the 'Hamming distance'.
28
+
29
+It is found by comparing two DNA strands and counting how many of the
30
+nucleotides are different from their equivalent in the other string.
31
+
32
+    GAGCCTACTAACGGGAT
33
+    CATCGTAATGACGGCCT
34
+    ^ ^ ^  ^ ^    ^^
35
+
36
+The Hamming distance between these two DNA strands is 7.
37
+
38
+
39
+
40
+

+ 36
- 0
hw2/task1/tests/task1.rs Прегледај датотеку

@@ -0,0 +1,36 @@
1
+extern crate task1;
2
+
3
+#[test]
4
+fn test_no_difference_between_empty_strands() {
5
+    assert_eq!(task1::hamming_distance("", "").unwrap(), 0);
6
+}
7
+
8
+#[test]
9
+fn test_no_difference_between_identical_strands() {
10
+    assert_eq!(task1::hamming_distance("GGACTGA", "GGACTGA").unwrap(), 0);
11
+}
12
+
13
+#[test]
14
+fn test_complete_hamming_distance_in_small_strand() {
15
+    assert_eq!(task1::hamming_distance("ACT", "GGA").unwrap(), 3);
16
+}
17
+
18
+#[test]
19
+fn test_small_hamming_distance_in_the_middle_somewhere() {
20
+    assert_eq!(task1::hamming_distance("GGACG", "GGTCG").unwrap(), 1);
21
+}
22
+
23
+#[test]
24
+fn test_larger_distance() {
25
+    assert_eq!(task1::hamming_distance("ACCAGGG", "ACTATGG").unwrap(), 2);
26
+}
27
+
28
+#[test]
29
+fn test_first_string_is_longer() {
30
+    assert!(task1::hamming_distance("AAA", "AA").is_err());
31
+}
32
+
33
+#[test]
34
+fn test_second_string_is_longer() {
35
+    assert!(task1::hamming_distance("A", "AA").is_err());
36
+}

Loading…
Откажи
Сачувај