Blog of Andrés Aravena
CMB2:

Homework 4

26 March 2021. Deadline: Friday, 2 April, 8:59.

Vector to vector

Write a function that takes a DNA sequence and returns its reverse-complement.

Use it to show that the GC skew of the reverse-complement strand has the same absolute value as the original strand, but opposite sign.

Vector to value

Make these functions using only for(), if() and indices. You cannot use the words min or max. The input is a vector called x.

Please write the code of the following functions:

  1. smallest_value(x). Returns the smallest element in x.

    You can test your function with the following code.

    x <- c(16, 15, 19, 10, 14, 7, 12, 18, 20, 9)
    min(x)
    smallest_value(x)

    The two results must be the same.

  2. largest_value(x). Returns the largest element in x.

    You can test your function with the following code.

    x <- c(7, 6, 18, 5, 16, 19, 7, 10, 14, 11)
    max(x)
    largest_value(x)

    The two results must be the same.

  3. place_of_smallest(x). Returns the index of the smallest element in x.

    You can test your function with the following code.

    x <- c(17, 12, 5, 6, 14, 15, 20, 13, 9, 20)
    which.min(x)
    place_of_smallest(x)

    The two results must be the same.

  4. place_of_largest(x). Returns the index of the largest element in x.

    You can test your function with the following code.

    x <- c(11, 14, 7, 6, 13, 10, 18, 16, 14, 14)
    which.max(x)
    place_of_largest(x)

    The two results must be the same.

Deadline: Friday, 2 April, 8:59.

Originally published at https://anaraven.bitbucket.io/blog/2021/cmb2/homework-4.html