-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprogram_debug.r
More file actions
39 lines (31 loc) · 1.58 KB
/
program_debug.r
File metadata and controls
39 lines (31 loc) · 1.58 KB
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
### デバッグのためのソースコード(変更しなくてよい) ###
### TRUEと表示されればprogram.rは正しく,FALSEと表示されれば間違っている ###
## このファイルについて
## program.rファイルの中で変数is_debugをTRUEにした時に呼び出されるファイル.
## 作ったDP関数が正しく動作するかを表示する.
## このデバッグで表示される経路ごとの減点の合計を表した行列は,こちらで用意したものが表示される.
### 2つの文字列を作成 ###
Data1<-"ATAGCG"
Data2<-"ACTCGAT"
Dist<-4.25 #デバッグ用データから求められるべき距離
S<-matrix(0,4,4)
rownames(S)<-c("A","C","G","T")
colnames(S)<-c("A","C","G","T")
S[1,]<-c(0,1.25,1.25,0.75)
S[2,]<-c(1.25,0,0.75,1.25)
S[3,]<-c(1.25,0.75,0,0.75)
S[4,]<-c(0.75,1.25,0.75,0) #デバッグ用に用意した減点行列
C.true <- matrix(c(0,1,2,3,4,5,6,
1,0,1,2,3,4,5,
2,1,1.25,2.25,2.75,3,4,
3,2,1,2,3,4,3.75,
4,3,2,2.25,2.75,3,4,
5,4,3,3.25,2.25,3.25,3,
6,5,4,3,3.25,3.5,4,7,6,
5,4,3.75,4.5,4.25),7,8) #デバッグ用に用意した経路ごとの減点を示した行列
DP.result <- DP(Data1,Data2,S) #program.r中で作ったDP関数を使って動的計画法を計算
cat("true C is ","\n")
print(C.true) #正しいCを表示
cat("your C is ","\n")
print(DP.result$C) #program.rが正解なら正しいCが表示される
cat("\n","program.r is ",all(C.true==DP.result$C),"\n") #program.rが正しければTRUEと表示