Skip to content

Instantly share code, notes, and snippets.

@karelfiser
karelfiser / find_kinase_consensus_in_proteins.R
Created November 30, 2012 17:25
find_kinase_consensus_in_proteins
## Find a kinase (here ABL1) consensus sequence in protein sequences using R.
proteins <- c("P00519", "P46109", "P61769") # ABL1, CRKL, B2M
for (ii in proteins) {
prot_url <- paste("http://www.uniprot.org/uniprot/", ii, ".fasta", sep="") # url of protein fasta
protein_fasta <- scan(file=url(prot_url), what="character", sep="\t") # read the protein fasta
protein_seq <- paste(protein_fasta[2:length(protein_fasta)], collapse="") # amino acid sequence only
# print(protein_seq)
for (ik in which(strsplit(protein_seq, '')[[1]]=='Y')) {
tyr_context <- substr(protein_seq, ik-1, ik+3)
# print(tyr_context)