-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSequence_Alignment_Speed_Test.R
75 lines (59 loc) · 1.8 KB
/
Sequence_Alignment_Speed_Test.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
###Pairwise Sequence Alignment Speed Test
###SeyyedAmirreza Mousavi Majd
library(Biostrings)
library(dplyr)
library(ggplot2)
library(here)
#setwd("C:/Users/Amirreza/Desktop/Short scripts github/")
#or a better option :
setwd(here())
NSEQ=5 ###test speed for random sequences of
###length 50,100,150,...,(NSEQ*50) residue
Create_Random_BioString = function(grp="DNA",N_Residue=100){
##grp=="DNA" -> DNAstring
##grp!="DNA" -> AAstring
if(grp=="DNA"){
string1 <- DNAString(paste(sample(DNA_BASES, N_Residue, replace = TRUE), collapse = ""))
}
else {
string1 <- AAString(paste(sample(AA_STANDARD, N_Residue, replace = TRUE), collapse = ""))
}
return(string1)
}
result=tibble(.rows = NSEQ)
for(GRP in c("DNA","AA")){
for(aln_type in c("global","local")){
for(j in 1:5){
###test for DNA/AA string Global and Local, with different # of residues.
N <- as.integer(seq(50, NSEQ*50, by = 50))
timings <- rep(0, length(N))
names(timings) <- as.character(N)
for (i in 1:(length(N))) {
string1 <- Create_Random_BioString(GRP,N[i])
string2 <- Create_Random_BioString(GRP,N[i])
timings[i] <- system.time(pairwiseAlignment(string1, string2, type = aln_type))[["user.self"]]
}
result=bind_cols(result,as_tibble(timings))
}
}
}
print(result)
###Renaming columns for better representation.
p=1
result=as.data.frame(result)
col_name_temp=rep(NA,20)
for(GRP in c("DNA","AA")){
for(aln_type in c("global","local")){
for(j in 1:5){
LABEL=paste0(GRP,aln_type,j)
col_name_temp[p]=LABEL
p=p+1
}
}
}
colnames(result)=col_name_temp
print(result)
result=as_tibble(result)
###Save the result into a csv file
write.csv(result,paste0("SAST","_",toString(NSEQ),".csv"))
###Statistical tests maybe for another time :)