how to split RNA-seq into codons by using python
1
1
Entering edit mode
3.1 years ago
m90 ▴ 30

I have this RNA-seq ACAGUCGACUAGCUUGCACGUAC and I want to split it into codons like this (ACC and AGG) and count the number of complete codon and incomplete codon by using python?

python split • 3.6k views
ADD COMMENT
3
Entering edit mode
3.1 years ago

Today I got access to a "new thing", currently in beta testing, called the GitHub Copilot, I am using it to answer this question:

first I typed

## how to split RNA-seq into codons

The copilot wrote me the code:

def codons(seq):
    codon_list = []
    for i in range(0, len(seq), 3):
        codon_list.append(seq[i:i+3])
    return codon_list

Let's see how it works:

seq = "ACAGUCGACUAGCUUGCACGUAC"
print (codons(seq))

prints:

['ACA', 'GUC', 'GAC', 'UAG', 'CUU', 'GCA', 'CGU', 'AC']

looks good to me, then I wrote:

#  count complete and incomplete codons

without batting an eye the Copilot suggested:

def count():
    seq = "ACAGUCGACUAGCUUGCACGUAC"
    codon_list = codons(seq)
    complete = 0
    incomplete = 0
    for codon in codon_list:
        if len(codon) == 3:
            complete += 1
        else:
            incomplete += 1
    return complete, incomplete

A new era has begun in computing.

I'll remember this day: Friday, October 29, 2021. It is the day when I realized a new era is upon us.

ADD COMMENT
0
Entering edit mode

Really interesting project.

ADD REPLY
0
Entering edit mode

No more Google/StackOverflow middle-man then, just go to this site, type in your google query, get code to run. Nice!

ADD REPLY

Login before adding your answer.

Traffic: 1360 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6