diff --git a/source/Object_Oriented_Programming.rst b/source/Object_Oriented_Programming.rst new file mode 100644 index 0000000000000000000000000000000000000000..1e76016b67c8300c91b54a9392411ef9f418e0ef --- /dev/null +++ b/source/Object_Oriented_Programming.rst @@ -0,0 +1,26 @@ +.. sectnum:: + :start: 13 + + +.. _Object_Oriented_Programming: + +*************************** +Object Oriented Programming +*************************** + +Exercises +========= + + +Exercise +-------- + +Exercise +-------- + +Exercise +-------- + + +Exercise +-------- \ No newline at end of file diff --git a/source/_static/code/enzyme.py b/source/_static/code/enzyme.py new file mode 100644 index 0000000000000000000000000000000000000000..ea839f4da832e9f71fdb16c67909bb1896c29c38 --- /dev/null +++ b/source/_static/code/enzyme.py @@ -0,0 +1,47 @@ + +class Sequence(object): + + def __init__(self, identifier, comment, seq): + self.id = identifier + self.comment = comment + self.seq = self._clean(seq) + + + def _clean(self, seq): + """ + + :param seq: + :return: + """ + return seq.replace('\n') + + def enzyme_filter(self, enzymes): + """ + + :param enzymes: + :return: + """ + enzymes_which_binds = [] + for enz in enzymes: + if enz.binds(self.seq): + enzymes_which_binds.append(enz) + return + + +class RestrictionEnzyme(object): + + def __init__(self, name, binding, cut, end, comment=''): + self.name = name + self.binding = binding + self.cut = cut + self.end = end + self.comment = comment + + + def binds(self, seq): + """ + + :param seq: + :return: + """ + return self.binding in seq.seq \ No newline at end of file diff --git a/source/_static/code/matrix_obj.py b/source/_static/code/matrix_obj.py new file mode 100644 index 0000000000000000000000000000000000000000..f105d89207df6da378b48a20c0d844d8789b4c92 --- /dev/null +++ b/source/_static/code/matrix_obj.py @@ -0,0 +1,35 @@ + + + + +class Matrix(object): + + def __init__(self, row, col, val=None): + self._row = row + self._col = col + self._matrix = [] + for i in range(row): + c = [val] * col + self._matrix.append(c) + + def size(self): + return self._row, self._col + + def get_cell(self, row, col): + self._check_index(row, col) + return self._matrix[i][j] + + def matrix_set(self, row, col, val): + self._check_index(row, col) + self._matrix[row][col] = val + + def __str__(self): + s = '' + for i in range(self._row): + s += self._matrix[i] + s += '\n' + return s + + def _check_index(self, row, col): + if not (0 < row <= self._row) or not (0 < col <= self._col): + raise IndexError("matrix index out of range") diff --git a/source/_static/code/point.py b/source/_static/code/point.py new file mode 100644 index 0000000000000000000000000000000000000000..914c21edca38a6b0180b1ef08d71aa7517f7d4a1 --- /dev/null +++ b/source/_static/code/point.py @@ -0,0 +1,46 @@ +import math + + +class Point(object): + """Class to handle point in a 2 dimensions space""" + + def __init__(self, x, y): + """ + :param x: the value on the X-axis + :type x: float + :param y: the value on the Y-axis + :type y: float + """ + self.x = x + self.y = y + + + def show(self): + """ + :return: the coordinate of this point + :rtype: a tuple of 2 elements (float, float) + """ + return (self.x, self.y) + + + def move(self, x, y): + """ + :param x: the value to move on the X-axis + :type x: float + :param y: the value to move on the Y-axis + :type y: float + """ + self.x += x + self.y += y + + + def dist(self, pt): + """ + :param pt: the point to compute the distance with + :type pt: :class:`Point` object + :return: the distance between this point ant pt + :rtype: int + """ + dx = pt.x - self.x + dy = pt.y - self.y + return math.sqrt(dx ** 2 + dy ** 2)