Skip to content

Commit

Permalink
added tests/code for attributes being set correctly in Genbank parsed…
Browse files Browse the repository at this point in the history
… JSON
  • Loading branch information
justaddcoffee committed Jul 15, 2013
1 parent cf11b96 commit cc97d81
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 4 additions & 0 deletions src/perl5/Bio/JBrowse/FeatureStream/Genbank.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@ sub _aggregate_features_from_gbk_record {
foreach my $feat ( @{$f->{FEATURES}} ){
next unless _isTopLevel( $feat );

# set subfeatures
$f->{'Subfeatures'} = undef;

# set start/stop
my $startStop = _extractStartStopFromJoinToken( $feat );
$f->{'start'} = $startStop->[0] + 1;
$f->{'end'} = $startStop->[1];

# deal with subfeatures
}

# get rid of unnecessary stuff, this could get really big for some GBK files
Expand Down
14 changes: 6 additions & 8 deletions tests/perl_tests/flatfile-to-json.pl.t
Original file line number Diff line number Diff line change
Expand Up @@ -293,14 +293,12 @@ for my $testfile ( "tests/data/au9_scaffold_subset.gff3", "tests/data/au9_scaffo
ok( $trackdata->{'trackData.json'}->{'intervals'}->{'nclist'}->[0]->[2] == 10950, "got right stop coordinate (full record)" );

# test attributes are present in the correct order
# is_deeply( sort($trackdata->{'trackData.json'}->{'intervals'}->{'classes'}->[0]->{'attributes'}),
# sort(
# ['Start', 'End', 'Strand', 'COMMENT', 'DEFINITION', 'CLASSIFICATION', 'LOCUS', 'FEATURES',
# 'KEYWORDS', 'SEQUENCE', 'ACCESSION', 'Seq_id', 'NCBI_TAXON_ID', 'MOL_TYPE', 'ORIGIN', 'ORGANISM',
# 'VERSION', 'SOURCE', "Subfeatures"]),
# 'got the right attributes in trackData.json')
# or diag explain $trackdata->{'trackData.json'};

is_deeply( [sort(@{$trackdata->{'trackData.json'}->{'intervals'}->{'classes'}->[0]->{'attributes'}})],
[sort(@{['Start', 'End', 'Strand', 'COMMENT', 'DEFINITION', 'CLASSIFICATION', 'LOCUS', 'FEATURES',
'KEYWORDS', 'SEQUENCE', 'ACCESSION', 'Seq_id', 'NCBI_TAXON_ID', 'MOL_TYPE', 'ORIGIN', 'ORGANISM',
'VERSION', 'SOURCE', "Subfeatures"]})],
'got the right attributes in trackData.json')
or diag $trackdata->{'trackData.json'}->{'intervals'}->{'classes'}->[0]->{'attributes'};


}
Expand Down

0 comments on commit cc97d81

Please sign in to comment.