Skip to content

Commit

Permalink
now parsing all locations except two (technically non-standard) ones
Browse files Browse the repository at this point in the history
  • Loading branch information
cjfields committed Sep 11, 2014
1 parent dd324ba commit 840c581
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 25 deletions.
5 changes: 4 additions & 1 deletion lib/Bio/Tools/FTLocationParser.pm6
Expand Up @@ -40,15 +40,18 @@ grammar Bio::Grammar::Location {
token functional_operator { 'join' | 'order' | 'complement' }

#base_position ::= <integer> | <low_base_bound> | <high_base_bound> | <two_base_bound>
token base_position { <abs_base_position> | <low_base_bound> | <high_base_bound> | <two_base_bound> }
token base_position { <abs_base_position> | <low_base_bound> | <high_base_bound> | <uncertain_bound> | <two_base_bound> }

# my addition
token abs_base_position { \d+ }

# low_base_bound ::= > <integer>
token low_base_bound { '>' <abs_base_position> }

token high_base_bound { '<' <abs_base_position> }

token uncertain_bound { '?' <abs_base_position>? }

# two_base_bound ::= <base_position>.<base_position>
token two_base_bound { '('? <abs_base_position>'.'<abs_base_position> ')'? }

Expand Down
46 changes: 22 additions & 24 deletions t/Tools/FTLocationParser.t
Expand Up @@ -41,27 +41,27 @@ my %testcases =
# 122, 133, "WITHIN", 204, 221, "WITHIN", "EXACT", 0, 1, Nil],

# UNCERTAIN locations and positions (Swissprot)
#"?2465..2774" => [0,
# 2465, 2465, "UNCERTAIN", 2774, 2774, "EXACT", "EXACT", 0, 1, Nil],
#"22..?64" => [0,
# 22, 22, "EXACT", 64, 64, "UNCERTAIN", "EXACT", 0, 1, Nil],
#"?22..?64" => [0,
# 22, 22, "UNCERTAIN", 64, 64, "UNCERTAIN", "EXACT", 0, 1, Nil],
#"?..>393" => [0,
# Nil, Nil, "UNCERTAIN", 393, Nil, "AFTER", "EXACT", 0, 1, Nil],
#"<1..?" => [0,
# Nil, 1, "BEFORE", Nil, Nil, "UNCERTAIN", "EXACT", 0, 1, Nil],
#"?..536" => [0,
# Nil, Nil, "UNCERTAIN", 536, 536, "EXACT", "EXACT", 0, 1, Nil],
#"1..?" => [0,
# 1, 1, "EXACT", Nil, Nil, "UNCERTAIN", "EXACT", 0, 1, Nil],
#"?..?" => [0,
# Nil, Nil, "UNCERTAIN", Nil, Nil, "UNCERTAIN", "EXACT", 0, 1, Nil],
#"1..?12" => [0,
# 1, 1, "EXACT", 12, 12, "UNCERTAIN", "EXACT", 0, 1, Nil],
## Not sure if this is legal...
#"?" => [0,
# Nil, Nil, "UNCERTAIN", Nil, Nil, "EXACT", "EXACT", 0, 1, Nil],
"?2465..2774" => [0,
2465, 2465, "UNCERTAIN", 2774, 2774, "EXACT", "EXACT", 0, 1, Nil],
"22..?64" => [0,
22, 22, "EXACT", 64, 64, "UNCERTAIN", "EXACT", 0, 1, Nil],
"?22..?64" => [0,
22, 22, "UNCERTAIN", 64, 64, "UNCERTAIN", "EXACT", 0, 1, Nil],
"?..>393" => [0,
Nil, Nil, "UNCERTAIN", 393, Nil, "AFTER", "EXACT", 0, 1, Nil],
"<1..?" => [0,
Nil, 1, "BEFORE", Nil, Nil, "UNCERTAIN", "EXACT", 0, 1, Nil],
"?..536" => [0,
Nil, Nil, "UNCERTAIN", 536, 536, "EXACT", "EXACT", 0, 1, Nil],
"1..?" => [0,
1, 1, "EXACT", Nil, Nil, "UNCERTAIN", "EXACT", 0, 1, Nil],
"?..?" => [0,
Nil, Nil, "UNCERTAIN", Nil, Nil, "UNCERTAIN", "EXACT", 0, 1, Nil],
"1..?12" => [0,
1, 1, "EXACT", 12, 12, "UNCERTAIN", "EXACT", 0, 1, Nil],
# Not sure if this is legal...
"?" => [0,
Nil, Nil, "UNCERTAIN", Nil, Nil, "EXACT", "EXACT", 0, 1, Nil],

# Split locations (now collections of locations)

Expand Down Expand Up @@ -123,9 +123,7 @@ for %testcases.keys -> $locstr {

Bio::Grammar::Location.parse($locstr);

say "$locstr" if !$/.defined;
say $/.gist;

ok($/.defined, $locstr);
}

done();

0 comments on commit 840c581

Please sign in to comment.