Bioinformatics in Python: DNA Toolkit. Part 4: Translation, Codon Usage

Поделиться
HTML-код
  • Опубликовано: 11 сен 2024

Комментарии • 24

  • @BasicScienceSeries
    @BasicScienceSeries 4 года назад +9

    If you are getting Counter error :
    This is what worked for my Counter error:
    freqDict = dict(collections.Counter(tmpList))
    Thanks rebelCoder for these videos ! Keep Going..

  • @tinos542
    @tinos542 4 года назад

    You are amazing! Thank you for this

  • @bryzsalvador8692
    @bryzsalvador8692 4 года назад +4

    return [DNA_Codons[seq[pos:pos...... len(seq) -2, 3)]

    • @rebelScience
      @rebelScience  4 года назад +8

      Basically, this is made to make sure we don't hit array/list out of bounds error and we also we scan every triplet (codon) in a string. As we have a third parameter '3' that will ensure we read 3 nucleotides, jump 3 positions, read another 3. I always suggest writing a simplified version of a code you are trying to understand and print() the results of every step so you can see what is happening:
      ---
      seq = "ATCGCATACA"
      k = 3
      # With - 2 correction
      for pos in range(0, len(seq) - 2, k):
      print(seq[pos:pos + k])
      Result:
      ATC
      GCA
      TAC
      # Without -2 correction:
      for pos in range(0, len(seq), k):
      print(seq[pos:pos + k])
      ATC
      GCA
      TAC
      A
      ^-- this last, single nucleotide 'A' will result in a KeyError as we will try to search/match A in our DNA_Codons dictionary. And DNA_Codons only has triplets/codons. So we need to make sure we always read 3 nucleotides and any 'tail' is discarded.
      Try using VSCode debugger to see what is happening at every stage. Also join our Telegram/Matrix chat. It is easier to discuss code there.

    • @bryzsalvador8692
      @bryzsalvador8692 4 года назад +3

      @@rebelScience Thank you so much. I also tried omitting that "-2" and I found that I'm having a problem with that tail.
      Sorry I'm really new at this. Just started learning coding this sem.
      What I used to get around the keyerror was a function where if the len(seq) %3 = 0 or 1 or 2 and it trimmed nucleotides at the end that but I had problems when I tried to attach my reverse complement code and translation of that complement because the sequence is now trimmed.

  • @talkpython
    @talkpython 3 года назад +1

    Thanks a bunch for recommending @talkpython at the end of the video. :)

  • @dr.lokbahadurshrestha4507
    @dr.lokbahadurshrestha4507 3 года назад +1

    In codon usage, I am getting "seq_type" is not defined.

  • @user-in1mg5cb6j
    @user-in1mg5cb6j 4 года назад +1

    Hi, I have a little question about this part.
    When I use function -codon_usage,
    "freqDict = dict(Counter(tmpList))
    NameError: name 'Counter' is not defined" was happened.
    I don't know why.

    • @rebelScience
      @rebelScience  4 года назад

      Hi! Did you watch previous videos ? We included that module before. You can see it on a line 3 in this video at 3:00

    • @user-in1mg5cb6j
      @user-in1mg5cb6j 4 года назад

      @@rebelScience I watched previous videos. Maybe I missed the key point. OK! I will check it again. Thank you!

    • @user-in1mg5cb6j
      @user-in1mg5cb6j 4 года назад +1

      @@rebelScience oh! I found it!

    • @rebelScience
      @rebelScience  4 года назад

      Good. Basically Counter is a method from Python's collections module. It has a lot of good stuff it it. You should search for a video on that module.

    • @user-in1mg5cb6j
      @user-in1mg5cb6j 4 года назад

      @@rebelScience Thanks for your advice!

  • @dylanneal8244
    @dylanneal8244 3 года назад

    what is the "-2" for in the translate_seq function? Great video by the way!

    • @rebelScience
      @rebelScience  3 года назад

      Hey! Someone already asked this in the comments and got an answer. Make sure you look through next time :) We read triplets in this function, right? Three amino acids at a time. -2 will ensure we stop at the very end and don't ready past the last three. Don't just take my word, and try using a small string of 9 and print every step, so you can see and understand why we are doing this. Try removing -2, see what happens, experiment, break things. Make sure you don’t just copy-past code.

  • @f-man3274
    @f-man3274 2 года назад

    Hi, thank you for video
    freqDict = dict(Counter(tmpList))
    ^
    SyntaxError: invalid syntax
    Do you know why that error can occur?

  • @EuphoriaSkater3
    @EuphoriaSkater3 4 года назад

    Hi rebelCoder if you were to try and join the amino acids together and omit the [] and '' how would you do that?

    • @CakeAndPi3
      @CakeAndPi3 4 года назад

      return "".join([DNA_Codons[seq[pos:pos+ 3 ]] for pos in range(init_pos, len(seq) - 2, 3)])

  • @moa4f223
    @moa4f223 4 года назад

    I have counter is not defined and i don't know which video to watch (it's title) pls

    • @rebelScience
      @rebelScience  4 года назад

      Hey! 'counter' is a method, that is built-in to Python. Python has this cool module, called 'collections', right? We use some of that functionality. 'counter' method is one of them. You can just make sure you include that module by adding it on the very first line in your file: 'from collections import counter' or you can watch the very first video in this series here: ruclips.net/video/Wkx0fI4e0fs/видео.html