Skip to content

Commit 6fbdd5a

Browse files
committed
add tests for new select
1 parent ec3dfa4 commit 6fbdd5a

1 file changed

Lines changed: 41 additions & 3 deletions

File tree

test/runtests.jl

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,7 @@ end
928928
@test length(collectatoms(struc, sel"disordered")) == 68
929929
@test length(collectatoms(struc, sel"sscode E")) == 2448
930930
@test length(collectatoms(struc, sel"helix")) == 4047
931+
931932
# Check interpolation support
932933
ss_type = "helix"
933934
@test length(collectatoms(struc, sel"$ss_type")) == 4047
@@ -942,14 +943,51 @@ end
942943
@test length(collectmodels(struc, sel"model 1")) == 1
943944
@test length(collectmodels(struc, sel"model 2")) == 0
944945

945-
@test_throws ArgumentError collectatoms(struc, BioStructures.Select("abc")) # Invalid selection syntax
946-
@test_throws ArgumentError collectatoms(struc, BioStructures.Select("index = A")) # Invalid value type
947-
@test_throws ArgumentError collectatoms(struc, BioStructures.Select("resnum C"))
946+
# Check complicated selections
947+
@test length(collectatoms(struc, sel"name CA and (resnum < 15 or resnum > 16)")) == 1404
948+
@test length(collectatoms(struc, sel"(name CA and resnum < 15) or (name N and chain A)")) == 299
949+
@test length(collectatoms(struc, sel"(not protein) and (resname HOH or (resname SOD and index < 600))")) == 639
950+
@test length(collectatoms(struc, sel"not protein and not water or (chain A and resnum < 10)")) == 79
951+
@test length(collectatoms(struc, sel"not protein and not water or (chain A and resnum <= 10)")) == 87
952+
@test length(collectatoms(struc, sel"name CA and resname ALA ARG GLU")) == 224
953+
@test length(collectatoms(struc, sel"resname ALA ARG GLU and name N")) == 224
954+
@test length(collectatoms(struc, sel"(resname ALA ARG GLU) and (name N or name CA)")) == 448
955+
@test length(collectatoms(struc, sel"index 2 3 4 5")) == 4
956+
@test length(collectatoms(struc, sel"element C")) == 7508
957+
@test length(collectatoms(struc, sel"element C N")) == 9468
958+
@test length(collectatoms(struc, sel"not protein and element C N")) == 0
959+
@test length(collectatoms(struc, sel"not protein and element O H ")) == 639
948960

949961
# Test show method for @sel_str
950962
buff = IOBuffer()
951963
show(buff, MIME"text/plain"(), sel"name CA and resnum 1")
952964
@test String(take!(buff)) == """Select("name CA and resnum 1")"""
965+
966+
# Syntax errors
967+
@test_throws ArgumentError collectatoms(struc, BioStructures.Select("abc")) # Invalid selection syntax
968+
@test_throws ArgumentError collectatoms(struc, BioStructures.Select("index = A")) # Invalid value type
969+
@test_throws ArgumentError collectatoms(struc, BioStructures.Select("resnum C"))
970+
@test_throws ArgumentError collectatoms(struc, sel"name CA and (residue 1")
971+
@test_throws ArgumentError collectatoms(struc, sel"name CA and (residue 1))")
972+
@test_throws ArgumentError collectatoms(struc, sel"index <")
973+
@test_throws ArgumentError collectatoms(struc, sel"index < 1.0")
974+
@test_throws ArgumentError collectatoms(struc, sel"indes 1")
975+
@test_throws ArgumentError collectatoms(struc, sel"element")
976+
@test_throws ArgumentError collectatoms(struc, sel"index 1 element")
977+
@test_throws ArgumentError collectatoms(struc, sel"protein 1")
978+
@test_throws ArgumentError collectatoms(struc, sel"protein = 1")
979+
@test_throws ArgumentError collectatoms(struc, sel"residue 1 < 5")
980+
@test_throws ArgumentError collectatoms(struc, sel"residue A")
981+
@test_throws ArgumentError collectatoms(struc, sel"residue 1 and ()")
982+
@test_throws ArgumentError collectatoms(struc, sel"not (protein) and ()")
983+
@test_throws ArgumentError collectatoms(struc, sel"residue 1 or")
984+
@test_throws ArgumentError collectatoms(struc, sel"residue 1 and")
985+
@test_throws ArgumentError collectatoms(struc, sel"residue 1 not")
986+
@test_throws ArgumentError collectatoms(struc, sel"residue")
987+
@test_throws ArgumentError collectatoms(struc, sel"element")
988+
@test_throws ArgumentError collectatoms(struc, sel"not")
989+
990+
953991
end
954992

955993
@testset "PDB reading" begin

0 commit comments

Comments
 (0)