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

now 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 ?

split seq python • 474 views
ADD COMMENT
2
Entering edit mode
11 weeks 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

Login before adding your answer.

Traffic: 1159 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