-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCodeUsage.R
71 lines (37 loc) · 1.07 KB
/
CodeUsage.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
library("ccmotif") # Version 0.6.6
#' Set path
#' Set file
#' Output: RDS
#' calculates Code Usage for all 216 codes and saves data to file
path = "../BA Circular Code/" # Change here
file = "Sars_23_0.fasta" # Change here
ff = read.fasta(paste(path, file, sep = ""),
as.string = TRUE,
forceDNAtolower = FALSE)
codons = codon.splitlist(ff)
cu = codon.usage(codons)
filename = unlist(strsplit(file, ".fasta"))
df = data.frame(File = c(),
Code = c(),
CodeUsage = c())
for (h in 1:length(codes.c3)) {
code = h
p = codes.usage(cu, codes.c3[[code]]) #Code Usage
#Fill data frame
tmp = data.frame(File = file,
Code = code,
CodeUsage = round(p, 3))
df = rbind(df, tmp)
}
#generate RDS file
subFrame = df[df$File == file,]
subFrame = subFrame[order(-subFrame$CodeUsage),] #sort
saveRDS(
object = subFrame,
file = paste("CodeUsage/",
"CU",
"_",
filename,
".RDS",
sep = "")
)