@@ -10,7 +10,6 @@ use strict;
10
10
use warnings;
11
11
12
12
use base ' Bio::JBrowse::FeatureStream' ;
13
- use Data::Dumper;
14
13
15
14
use Bio::JBrowse::FeatureStream::Genbank::LocationParser;
16
15
@@ -32,12 +31,11 @@ sub _aggregate_features_from_gbk_record {
32
31
# get index of top level feature ('mRNA' at current writing)
33
32
my $indexTopLevel ;
34
33
my $count = 0;
35
- print Dumper $record ;
36
34
foreach my $feat ( @{$record -> {FEATURES }} ){
37
- if ( _isTopLevel( $feat ) ){
38
- $indexTopLevel = $count ;
39
- }
40
- $count ++;
35
+ if ( _isTopLevel( $feat ) ){
36
+ $indexTopLevel = $count ;
37
+ }
38
+ $count ++;
41
39
}
42
40
43
41
return unless defined $indexTopLevel ;
@@ -56,52 +54,55 @@ sub _aggregate_features_from_gbk_record {
56
54
delete $f -> {SEQUENCE };
57
55
58
56
$f -> {end } = $locations [-1]{end };
59
- $f -> {type } = $record -> {FEATURES }[$indexTopLevel ]{name };
60
- $f -> {seq_id } ||= $seq_id ;
61
-
62
- %$f = ( %{$record -> {FEATURES }[$indexTopLevel ]{feature } || {}}, %$f ); # get other attrs
63
- if ( $f -> {type } eq ' gene' ) {
64
- print " here2\n " ;
65
- $f -> {name } = $record -> {FEATURES }[$indexTopLevel ]{feature }{gene };
66
- $f -> {description } = $record -> {FEATURES }[$indexTopLevel ]{feature }{product } || $f -> {FEATURES }[$indexTopLevel ]{feature }{note };
67
- }
57
+ # for my $f ( @features ) {
58
+ $f -> {start } += $offset + 1;
59
+ $f -> {end } += $offset ;
60
+ $f -> {strand } = 1 unless defined $f -> {strand };
61
+ $f -> {type } = $record -> {FEATURES }[$indexTopLevel ]{name };
62
+ $f -> {seq_id } ||= $seq_id ;
63
+
64
+ %$f = ( %{$record -> {FEATURES }[$indexTopLevel ]{feature } || {}}, %$f ); # get other attrs
65
+ if ( $f -> {type } eq ' mRNA' ) {
66
+ $f -> {name } = $record -> {FEATURES }[$indexTopLevel ]{feature }{gene };
67
+ $f -> {description } = $record -> {FEATURES }[$indexTopLevel ]{feature }{product } || $f -> {FEATURES }[$indexTopLevel ]{feature }{note };
68
+ }
68
69
69
- # convert FEATURES to subfeatures
70
- $f -> {subfeatures } = [];
71
- if ( scalar ( @{$record -> {FEATURES } || [] }) > $indexTopLevel ) {
72
- for my $i ( $indexTopLevel + 1 .. $# {$record -> {FEATURES }} ) {
73
- my $feature = $record -> {FEATURES }[$i ];
74
- my @sublocations = _parseLocation( $feature -> {location } );
75
- for my $subloc ( @sublocations ) {
76
- $subloc -> {start } += $offset + 1;
77
- $subloc -> {end } += $offset ;
78
-
79
- my $newFeature = {
80
- %{ $feature -> {feature }||{} },
81
- %$subloc ,
82
- type => $feature -> {name }
83
- };
84
-
85
- $newFeature -> {seq_id } ||= $seq_id ;
86
-
87
- push @{$f -> {subfeatures }}, $newFeature ;
70
+ # convert FEATURES to subfeatures
71
+ $f -> {subfeatures } = [];
72
+ if ( scalar ( @{$record -> {FEATURES } || [] }) > $indexTopLevel ) {
73
+ for my $i ( $indexTopLevel + 1 .. $# {$record -> {FEATURES }} ) {
74
+ my $feature = $record -> {FEATURES }[$i ];
75
+ my @sublocations = _parseLocation( $feature -> {location } );
76
+ for my $subloc ( @sublocations ) {
77
+ $subloc -> {start } += $offset + 1;
78
+ $subloc -> {end } += $offset ;
79
+
80
+ my $newFeature = {
81
+ %{ $feature -> {feature }||{} },
82
+ %$subloc ,
83
+ type => $feature -> {name }
84
+ };
85
+
86
+ $newFeature -> {seq_id } ||= $seq_id ;
87
+
88
+ push @{$f -> {subfeatures }}, $newFeature ;
89
+ }
88
90
}
89
91
}
90
- }
92
+ # }
91
93
92
94
return $f ;
93
95
}
94
96
95
97
sub _isTopLevel {
96
98
my $feat = shift ;
97
- my @topLevelFeatures = qw( gene ) ; # add more as needed?
99
+ my @topLevelFeatures = qw( mRNA ) ; # add more as needed?
98
100
my $isTopLevel = 0;
99
101
foreach my $thisTopFeat ( @topLevelFeatures ){
100
- if ( $feat -> {' name' } =~ m /$thisTopFeat / ){
101
- print " here\n " ;
102
- $isTopLevel = 1;
103
- last ;
104
- }
102
+ if ( $feat -> {' name' } =~ m /$thisTopFeat / ){
103
+ $isTopLevel = 1;
104
+ last ;
105
+ }
105
106
}
106
107
return $isTopLevel ;
107
108
}
@@ -114,7 +115,7 @@ sub _getRegionOffset {
114
115
115
116
my $f = shift ;
116
117
my $offset = 0;
117
- if ( grep {$_ =~ / REGION\: / } @{$f -> {' VERSION' }} ){ # this is a region file
118
+ if ( grep {$_ =~ / REGION\: / } @{$f -> {' VERSION' }} ){ # this is a region file
118
119
# get array item after REGION token
119
120
my $count = 0;
120
121
my $regionIndexInArray ;
0 commit comments