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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721
|
#!/bin/bash
test -e ssshtest || wget -q https://raw.githubusercontent.com/ryanlayer/ssshtest/master/ssshtest
. ssshtest
set -e
cd seqkit; go build; cd ..;
app=./seqkit/seqkit
set +e
which csvtk || (git clone --depth 1 https://github.com/shenwei356/csvtk; cd ./csvtk/csvtk; go get -v ... ; go build)
CSVTK=csvtk
which csvtk || CSVTK=./csvtk/csvtk/csvtk; true
STOP_ON_FAIL=1
md5sum () {
openssl dgst -sha256 $1 | cut -d $' ' -f 2;
}
# ------------------------------------------------------------
# seq
# ------------------------------------------------------------
file=tests/hairpin.fa
# seq content
run seq_content $app seq -w 60 $file
# seq number
assert_equal $(grep -c "^>" $file) $(grep -c "^>" $STDOUT_FILE)
# seq content
assert_equal $(cat $file | md5sum | cut -d" " -f 1) $(cat $STDOUT_FILE | md5sum | cut -d" " -f 1)
# ------------------------------------------------------------
# seq type
run seq_type $app seq -t dna $file
assert_in_stderr "invalid DNAredundant letter"
fun() {
echo -e ">seq\nabcdefghijklmnpqrstvwyz" | $app stat
}
run seq_type fun
assert_in_stdout "Protein"
fun() {
echo -e ">seq\nACGUN ACGUN" | $app stat
}
run seq_type fun
assert_in_stdout "RNA"
fun() {
echo -e ">seq\nacgtryswkmbdhvACGTRYSWKMBDHV" | $app stat
}
run seq_type fun
assert_in_stdout "DNA"
fun() {
echo -e "@read\nACTGCN\n+\n@IICCG" | $app stat
}
run seq_type fun
assert_in_stdout "DNA"
assert_in_stdout "FASTQ"
# ------------------------------------------------------------
# head
run seq_head $app seq -n $file
assert_equal $(cat $STDOUT_FILE | md5sum | cut -d" " -f 1) $(grep "^>" $file | sed 's/^>//g' | md5sum | cut -d" " -f 1)
# id
run seq_id $app seq -n -i $file
assert_equal $(cat $STDOUT_FILE | md5sum | cut -d" " -f 1) $(grep "^>" $file | sed 's/^>//g' | sed 's/ .*//g' | md5sum | cut -d" " -f 1)
# seq
run seq_seq $app seq $file -s -w 0
assert_equal $(cat $STDOUT_FILE | md5sum | cut -d" " -f 1) $($app fx2tab $file | cut -f 2 | md5sum | cut -d" " -f 1)
# ------------------------------------------------------------
file=tests/hairpin.fa
# reverse complement
fun() {
$app head -n 1 $file | $app seq -r | $app seq -p
}
run seq_revcom fun
assert_equal $(cat $STDOUT_FILE | md5sum | cut -d" " -f 1) $($app head -n 1 $file | $app seq -r -p | md5sum | cut -d" " -f 1)
# remove gaps
fun() {
echo -e ">seq\nACGT-ACTGC-ACC" | $app seq -g -l
}
run seq_rmgap_lowercapse fun
assert_in_stdout "acgtactgcacc"
# rna2dna
fun() {
echo -e ">seq\nUCAUAUGCUUGUCUCAAAGAUUA" | $app seq --rna2dna
}
run seq_rna2dna fun
assert_in_stdout "TCATATGCTTGTCTCAAAGATTA"
# ------------------------------------------------------------
# subseq
# ------------------------------------------------------------
testseq() {
echo -e ">seq\nacgtnACGTN"
}
# by region
fun () {
testseq | $app subseq -r 1:1 | $app seq -s -w 0
}
run subseq_region fun
assert_equal a $(cat $STDOUT_FILE)
fun () {
testseq | $app subseq -r 1:-1 | $app seq -s -w 0
}
run subseq_region fun
assert_equal acgtnACGTN $(cat $STDOUT_FILE)
fun () {
testseq | $app subseq -r 3:5 | $app seq -s -w 0
}
run subseq_region fun
assert_equal gtn $(cat $STDOUT_FILE)
fun () {
testseq | $app subseq -r -5:-3 | $app seq -s -w 0
}
run subseq_region fun
assert_equal ACG $(cat $STDOUT_FILE)
fun () {
testseq | $app subseq -r -1:-1 | $app seq -s -w 0
}
run subseq_region fun
assert_equal N $(cat $STDOUT_FILE)
# ------------------------------------------------------------
# gtf
# seq=">seq\nacgtnACGTN"
gtf="seq\ttest\tCDS\t4\t6\t.\t+\t.\tgene_id \"A\"; transcript_id \"A\"\nseq\ttest\tCDS\t4\t6\t.\t-\t.\tgene_id \"B\"; transcript_id \"B\"\n"
fun () {
testseq | $app subseq --gtf <(echo -ne $gtf) | $app seq -s -w 0
}
run subseq_gtf fun
assert_equal $(echo -e "tnA\nTna" | md5sum | cut -d" " -f 1) $(cat $STDOUT_FILE | md5sum | cut -d" " -f 1)
fun () {
testseq | $app subseq --gtf <(echo -ne $gtf) -u 3 -d 2 | $app seq -s -w 0
}
run subseq_gtf fun
assert_equal $(echo -e "acgtnACG\nACGTnacg" | md5sum | cut -d" " -f 1) $(cat $STDOUT_FILE | md5sum | cut -d" " -f 1)
fun () {
testseq | $app subseq --gtf <(echo -ne $gtf) -u 100 -d 100 | $app seq -s -w 0
}
run subseq_gtf fun
assert_equal $(echo -e "acgtnACGTN\nNACGTnacgt" | md5sum | cut -d" " -f 1) $(cat $STDOUT_FILE | md5sum | cut -d" " -f 1)
fun () {
testseq | $app subseq --gtf <(echo -ne $gtf) -u 3 -f | $app seq -s -w 0
}
run subseq_gtf fun
assert_equal $(echo -e "acg\nACG" | md5sum | cut -d" " -f 1) $(cat $STDOUT_FILE | md5sum | cut -d" " -f 1)
# ------------------------------------------------------------
# sliding
# ------------------------------------------------------------
testseq() {
echo -e ">seq\nacgtnACGTN"
}
fun () {
testseq | $app sliding -W 5 -s 5 | $app seq -s -w 0
}
run sliding fun
assert_equal $(echo -e "acgtn\nACGTN" | md5sum | cut -d" " -f 1) $(cat $STDOUT_FILE | md5sum | cut -d" " -f 1)
# ------------------------------------------------------------
# fq2fa, fx2tab, tab2fx
# ------------------------------------------------------------
file=tests/hairpin.fa
fun () {
$app fx2tab $file | $app tab2fx
}
run fx2tab_tab2fx fun
assert_equal $(cat $STDOUT_FILE | md5sum | cut -d" " -f 1) $($app seq $file | md5sum | cut -d" " -f 1)
file=tests/reads_1.fq.gz
run fq2fa $app fq2fa $file
assert_equal $(cat $STDOUT_FILE | md5sum | cut -d" " -f 1) $($app fx2tab $file | cut -f 1,2 | $app tab2fx -w 0 | md5sum | cut -d" " -f 1)
READS_FQ=tests/pcs109_5k.fq
NANO_FQ_TSV=tests/pcs109_5k_fq_NanoPlot.tsv
float_gt(){
CODE=$(awk 'BEGIN {PREC="double"; print ("'$1'" >= "'$2'")}')
return $CODE
}
fun () {
echo -e "Len\tQual" > seqkit.tsv
$app fx2tab -q -l $READS_FQ | cut -f 4,5 >> seqkit.tsv
paste seqkit.tsv $NANO_FQ_TSV > joint.tsv
$CSVTK corr -t -f Len,lengths joint.tsv 2> corr_len.tsv
$CSVTK corr -t -f Qual,quals joint.tsv 2> corr_qual.tsv
}
run fx2tab_qual_len fun
RL=$(cut -f 3 corr_len.tsv)
echo Length correlation: $RL
float_gt $RL 0.99
assert_equal $? 1
RL=$(cut -f 3 corr_len.tsv)
echo Length correlation: $RL
float_gt $RL 0.99
assert_equal $? 1
RQ=$(cut -f 3 corr_len.tsv)
echo Qual correlation: $RQ
float_gt $RQ 0.99
assert_equal $? 1
rm seqkit.tsv corr_len.tsv corr_qual.tsv
# ------------------------------------------------------------
# grep
# ------------------------------------------------------------
file=tests/hairpin.fa
# by regexp
run grep_by_regexp $app grep -r -p "^hsa" $file
assert_equal $(cat $STDOUT_FILE | md5sum | cut -d" " -f 1) $($app fx2tab $file | grep -E "^hsa" | $app tab2fx | md5sum | cut -d" " -f 1)
# by list
$app fx2tab -n $file -i | cut -f 1 > list
run grep_by_list_all $app grep -f list $file
assert_equal $(cat $STDOUT_FILE | md5sum | cut -d" " -f 1) $(md5sum $file | cut -d" " -f 1)
rm list
cat $file | $app head -n 100 | $app seq -n -i > list
run grep_by_list_head100 $app grep -f list $file
assert_equal $($app fx2tab $STDOUT_FILE | wc -l) 100
rm list
echo -en "Homo\nMus\n" > list
run grep_by_regexp_list $app grep -r -n -f list $file
assert_equal $($app fx2tab $STDOUT_FILE | wc -l) $($app seq -n $file | grep -E "Homo|Mus" | wc -l)
rm list
# ------------------------------------------------------------
# locate
# ------------------------------------------------------------
# ------------------------------------------------------------
# rmdup
# ------------------------------------------------------------
testseq() {
echo -e ">seq\nacgtnACGTN"
}
repeated_seq() {
for i in $(seq 10); do
testseq
done
}
fun() {
repeated_seq | $app rmdup
}
run rmdup fun
assert_in_stderr "9 duplicated records removed"
assert_equal $(cat $STDOUT_FILE | md5sum | cut -d" " -f 1) $(testseq | md5sum | cut -d" " -f 1)
fun() {
repeated_seq | $app rmdup -s
}
run "rmdup -s" fun
assert_in_stderr "9 duplicated records removed"
assert_equal $(cat $STDOUT_FILE | md5sum | cut -d" " -f 1) $(testseq | md5sum | cut -d" " -f 1)
# ------------------------------------------------------------
# common
# ------------------------------------------------------------
file=tests/hairpin.fa
$app rmdup $file > t.1
$app sample t.1 -p 0.1 > t.2
fun() {
$app common t.1 t.2 > t.c
}
run common fun
assert_equal $(cat t.c | $app stat -a | md5sum | cut -d" " -f 1) $(cat t.2 | $app stat -a | md5sum | cut -d" " -f 1)
rm t.*
# ------------------------------------------------------------
# split
# ------------------------------------------------------------
file=tests/hairpin.fa
testseq() {
cat $file | $app head -n 100 | $app rmdup
}
fun() {
testseq | $app split -i -f
}
run split fun
assert_equal $(ls stdin.split/* | wc -l | tail -n 1) $(testseq | $app seq -n -i | wc -l | tail -n 1)
assert_equal $(cat stdin.split/* | $app stat -a | md5sum | cut -d" " -f 1) $(testseq | $app stat -a | md5sum | cut -d" " -f 1)
rm -r stdin.split
# ------------------------------------------------------------
# sample
# ------------------------------------------------------------
file=tests/hairpin.fa
assert_equal $(cat $file | $app sample -p 0.1 | $app stat -a | md5sum | cut -d" " -f 1) $(cat $file | $app sample -p 0.1 | $app stat -a | md5sum | cut -d" " -f 1)
# ------------------------------------------------------------
# head
# ------------------------------------------------------------
run head $app head -n 10 $file
assert_equal 10 $(grep -c ">" $STDOUT_FILE)
# ------------------------------------------------------------
# replace
# ------------------------------------------------------------
testseq() {
echo -e ">seq\nacgtnACGTN"
}
assert_equal $(testseq | $app replace -p e -r n | $app seq -n -i) snq
# ------------------------------------------------------------
# rename
# ------------------------------------------------------------
testseq() {
echo -e ">seq\na\n>seq\nc"
}
assert_equal $(testseq | $app rename | $app seq -n -i | tail -n 1) seq_2
# ------------------------------------------------------------
# restart
# ------------------------------------------------------------
testseq() {
echo -e ">seq\nacgtnACGTN"
}
fun(){
testseq | $app restart -i 6
}
run restart fun
assert_equal $(cat $STDOUT_FILE | $app seq -s) "ACGTNacgtn"
fun(){
testseq | $app restart -i -5
}
run restart2 fun
assert_equal $(cat $STDOUT_FILE | $app seq -s) "ACGTNacgtn"
# ------------------------------------------------------------
# shuffle and sort
# ------------------------------------------------------------
file=tests/hairpin.fa
fun(){
$app seq $file > t.shu.0
$app shuffle -s 1 $file > t.shu.1
$app shuffle -s 1 $file > t.shu.2
$app sort -l $file > t.sort.l
$app sort -n $file > t.sort.n
$app sort -s $file > t.sort.s
}
run shuffle fun
assert_equal $(cat t.shu.1 | $app stat -a | md5sum | cut -d" " -f 1) $(cat t.shu.0 | $app stat -a | md5sum | cut -d" " -f 1)
assert_equal $(cat t.shu.1 | md5sum | cut -d" " -f 1) $(cat t.shu.2 | md5sum | cut -d" " -f 1)
rm t.shu.*
assert_equal $(cat $file | $app stat -a | md5sum | cut -d" " -f 1) $(cat t.sort.l | $app stat -a | md5sum | cut -d" " -f 1)
assert_equal $(cat $file | $app stat -a | md5sum | cut -d" " -f 1) $(cat t.sort.n | $app stat -a | md5sum | cut -d" " -f 1)
assert_equal $(cat $file | $app stat -a | md5sum | cut -d" " -f 1) $(cat t.sort.s | $app stat -a | md5sum | cut -d" " -f 1)
rm t.sort.*
#-------------------------------------------------------------
# bam
#-------------------------------------------------------------
BAM=tests/pcs109_5k.bam
PRIM_BAM=tests/pcs109_5k_prim.bam
SPLICE_BAM=tests/pcs109_5k_spliced.bam
PRIM_NANOPLOT=tests/pcs109_5k_prim_bam_NanoPplot.tsv
PRIM_WUB=tests/pcs109_5k_bam_alignment_length.tsv
WUB_CLIP=tests/pcs109_5k_bam_soft_clips_tab.tsv
PCS_FQ=tests/pcs109_5k.fq
float_gt(){
CODE=$(awk 'BEGIN {PREC="double"; print ("'$1'" >= "'$2'")}')
return $CODE
}
# accuracy
fun(){
$app bam -f Read,Acc $PRIM_BAM 2> seqkit_acc.tsv
paste seqkit_acc.tsv $PRIM_NANOPLOT > joint.tsv
$CSVTK corr -t -f Acc,percentIdentity joint.tsv 2> corr.tsv
}
run bam_acc fun
R=$(cut -f 3 corr.tsv)
echo Correlation: $R
float_gt $R 0.99
assert_equal $? 1
rm corr.tsv seqkit_acc.tsv joint.tsv
# MeanQual
fun(){
$app bam -f Read,MeanQual $PRIM_BAM 2> seqkit.tsv
paste seqkit.tsv $PRIM_NANOPLOT > joint.tsv
$CSVTK corr -t -f MeanQual,quals joint.tsv 2> corr.tsv
}
run bam_mean_qual fun
R=$(cut -f 3 corr.tsv)
echo Correlation: $R
float_gt $R 0.99
assert_equal $? 1
rm corr.tsv seqkit.tsv joint.tsv
# MapQual
fun(){
$app bam -f Read,MapQual $PRIM_BAM 2> seqkit.tsv
paste seqkit.tsv $PRIM_NANOPLOT > joint.tsv
$CSVTK corr -t -f MapQual,mapQ joint.tsv 2> corr.tsv
}
run bam_map_qual fun
R=$(cut -f 3 corr.tsv)
echo Correlation: $R
float_gt $R 0.99
assert_equal $? 1
rm corr.tsv seqkit.tsv joint.tsv
# ReadLen
fun(){
$app bam -f Read,ReadLen $PRIM_BAM 2> seqkit.tsv
paste seqkit.tsv $PRIM_NANOPLOT > joint.tsv
$CSVTK corr -t -f ReadLen,lengths joint.tsv 2> corr.tsv
}
run bam_read_len fun
R=$(cut -f 3 corr.tsv)
echo Correlation: $R
float_gt $R 0.99
assert_equal $? 1
rm corr.tsv seqkit.tsv joint.tsv
# ReadAln
fun(){
$app bam -f Read,ReadAln $PRIM_BAM 2> seqkit.tsv
paste seqkit.tsv $PRIM_NANOPLOT > joint.tsv
$CSVTK corr -t -f ReadAln,aligned_lengths joint.tsv 2> corr.tsv
}
run bam_read_aln fun
R=$(cut -f 3 corr.tsv)
echo Correlation: $R
float_gt $R 0.99
assert_equal $? 1
rm corr.tsv seqkit.tsv joint.tsv
# LeftClip
fun(){
$app bam -f Read,LeftClip $PRIM_BAM 2> seqkit.tsv
paste seqkit.tsv $WUB_CLIP > joint.tsv
head -1 joint.tsv > TMP
grep "\+" joint.tsv >> TMP
mv TMP joint.tsv
$CSVTK corr -t -f LeftClip,ClipStart joint.tsv 2> corr.tsv
}
run bam_left_clip fun
R=$(cut -f 3 corr.tsv)
echo Correlation: $R
float_gt $R 0.99
assert_equal $? 1
rm corr.tsv seqkit.tsv joint.tsv
# RightClip
fun(){
$app bam -f Read,RightClip $PRIM_BAM 2> seqkit.tsv
paste seqkit.tsv $WUB_CLIP > joint.tsv
head -1 joint.tsv > TMP
grep "\+" joint.tsv >> TMP
mv TMP joint.tsv
$CSVTK corr -t -f RightClip,ClipEnd joint.tsv 2> corr.tsv
}
run bam_right_clip fun
R=$(cut -f 3 corr.tsv)
echo Correlation: $R
float_gt $R 0.99
assert_equal $? 1
rm corr.tsv seqkit.tsv joint.tsv
# bundling with -N
fun(){
rm -fr tests/bundler_test tests/bundler_merged.bam
$app bam -N -1 $SPLICE_BAM -o tests/bundler_test
($app bam -s $SPLICE_BAM 2>&1) | cut -f 1,8 | sed '1d' - > tests/bundler_stats_bulk.tsv
($app bam -s tests/bundler_test/*.bam 2>&1) \
| cut -f 1,8 | sed '1d' | $CSVTK -H -t summary -w 0 -g 1 -f "2:sum" > tests/bundler_stats_merged.tsv
}
run bam_bundler fun
cmp tests/bundler_stats_merged.tsv tests/bundler_stats_bulk.tsv
assert_equal $? 0
rm -fr tests/bundler_test tests/bundler_stats_merged.tsv tests/bundler_stats_bulk.tsv
# ------------------------------------------------------------
# fish
# ------------------------------------------------------------
# Regression test for fish
fun(){
Q1="GTTGTTATGGAGGATACTTTCCTACCGTGACAAGAAAGTTGT"
Q2="GCCAGTAGACAAGTTTCTCCATCTCCGGCCTTTT"
Q3="CAGTATGCTTCGTTTCAATTTCGGGTTTGGAGTGTTTG"
Q4="TTTTATCAAAAGAAAAAAAAGAAGATAGAGCGACAGGCAAGTCACAAAGACACCGACAACTTTCTTGTCATC"
head -n 40 $PCS_FQ > TMP.fq
$app fish -q 40 -g -F "$Q1,$Q2,$Q3,$Q4" TMP.fq 2> seqkit_fish.tsv
rm TMP.fq
}
run bam_fish_regression fun
cmp seqkit_fish.tsv tests/pcs109_5k_fish_regression.tsv
assert_exit_code 0
rm seqkit_fish.tsv
# ------------------------------------------------------------
# sana
# ------------------------------------------------------------
# Regression test for sana/fasta
fun(){
awk '{print ">" $1 "\n" $2}' tests/scat_test.tsv > tests/sana_test_input.fas
$app sana -i fasta tests/sana_test_input.fas > tests/sana_output.fas
}
run sana_fasta_regression fun
cmp tests/sana_output.fas tests/sana_ground.fas
assert_equal $? 0
rm -f tests/sana_output.fas tests/sana_test_input.fas
# Regression test for sana/fastq
fun(){
awk '{print "@" $1 "\n" $2 "\n+\n" $3}' tests/scat_test.tsv > tests/sana_test_input.fq
# $app sana -i fastq tests/sana_test_input.fq > tests/sana_output.fq
$app sana tests/sana_test_input.fq > tests/sana_output.fq
}
run sana_fastq_regression_empty_line fun
cmp tests/sana_output.fq tests/sana_ground.fq
assert_equal $? 0
rm -f tests/sana_output.fq tests/sana_test_input.fq
# Regression test for sana/fasta empty file issue
fun(){
$app sana -j 2 -i fasta tests/empty.fx
}
run sana_fasta_regression_empty_line fun
assert_equal $? 0
# Regression test for sana/fastq empty file issue
fun(){
$app sana -j 2 -i fastq tests/empty.fx
}
run sana_fastq_regression fun
assert_equal $? 0
# ------------------------------------------------------------
# scat
# ------------------------------------------------------------
# Regression test for scat/fasta
fun(){
BASE=tests/scat_test_fasta
rm -fr $BASE
rm -f tests/scat_test_all.fas tests/scat_output.fas
mkdir -p $BASE
($app scat -j 4 -i fasta $BASE > tests/scat_output.fas)&
SCAT_PID=$!
BAK=$IFS
IFS=$'\n'
SIZE=2
for i in `seq 0 $SIZE`;
do
for j in `seq 0 $SIZE`;
do
D=$BASE/$RANDOM/$RANDOM
mkdir -p $D
F=$D/${RANDOM}.fas
for l in `cat tests/scat_test.tsv`;
do
PRE=".${RANDOM}.${i}.${j}"
echo -n $l | awk -v pre="$PRE" '{print ">" $1 pre "\n" $2}' - >> $F
echo -n $l | awk -v pre="$PRE" '{print ">" $1 pre "\n" $2}' - >> tests/scat_test_all.fas
sync;
done;
done;
done;
IFS=$BAK
sync; sleep 0.5
$app sana -j 4 -i fasta tests/scat_test_all.fas | $app sort -n -j 1 - > tests/sorted_scat_test_all.fas
kill -s INT $SCAT_PID
sync; sleep 0.5
wait $SCAT_PID
sync;
$app scat -f -j 4 -i fasta $BASE | $app sort -n -j 1 - > tests/sorted_scat_find.fas
$app sort -n -j 1 tests/scat_output.fas > tests/sorted_scat_output.fas
rm -fr $BASE
rm -f tests/scat_test_all.fas tests/scat_output.fas
}
run scat_fasta fun
cmp tests/sorted_scat_output.fas tests/sorted_scat_test_all.fas
assert_equal $? 0
cmp tests/sorted_scat_find.fas tests/sorted_scat_test_all.fas
assert_equal $? 0
rm -f tests/sorted_scat_output.fas tests/sorted_scat_test_all.fas tests/sorted_scat_find.fas
# Regression test for scat/fastq
fun(){
BASE=tests/scat_test_fastq
rm -fr $BASE
rm -f tests/scat_test_all.fq tests/scat_output.fq
mkdir -p $BASE
($app scat -j 4 -i fastq $BASE > tests/scat_output.fq)&
SCAT_PID=$!
BAK=$IFS
IFS=$'\n'
SIZE=2
for i in `seq 0 $SIZE`;
do
for j in `seq 0 $SIZE`;
do
D=$BASE/$RANDOM/$RANDOM
mkdir -p $D
F=$D/${RANDOM}.fq
for l in `cat tests/scat_test.tsv`;
do
PRE=".${RANDOM}.${i}.${j}"
echo -n $l | awk -v pre="$PRE" '{print "@" $1 pre "\n" $2 "\n+\n" $3}' - >> $F
echo -n $l | awk -v pre="$PRE" '{print "@" $1 pre "\n" $2 "\n+\n" $3}' - >> tests/scat_test_all.fq
done;
done;
done;
IFS=$BAK
sync; sleep 0.5
$app sana -j 4 -i fastq tests/scat_test_all.fq > tests/scat_test_all_sana.fq
kill -s INT $SCAT_PID
wait $SCAT_PID
sync; sleep 0.5
$app scat -f -j 4 -i fastq $BASE | $app sort -n -j 1 - > tests/sorted_scat_find.fq
$app sort -n -j 1 tests/scat_test_all_sana.fq > tests/sorted_scat_test_all.fq
$app sort -n -j 1 tests/scat_output.fq > tests/sorted_scat_output.fq
rm -fr $BASE
rm -f tests/scat_test_all.fq tests/scat_output.fq
}
run scat_fastq fun
cmp tests/sorted_scat_output.fq tests/sorted_scat_test_all.fq
assert_equal $? 0
cmp tests/sorted_scat_find.fq tests/sorted_scat_test_all.fq
assert_equal $? 0
rm -f tests/sorted_scat_output.fq tests/sorted_scat_test_all.fq tests/sorted_scat_find.fq tests/scat_test_all_sana.fq
# ------------------------------------------------------------
# faidx
# ------------------------------------------------------------
file=tests/hairpin.fa
idFile=tests/t.ids
outFile=tests/t.fa
$app sample -n 10 $file| $app seq -i -n | shuf > $idFile
fun(){
$app faidx $file $(paste -s -d ' ' $idFile) > $outFile
}
run faidx_id fun
assert_equal $($app grep -f $idFile $file | $app seq -i | $app sort | md5sum | cut -d" " -f 1) $(cat $outFile | $app sort | md5sum | cut -d" " -f 1)
rm $outFile
fun(){
$app faidx $file $(paste -s -d ' ' $idFile) -f > $outFile
}
run faidx_full_head fun
assert_equal $($app grep -f $idFile $file | $app sort | md5sum | cut -d" " -f 1) $(cat $outFile | $app sort | md5sum | cut -d" " -f 1)
rm $outFile
ref=$(head -n 1 $idFile)
fun(){
$app faidx $file "${ref}:5--5" -f > $outFile
}
run faidx_region fun
assert_equal $($app grep -p $ref $file | $app subseq -r 5:-5 | $app seq -s -w 0) $(cat $outFile | $app seq -s -w 0)
rm $idFile $outFile
|