None available.
sub parse
{
my ($self, $db_adaptor, $file, $old_assembly, $new_assembly) = @_;
my %result;
print "Parsing $file with enhancer parser\n";
my $feature_internal_id = ($self->find_max_id($db_adaptor, "regulatory_feature")) + 1;
my $highest_factor_id = ($self->find_max_id($db_adaptor, "regulatory_factor")) + 1;
my $analysis_adaptor = $db_adaptor->get_AnalysisAdaptor();
my $slice_adaptor = $db_adaptor->get_SliceAdaptor();
my @features;
my %feature_objects;
my %anal;
my $dummy_analysis = new Bio::EnsEMBL::Analysis(-logic_name => 'EnhancerProjection');
my $analysis_positive = $analysis_adaptor->fetch_by_logic_name("enhancer_positive")->dbID();
my $analysis_negative = $analysis_adaptor->fetch_by_logic_name("enhancer_negative")->dbID();
if (!$analysis_positive) {
print STDERR "Can't get analysis for enhancer_positive, skipping\n";
exit(1);
}
if (!$analysis_negative) {
print STDERR "Can't get analysis for enhancer_negative, skipping\n";
exit(1);
}
my $blank_factor_id = $self->get_blank_factor_id($db_adaptor);
open (FILE, "<$file") || die "Can't open $file";
while (<FILE>) {
next if ($_ !~ /^>/);
my %feature;
my ($coords, $element, $posneg, @stuff) = split /\s+\|\s+/;;
my ($chr, $start, $end) = $coords =~ /chr([^:]+):(\d+)-(\d+)/;
my ($element_number) = $element =~ /\s*element\s*(\d+)/;
$feature{NAME} = "LBNL-$element_number";
$feature{ANALYSIS_ID} = $posneg eq 'positive' ? $analysis_positive : $analysis_negative;
my $chr_slice;
if ($old_assembly) {
$chr_slice = $slice_adaptor->fetch_by_region('chromosome', $chr, undef, undef, undef, $old_assembly);
} else {
$chr_slice = $slice_adaptor->fetch_by_region('chromosome', $chr);
}
if (!$chr_slice) {
print STDERR "Can't get slice for chromosme $chr\n";
next;
}
my $seq_region_id = $slice_adaptor->get_seq_region_id($chr_slice);
if (!$seq_region_id) {
print STDERR "Can't get seq_region_id for chromosome $chr\n";
next;
}
$feature{SEQ_REGION_ID} = $seq_region_id;
my $strand = 1;
if ($new_assembly) {
my $projected_feature = $self->project_feature($start, $end, $strand, $chr, $chr_slice, $dummy_analysis, $new_assembly, $slice_adaptor, $feature{NAME});
$start = $projected_feature->start();
$end = $projected_feature->end();
$strand = $projected_feature->strand();
$feature{SEQ_REGION_ID} = $slice_adaptor->get_seq_region_id($projected_feature->feature_Slice);
}
$feature{START} = $start;
$feature{END} = $end;
$feature{STRAND} = $strand;
$feature{INTERNAL_ID} = $feature_internal_id++;
$feature{EVIDENCE} = "";
$feature{FACTOR_ID} = $blank_factor_id;
push @features,\% feature;
}
close FILE;
$result{FEATURES} =\@ features;
print "Parsed " . scalar(@{$result{FEATURES}}) . " features\n";
return\% result; } |