My First Blog Post!

December 11, 2019   

Python in R

Reticulate

I think one of the most cool Python thing that I learned this semester was using Python in RStudio. It’s interesting to see how you can interact with different languages in one platform, and the Reticulate package allows you to do just that!

library(reticulate)

a <- "Swag"
b = 'money'

print(r.a ,b)
## ('Swag', 'money')
cat(c(a,py$b))
## Swag money

Computational Biology Context

Another python use that I found was using it in the context of computational biology. I personally did much of my computational biology research in R, but python’s strength with strings allow you to solve all sorts of problems.

my_seq2 = "CAGCCCAATCAGGCTCTACTGCCACTAAACTTACGCAGGATATATTTACGCCGACGTACT"

def kmer(seq):
    codon_table = {}
    for i in range(len(seq)-2):
        if seq[i:i+3] in codon_table:
            codon_table[seq[i:i+3]] += 1
        else:
            codon_table[seq[i:i+3]] = 1
    return codon_table

kmer(my_seq2)
## {'CTT': 1, 'AAA': 1, 'ATC': 1, 'AAC': 1, 'ATA': 2, 'AGG': 2, 'CTC': 1, 'AGC': 1, 'AAT': 1, 'ATT': 1, 'CTG': 1, 'CTA': 2, 'ACT': 4, 'CAC': 1, 'ACG': 3, 'CAA': 1, 'CCA': 2, 'CCG': 1, 'CCC': 1, 'TAT': 2, 'CGA': 1, 'CAG': 3, 'TCT': 1, 'GAT': 1, 'TTT': 1, 'TGC': 1, 'GGA': 1, 'TAA': 1, 'GGC': 1, 'TAC': 4, 'TTA': 2, 'GAC': 1, 'CGT': 1, 'TCA': 1, 'GCA': 1, 'GTA': 1, 'GCC': 3, 'GCT': 1, 'CGC': 2}

In this situation, I was able to use python to analyze a DNA string for all of the codons possible within the 3 different reading frames.



comments powered by Disqus