Sep-19-2019, 01:56 PM
(This post was last modified: Sep-19-2019, 01:56 PM by YoungGrassHopper.)
Hey guys,
Hope you can shed some light on this matter.
In this task I need to create a function that displays the amino acid type that corresponds to a codon. for example if the user inputs a DNA sequence of AAABBBCCCDD
The function needs to be able to deal with a length not divisible by 3, in other words any random input
AAA is one codon and will represent one type of amino acid
BBB "" ""
CCC "" ""
DD is not a full codon and needs to be removed from the sequence
What I am trying to do now is to get the input / or argument given to the called function into workable blocks of 3. for example if the input is AAABBBCC
I want to get it to:
DNA1 = "AAA"
DNA2 = "BBB"
CC needs to get cut off.
Below is my idea to get the odd tail that's not workable cut off and it seems to work if input is AAABBBC but not if the input is AAABBBCC , I will need to fix that too
but how do I code it so it splits any random size sequence in workable chunks and join them again from list to string?
also I struggled to join it again from ['A','A','A'] to "AAA"
my Idea as is can obvious not deal with a random size input which is a problem
Hope you can shed some light on this matter.
In this task I need to create a function that displays the amino acid type that corresponds to a codon. for example if the user inputs a DNA sequence of AAABBBCCCDD
The function needs to be able to deal with a length not divisible by 3, in other words any random input
AAA is one codon and will represent one type of amino acid
BBB "" ""
CCC "" ""
DD is not a full codon and needs to be removed from the sequence
What I am trying to do now is to get the input / or argument given to the called function into workable blocks of 3. for example if the input is AAABBBCC
I want to get it to:
DNA1 = "AAA"
DNA2 = "BBB"
CC needs to get cut off.
Below is my idea to get the odd tail that's not workable cut off and it seems to work if input is AAABBBC but not if the input is AAABBBCC , I will need to fix that too
but how do I code it so it splits any random size sequence in workable chunks and join them again from list to string?
also I struggled to join it again from ['A','A','A'] to "AAA"
my Idea as is can obvious not deal with a random size input which is a problem
dna = "AAABBBCCCDD" dna = list(dna) DNA = len(dna) print(DNA) if DNA % 3 != 0: del dna[-1] print(dna) DNA1 = dna[0:3] DNA2 = dna[3:6] print(DNA1) print(DNA2) ''.join(DNA2) print(DNA2)Any help would be appreciate stacks