Skip to content

Commit

Permalink
Add support for SCRIPT_ARG_FMT
Browse files Browse the repository at this point in the history
  • Loading branch information
HenrikBengtsson committed Apr 30, 2024
1 parent 38ff421 commit 396dbc7
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 59 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ check-api/seguid-r:
$(MAKE) check-api SCRIPT_CALL="Rscript --no-init-file" SCRIPT_PREAMBLE="library(seguid)" SCRIPT_PRINT_FMT="cat(%s)" SCRIPT_ARGS_SEP=", "

check-api/seguid-tcl:
$(MAKE) check-api SCRIPT_CALL="tclsh" SCRIPT_PREAMBLE="source ../src/base64.tcl; source ../src/sha1.tcl; source ../src/seguid.tcl;" SCRIPT_PRINT_FMT="puts stdout [%s]" SCRIPT_ARGS_SEP=" " SCRIPT_CALL_FMT="%s %s"
$(MAKE) check-api SCRIPT_CALL="tclsh" SCRIPT_PREAMBLE="source ../src/base64.tcl; source ../src/sha1.tcl; source ../src/seguid.tcl;" SCRIPT_PRINT_FMT="puts stdout [%s]" SCRIPT_ARG_FMT='"%s"' SCRIPT_ARGS_SEP=" " SCRIPT_CALL_FMT="%s %s"

check-api/ALL: check-api/seguid-python check-api/seguid-r
4 changes: 2 additions & 2 deletions tests-api/20.seguid-v1.bats
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ setup() {
## SEGUID v1
## --------------------------------------------------------
@test "seguid('ACGT')" {
run api_call "seguid" "'ACGT'"
run api_call "seguid" "ACGT"
assert_success
assert_output "seguid=IQiZThf2zKn/I1KtqStlEdsHYDQ"
}

@test "seguid('A')" {
run api_call "seguid" "'A'"
run api_call "seguid" "A"
assert_success
assert_output "seguid=bc1M4j2I4u6VaLpUbAB8Y9kTHBs"
}
68 changes: 34 additions & 34 deletions tests-api/40.seguid-v2.bats
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ setup() {
## lsseguid()
## --------------------------------------------------------
@test "lsseguid('ACGT')" {
run api_call "lsseguid" "'ACGT'"
run api_call "lsseguid" "ACGT"
assert_success
assert_output "lsseguid=IQiZThf2zKn_I1KtqStlEdsHYDQ"
}

@test "lsseguid('A') (single-symbol input)" {
run api_call "lsseguid" "'A'"
run api_call "lsseguid" "A"
assert_success
assert_output "lsseguid=bc1M4j2I4u6VaLpUbAB8Y9kTHBs"
}
Expand All @@ -27,38 +27,38 @@ setup() {
## ldsseguid()
## --------------------------------------------------------
@test "ldseguid('AACGT', 'ACGTT')" {
run api_call "ldseguid" "'AACGT'" "'ACGTT'"
run api_call "ldseguid" "AACGT" "ACGTT"
assert_success
assert_output "ldseguid=5fHMG19IbYxn7Yr7_sOCkvaaw7U"
}

@test "ldseguid('ACGTT', 'AACGT' (strand symmetry)" {
truth=$(api_call "ldseguid" "'AACGT', 'ACGTT'")
run api_call "ldseguid" "'ACGTT', 'AACGT'"
truth=$(api_call "ldseguid" "AACGT', 'ACGTT")
run api_call "ldseguid" "ACGTT', 'AACGT"
assert_success
assert_output "${truth}"
}

@test "ldseguid('-CGT', 'ACGT')" {
run api_call "ldseguid" "'-CGT'" "'ACGT'"
run api_call "ldseguid" "-CGT" "ACGT"
assert_success
assert_output "ldseguid=PVID4ZDkJEzFu2w2RLBCMQdZgvE"
}

@test "ldseguid('-CGT', '-CGT')" {
run api_call "ldseguid" "'-CGT'" "'-CGT'"
run api_call "ldseguid" "-CGT" "-CGT"
assert_success
assert_output "ldseguid=s_nCUnQCNz7NjQQTOBmoqIvXexA"
}

@test "ldseguid('--TTACA', '-GTAATC')" {
run api_call "ldseguid" "'--TTACA'" "'-GTAATC'"
run api_call "ldseguid" "--TTACA" "-GTAATC"
assert_success
assert_output "ldseguid=4RNiS6tZ_3dnHmqD_15_83vEqKQ"
}

@test "ldseguid('A', 'T') (single-symbol input)" {
run api_call "ldseguid" "'A'" "'T'"
run api_call "ldseguid" "A" "T"
assert_success
assert_output "ldseguid=ydezQsYTZgUCcb3-adxMaq_Xf8g"
}
Expand All @@ -68,27 +68,27 @@ setup() {
## csseguid()
## --------------------------------------------------------
@test "csseguid('ACGT')" {
run api_call "csseguid" "'ACGT'"
run api_call "csseguid" "ACGT"
assert_success
assert_output "csseguid=IQiZThf2zKn_I1KtqStlEdsHYDQ"
}

@test "csseguid('CGTA') (rotation invariant)" {
truth=$(api_call "csseguid" "'ACGT'")
run api_call "csseguid" "'CGTA'"
truth=$(api_call "csseguid" "ACGT")
run api_call "csseguid" "CGTA"
assert_success
assert_output "${truth}"
}

@test "csseguid('GTAC') (rotation invariant)" {
truth=$(api_call "csseguid" "'ACGT'")
run api_call "csseguid" "'GTAC'"
truth=$(api_call "csseguid" "ACGT")
run api_call "csseguid" "GTAC"
assert_success
assert_output "${truth}"
}

@test "csseguid('A') (single-symbol input)" {
run api_call "csseguid" "'A'"
run api_call "csseguid" "A"
assert_success
assert_output "csseguid=bc1M4j2I4u6VaLpUbAB8Y9kTHBs"
}
Expand All @@ -98,33 +98,33 @@ setup() {
## cdseguid()
## --------------------------------------------------------
@test "cdseguid('AACGT', 'ACGTT')" {
run api_call "cdseguid" "'AACGT'" "'ACGTT'"
run api_call "cdseguid" "AACGT" "ACGTT"
assert_success
assert_output "cdseguid=5fHMG19IbYxn7Yr7_sOCkvaaw7U"
}

@test "cdseguid('CGTAA', 'TTACG') (rotation invariant)" {
run api_call "cdseguid" "'CGTAA'" "'TTACG'"
run api_call "cdseguid" "CGTAA" "TTACG"
assert_success
assert_output "cdseguid=5fHMG19IbYxn7Yr7_sOCkvaaw7U"
}

@test "cdseguid('GTAAC', 'GTTAC') (rotation invariant)" {
truth=$(api_call "cdseguid" "'CGTAA'" "'TTACG'")
run api_call "cdseguid" "'GTAAC'" "'GTTAC'"
truth=$(api_call "cdseguid" "CGTAA" "TTACG")
run api_call "cdseguid" "GTAAC" "GTTAC"
assert_success
assert_output "${truth}"
}

@test "cdseguid('GTTAC', 'GTAAC') (strand symmetry)" {
truth=$(api_call "cdseguid" "'CGTAA'" "'TTACG'")
run api_call "cdseguid" "'GTTAC'" "'GTAAC'"
truth=$(api_call "cdseguid" "CGTAA" "TTACG")
run api_call "cdseguid" "GTTAC" "GTAAC"
assert_success
assert_output "${truth}"
}

@test "cdseguid('A', 'T') (single-symbol input)" {
run api_call "cdseguid" "'A'" "'T'"
run api_call "cdseguid" "A" "T"
assert_success
assert_output "cdseguid=ydezQsYTZgUCcb3-adxMaq_Xf8g"
}
Expand All @@ -135,7 +135,7 @@ setup() {
## Alphabet: DNA
## --------------------------------------------------------
@test "seguid('ACGT', '{DNA}')" {
run api_call "seguid" "'ACGT'" "'{DNA}'"
run api_call "seguid" "ACGT" "{DNA}"
assert_success
assert_output "seguid=IQiZThf2zKn/I1KtqStlEdsHYDQ"
}
Expand All @@ -145,31 +145,31 @@ setup() {
## Alphabet: RNA
## --------------------------------------------------------
@test "seguid('ACGU', '{RNA}')" {
run api_call "seguid" "'ACGU'" "'{RNA}'"
run api_call "seguid" "ACGU" "{RNA}"
assert_success
assert_output "seguid=LLaWk2Jb8NGt20QXhgm+cSVat34"
}

@test "lsseguid('ACGU', '{RNA}')" {
run api_call "lsseguid" "'ACGU'" "'{RNA}'"
run api_call "lsseguid" "ACGU" "{RNA}"
assert_success
assert_output "lsseguid=LLaWk2Jb8NGt20QXhgm-cSVat34"
}

@test "csseguid('ACGU', '{RNA}')" {
run api_call "csseguid" "'ACGU'" "'{RNA}'"
run api_call "csseguid" "ACGU" "{RNA}"
assert_success
assert_output "csseguid=LLaWk2Jb8NGt20QXhgm-cSVat34"
}

@test "ldseguid('AACGU', 'ACGUU', '{RNA}')" {
run api_call "ldseguid" "'AACGU'" "'ACGUU'" "'{RNA}'"
run api_call "ldseguid" "AACGU" "ACGUU" "{RNA}"
assert_success
assert_output "ldseguid=x5iCPrq2tytNXOWgZroz1u6AN2Y"
}

@test "cdseguid('AACGU', 'ACGUU', '{RNA}')" {
run api_call "cdseguid" "'AACGU'" "'ACGUU'" "'{RNA}'"
run api_call "cdseguid" "AACGU" "ACGUU" "{RNA}"
assert_success
assert_output "cdseguid=x5iCPrq2tytNXOWgZroz1u6AN2Y"
}
Expand All @@ -180,19 +180,19 @@ setup() {
## --------------------------------------------------------
## Source: http://bioinformatics.anl.gov/seguid/ftp.aspx
@test "seguid('PQITLWQRPIATIKVGGQLKEALLDTGADDTVLEEMNLPGRWKPKLIGGIGGFVKVRQYDQIPIEICGHQAIGTVLVGPTPANIIGRNLLTQIGCTLNF', '{protein}')" {
run api_call "seguid" "'PQITLWQRPIATIKVGGQLKEALLDTGADDTVLEEMNLPGRWKPKLIGGIGGFVKVRQYDQIPIEICGHQAIGTVLVGPTPANIIGRNLLTQIGCTLNF'" "'{protein}'"
run api_call "seguid" "PQITLWQRPIATIKVGGQLKEALLDTGADDTVLEEMNLPGRWKPKLIGGIGGFVKVRQYDQIPIEICGHQAIGTVLVGPTPANIIGRNLLTQIGCTLNF" "{protein}"
assert_success
assert_output "seguid=N4/z+gxAPfkFozbb3f3vStDB/5g"
}

@test "seguid('MTEYKLVVVGAGGVGKSALTIQLTQNHFVDEYDPTIE', '{protein}')" {
run api_call "seguid" "'MTEYKLVVVGAGGVGKSALTIQLTQNHFVDEYDPTIE'" "'{protein}'"
run api_call "seguid" "MTEYKLVVVGAGGVGKSALTIQLTQNHFVDEYDPTIE" "{protein}"
assert_success
assert_output "seguid=PdwDBhhFjE6qlPmSWCJCOjKIDeA"
}

@test "seguid('ARDNAKNTLYLQMSRLRSEDTAMYYCAR', '{protein}')" {
run api_call "seguid" "'ARDNAKNTLYLQMSRLRSEDTAMYYCAR'" "'{protein}'"
run api_call "seguid" "ARDNAKNTLYLQMSRLRSEDTAMYYCAR" "{protein}"
assert_success
assert_output "seguid=IdtGC8ZYgDbkA0i4u4n0tiAQwng"
}
Expand All @@ -203,19 +203,19 @@ setup() {
## Output forms
## --------------------------------------------------------
@test "seguid('ACGT', '{DNA}', 'long')" {
run api_call "seguid" "'ACGT'" "'{DNA}'" "'long'"
run api_call "seguid" "ACGT" "{DNA}" "long"
assert_success
assert_output "seguid=IQiZThf2zKn/I1KtqStlEdsHYDQ"
}

@test "seguid('ACGT', '{DNA}', 'short')" {
run api_call "seguid" "'ACGT'" "'{DNA}'" "'short'"
run api_call "seguid" "ACGT" "{DNA}" "short"
assert_success
assert_output "IQiZTh"
}

@test "seguid('ACGT', '{DNA}', 'both')" {
run api_call "seguid" "'ACGT'" "'{DNA}'" "'both'"
run api_call "seguid" "ACGT" "{DNA}" "both"
assert_success
assert_output "IQiZTh seguid=IQiZThf2zKn/I1KtqStlEdsHYDQ"
}
16 changes: 8 additions & 8 deletions tests-api/60.alphabets-custom.bats
Original file line number Diff line number Diff line change
Expand Up @@ -12,54 +12,54 @@ setup() {
## Alphabet: custom
## --------------------------------------------------------
@test "seguid('ACGU', 'AU,CG')" {
run api_call "seguid" "'ACGU'" "'AU,CG'"
run api_call "seguid" "ACGU" "AU,CG"
assert_success
assert_output "seguid=LLaWk2Jb8NGt20QXhgm+cSVat34"
}

@test "seguid('ACGT', 'AT,CG')" {
run api_call "seguid" "'ACGT'" "'AT,CG'"
run api_call "seguid" "ACGT" "AT,CG"
assert_success
assert_output "seguid=IQiZThf2zKn/I1KtqStlEdsHYDQ"
}

@test "seguid('ARDNAKNTLYLQMSRLRSEDTAMYYCAR', 'A,C,D,E,F,G,H,I,K,L,M,N,P,Q,R,S,T,V,W,Y')" {
run api_call "seguid" "'ARDNAKNTLYLQMSRLRSEDTAMYYCAR'" "'A,C,D,E,F,G,H,I,K,L,M,N,P,Q,R,S,T,V,W,Y'"
run api_call "seguid" "ARDNAKNTLYLQMSRLRSEDTAMYYCAR" "A,C,D,E,F,G,H,I,K,L,M,N,P,Q,R,S,T,V,W,Y"
assert_success
assert_output "seguid=IdtGC8ZYgDbkA0i4u4n0tiAQwng"
}

# Expanded epigenetic alphabet per Viner et al. (2024)
@test "lsseguid('AmT2C', '{DNA},m1,h2,f3,c4')" {
run api_call "lsseguid" "'AmT2C'" "'{DNA},m1,h2,f3,c4'"
run api_call "lsseguid" "AmT2C" "{DNA},m1,h2,f3,c4"
assert_success
assert_output "lsseguid=MW4Rh3lGY2mhwteaSKh1-Kn2fGA"
}

# Expanded epigenetic alphabet per Viner et al. (2024)
@test "ldseguid('AmT2C', 'GhA1T', '{DNA},m1,h2,f3,c4')" {
run api_call "ldseguid" "'AmT2C'" "'GhA1T'" "'{DNA},m1,h2,f3,c4'"
run api_call "ldseguid" "AmT2C" "GhA1T" "{DNA},m1,h2,f3,c4"
assert_success
assert_output "ldseguid=bFZedILTms4ORUi3SSMfU0FUl7Q"
}

# Ambigous expanded epigenetic alphabet per Viner et al. (2024)
@test "ldseguid('AAAhyAmA', 'T1T82TTT', '{DNA},m1,h2,f3,c4,w6,x7,y8,z9')" {
run api_call "ldseguid" "'AAAhyAmA'" "'T1T82TTT'" "'{DNA},m1,h2,f3,c4,w6,x7,y8,z9'"
run api_call "ldseguid" "AAAhyAmA" "T1T82TTT" "{DNA},m1,h2,f3,c4,w6,x7,y8,z9"
assert_success
assert_output "ldseguid=7-4HH4Evl9RhN0OzTK18QPoqjWo"
}

# Non-bijective complementary alphabets
@test "seguid('ACGTU', '{DNA},AU')" {
run api_call "seguid" "'ACGTU'" "'{DNA},AU'"
run api_call "seguid" "ACGTU" "{DNA},AU"
assert_success
assert_output "seguid=w13LHbo0Y8FHo+vaowojJkwh9nY"
}

# Non-bijective complementary alphabets
@test "ldseguid('AAT', 'AUT', '{DNA},AU')" {
run api_call "ldseguid" "'AAT'" "'AUT'" "'{DNA},AU'"
run api_call "ldseguid" "AAT" "AUT" "{DNA},AU"
assert_success
assert_output "ldseguid=fHXyliATc43ySIxHY2Zjlepnupo"
}
16 changes: 8 additions & 8 deletions tests-api/80.locales.bats
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ setup() {
local alphabet seq truth
seq="0A"
alphabet="0,A"
truth=$(api_call "lsseguid" "'${seq}'" "'${alphabet}'")
truth=$(api_call "lsseguid" "${seq}" "${alphabet}")
truth=${truth/lsseguid=/csseguid=}
echo "truth=${truth:?}"
locale -a | grep "${LC_COLLATE}"
echo "LC_COLLATE=${LC_COLLATE:-<not set>}"
run api_call "csseguid" "'${seq}'" "'${alphabet}'"
run api_call "csseguid" "${seq}" "${alphabet}"
assert_success
assert_output --partial "${truth}"
}
Expand All @@ -29,12 +29,12 @@ setup() {
local alphabet seq truth
seq="0a"
alphabet="0,a"
truth=$(api_call "lsseguid" "'${seq}'" "'${alphabet}'")
truth=$(api_call "lsseguid" "${seq}" "${alphabet}")
truth=${truth/lsseguid=/csseguid=}
echo "truth=${truth:?}"
locale -a | grep "${LC_COLLATE}"
echo "LC_COLLATE=${LC_COLLATE:-<not set>}"
run api_call "csseguid" "'${seq}'" "'${alphabet}'"
run api_call "csseguid" "${seq}" "${alphabet}"
assert_success
assert_output --partial "${truth}"
}
Expand All @@ -43,12 +43,12 @@ setup() {
local alphabet seq truth
seq="Aa"
alphabet="A,a"
truth=$(api_call "lsseguid" "'${seq}'" "'${alphabet}'")
truth=$(api_call "lsseguid" "${seq}" "${alphabet}")
truth=${truth/lsseguid=/csseguid=}
echo "truth=${truth:?}"
locale -a | grep "${LC_COLLATE}"
echo "LC_COLLATE=${LC_COLLATE:-<not set>}"
run api_call "csseguid" "'${seq}'" "'${alphabet}'"
run api_call "csseguid" "${seq}" "${alphabet}"
assert_success
assert_output --partial "${truth}"
}
Expand All @@ -57,12 +57,12 @@ setup() {
local alphabet seq truth
seq="TZ"
alphabet="T,Z"
truth=$(api_call "lsseguid" "'${seq}'" "'${alphabet}'")
truth=$(api_call "lsseguid" "${seq}" "${alphabet}")
truth=${truth/lsseguid=/csseguid=}
echo "truth=${truth:?}"
locale -a | grep "${LC_COLLATE}"
echo "LC_COLLATE=${LC_COLLATE:-<not set>}"
run api_call "csseguid" "'${seq}'" "'${alphabet}'"
run api_call "csseguid" "${seq}" "${alphabet}"
assert_success
assert_output --partial "${truth}"
}
Loading

0 comments on commit 396dbc7

Please sign in to comment.