Skip to content
GitLab
探索
登录
主导航
搜索或转到…
项目
P
picard
管理
动态
成员
标记
计划
议题
0
议题看板
里程碑
迭代
Wiki
代码
合并请求
0
仓库
分支
提交
标签
仓库图
比较修订版本
代码片段
锁定的文件
构建
流水线
作业
流水线计划
产物
部署
发布
软件包库
运维
环境
Terraform 模块
监控
事件
服务台
分析
价值流分析
Contributor analytics
CI/CD 分析
仓库分析
代码评审分析
议题分析
模型实验
帮助
帮助
支持
GitLab 文档
比较 GitLab 各版本
社区论坛
为极狐GitLab 提交贡献
提交反馈
快捷键
?
支持
扫描加入微信群:
1. 获取企业级DevOps解决方案支持
2. 免费或折扣极狐GitLab 官方培训认证
代码片段
群组
项目
HPCSource
picard
提交
c243e668
提交
c243e668
编辑于
5年前
作者:
Christopher Kachulis
浏览文件
操作
下载
补丁
差异文件
adding tests for BKTree
上级
e35b1115
分支
gg_UpdateTo_htsjdk_2.23.0
无相关合并请求
变更
1
隐藏空白变更内容
行内
左右并排
显示
1 个更改的文件
src/test/java/picard/util/BKTreeTest.java
+47
-0
47 个添加, 0 个删除
src/test/java/picard/util/BKTreeTest.java
有
47 个添加
和
0 个删除
src/test/java/picard/util/BKTreeTest.java
0 → 100644
+
47
−
0
浏览文件 @
c243e668
package
picard.util
;
import
org.testng.Assert
;
import
org.testng.annotations.DataProvider
;
import
org.testng.annotations.Test
;
import
java.util.*
;
import
static
org
.
testng
.
Assert
.*;
public
class
BKTreeTest
{
@DataProvider
(
name
=
"testQueryDataProvider"
)
public
Object
[][]
testQueryDataProvider
()
{
final
Set
<
String
>
dictionary
=
new
HashSet
<>(
Arrays
.
asList
(
"ACGCA"
,
"GCTCG"
,
"GGCTA"
,
"CGTCG"
,
"AGTCG"
,
"GGTCG"
,
"AACCT"
));
final
BKTree
<
String
>
tree
=
new
BKTree
<>((
s1
,
s2
)
->
StringDistanceUtils
.
countMismatches
(
new
byte
[][]{
s1
.
getBytes
()},
new
byte
[][]{
s2
.
getBytes
()},
null
,
0
));
for
(
final
String
word
:
dictionary
)
{
tree
.
insert
(
word
);
}
final
List
<
Object
[]>
tests
=
new
ArrayList
<>();
for
(
final
String
query
:
dictionary
)
{
final
Map
<
Integer
,
Set
<
String
>>
expectedResult
=
new
HashMap
<>();
expectedResult
.
put
(
0
,
new
HashSet
<>(
Collections
.
singletonList
(
query
)));
tests
.
add
(
new
Object
[]{
query
,
0
,
tree
,
new
HashMap
<>(
expectedResult
)});
if
(
query
.
equals
(
"GCTCG"
))
{
expectedResult
.
put
(
1
,
new
HashSet
<>(
Collections
.
singletonList
(
"GGTCG"
)));
}
else
if
(
query
.
equals
(
"CGTCG"
))
{
expectedResult
.
put
(
1
,
new
HashSet
<>(
Arrays
.
asList
(
"AGTCG"
,
"GGTCG"
)));
}
else
if
(
query
.
equals
(
"AGTCG"
))
{
expectedResult
.
put
(
1
,
new
HashSet
<>(
Arrays
.
asList
(
"CGTCG"
,
"GGTCG"
)));
}
else
if
(
query
.
equals
(
"GGTCG"
))
{
expectedResult
.
put
(
1
,
new
HashSet
<>(
Arrays
.
asList
(
"CGTCG"
,
"AGTCG"
,
"GCTCG"
)));
}
tests
.
add
(
new
Object
[]{
query
,
1
,
tree
,
new
HashMap
<>(
expectedResult
)});
}
return
tests
.
toArray
(
new
Object
[][]{});
}
@Test
(
dataProvider
=
"testQueryDataProvider"
)
public
void
testQuery
(
final
String
query
,
final
int
maxDist
,
final
BKTree
<
String
>
tree
,
final
Map
<
Integer
,
Set
<
String
>>
expectedResult
)
{
final
Map
<
Integer
,
LinkedList
<
String
>>
results
=
tree
.
query
(
query
,
maxDist
);
Assert
.
assertEquals
(
results
.
size
(),
expectedResult
.
size
());
for
(
final
Map
.
Entry
<
Integer
,
LinkedList
<
String
>>
matchSet
:
results
.
entrySet
())
{
Assert
.
assertEquals
(
matchSet
.
getValue
().
size
(),
expectedResult
.
get
(
matchSet
.
getKey
()).
size
());
Assert
.
assertTrue
(
expectedResult
.
get
(
matchSet
.
getKey
()).
containsAll
(
matchSet
.
getValue
()));
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
预览
0%
请重试
或
添加新附件
.
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
保存评论
取消
想要评论请
注册
或
登录