Skip to content

Session 6: Object Oriented Programing 2

Juan Gonzalez-Gomez edited this page Feb 6, 2019 · 15 revisions
  • Goals:
    • Practicing with Object oriented programming
  • Duration: 2h
  • Date: Week 3: Wednesday, Feb-6th-2019

Contents

Practice 1

  • Place all the files in your P1 Folder in your 2018-19-PNE repo in github
  • Create the Seq class for working with sequences. It should be stored in the Seq.py file
  • The Seq class should implement the following methods:
    • Class initialization: The string with the sequence is passed when creating the object (as we have seen in the examples)
    • len(): It returns the length of the sequence
    • complement(): It returns a new sequence, that is the complement of the object's sequence (Tip: Calculate first the complement string and then return a object created from this string. Use a diccionary calculating the complement
    • reverse(): Return a new sequence that is the reverse of the current sequence
    • count(base): Return the number of times the base "base" appears in the sequence
    • perc(base): Return the percentage of the base "base" over the total bases
  • The Seq class should implement the attribute strbase, with the sequence as a string (the same that is shown in the examples)
  • The main program is located in the file: Seq_main.py
  • The main program should create 4 sequences. The first two are created directly my invoking the Seq method with their string sequence
  • The sequence 3 is created by invoking the complement() method in the sequence 1
  • The sequence 4 is created by invoking the reverse() method in the sequence 3
  • The main program should print the following information for every sequence:
    • The sequence string
    • The total length
    • The number of bases of every type
    • The percentage of bases of every type
  • This is an example of the output:
Sequence 1: AGTACACTGGT
  Length: 11
  Bases count: A:3, T:3, C:2, G:3
  Bases percentage: A:27.3%, T:27.3%, C:18.2%, G:27.3%

Sequence 2: CGTAAC
  Length: 6
  Bases count: A:2, T:1, C:2, G:1
  Bases percentage: A:33.3%, T:16.7%, C:33.3%, G:16.7%

Sequence 3: TCATGTGACCA
  Length: 11
  Bases count: A:3, T:3, C:3, G:2
  Bases percentage: A:27.3%, T:27.3%, C:27.3%, G:18.2%

Sequence 4: ACCAGTGTACT
  Length: 11
  Bases count: A:3, T:3, C:3, G:2
  Bases percentage: A:27.3%, T:27.3%, C:27.3%, G:18.2%

Authors

Credits

  • Alvaro del Castillo. He designed and created the original content of this subject. Thanks a lot :-)

License

Links

Clone this wiki locally