Skip to content

Commit

Permalink
Pair-matching in the presence of multiply-mapped reads is more compli…
Browse files Browse the repository at this point in the history
…cated than I thought; reverting the pair matching code

Revert "don't try to share subfeatures if they're not already shared"

This reverts commit 433c2d4.
  • Loading branch information
Mitch Skinner committed Sep 3, 2010
1 parent f1470f1 commit c06893f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
5 changes: 4 additions & 1 deletion bin/flatfile-to-json.pl
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
};

my $streaming = 0;
my $shareSubs = 0;
my ($db, $stream);
if ($gff) {
$db = Bio::DB::SeqFeature::Store->new(-adaptor => 'memory',
Expand All @@ -113,6 +114,7 @@
($thinType ? ("-thin_type" => $thinType) : ()),
($thickType ? ("-thick_type" => $thickType) : ()) );
$streaming = 1;
$shareSubs = 1;
$labelSub = sub {
#label sub for features returned by Bio::FeatureIO::bed
return $_[0]->name;
Expand Down Expand Up @@ -159,7 +161,8 @@
foreach my $seqInfo (@refSeqs) {
$perChromGens{$seqInfo->{"name"}} = JsonGenerator->new($trackLabel,
$seqInfo->{"name"},
\%style, [], []);
\%style, [], [],
$shareSubs);
}

if ($streaming) {
Expand Down
24 changes: 13 additions & 11 deletions lib/JsonGenerator.pm
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ sub evalSubStrings {

sub new {
my ($class, $label, $segName, $setStyle,
$extraMap, $extraHeaders) = @_;
$extraMap, $extraHeaders,
$autoshareSubs) = @_;

my %style = ("key" => $label,
%builtinDefaults,
Expand Down Expand Up @@ -215,11 +216,17 @@ sub new {
my @allSubfeatures;
$self->{allSubfeatures} = \@allSubfeatures;
my $subfeatId = $style{idSub} || sub {
return
$_[0]->can('primary_id') ?
$_[0]->primary_id :
($_[0]->can('id') ? $_[0]->id : undef);
return $_[0]->can('primary_id') ? $_[0]->primary_id : $_[0]->id;
};
if ($autoshareSubs) {
$subfeatId = sub {
my $feat = shift;
return $feat->primary_tag
. "|" . $feat->start
. "|" . $feat->end
. "|" . $feat->strand;
}
}
# %seenSubfeatures is so that shared subfeatures don't end up
# in @{$self->{allSubfeatures}} more than once
my %seenSubfeatures;
Expand All @@ -237,12 +244,7 @@ sub new {
next unless
$sfClasses && $sfClasses->{$subFeature->primary_tag};
my $subId = $subfeatId->($subFeature);
my $subIndex;
if (defined($subId)) {
$subIndex = $seenSubfeatures{$subId};
} else {
$subIndex = undef;
}
my $subIndex = $seenSubfeatures{$subId};
if (!defined($subIndex)) {
push @allSubfeatures, [map {&$_($subFeature)} @subfeatMap];
$subIndex = $#allSubfeatures;
Expand Down

0 comments on commit c06893f

Please sign in to comment.