None available.
sub new
{ my $caller = shift;
my $class = ref($caller) || $caller;
my $self = $class->SUPER::new(@_);
$self->{'feature_types'} = {
'cisRED Search Region' => {
name => 'cisRED Search Region',
class => 'Region',
description => 'cisRED search region',
},
'cisRED Motif' => {
name => 'cisRED Motif',
class => 'Regulatory Motif',
description => 'cisRED atomic motif',
},
};
$self->{feature_sets} = {
'cisRED search regions' => {
feature_type =>\$ self->{'feature_types'}{'cisRED Search Region'},
display_label => 'cisRED searches',
analysis =>
{
-logic_name => 'cisRED',
-description => 'cisRED motif search (www.cisred.org)',
-display_label => 'cisRED',
-displayable => 1,
},
xrefs => 1,
},
'cisRED motifs' => {
feature_type =>\$ self->{'feature_types'}{'cisRED Motif'},
analysis =>
{
-logic_name => 'cisRED',
-description => 'cisRED motif search (www.cisred.org)',
-display_label => 'cisRED',
-displayable => 1,
},
xrefs => 1,
},
};
$self->validate_and_store_feature_types;
$self->set_feature_sets;
return $self;
}
} |
sub parse_and_load
{ my ($self, $files, $old_assembly, $new_assembly) = @_;
$self->log_header("Parsing cisRED data");
my $analysis_adaptor = $self->db->get_AnalysisAdaptor();
my %groups;
my %slice_cache;
my $extf_adaptor = $self->db->get_ExternalFeatureAdaptor;
my $dbentry_adaptor = $self->db->get_DBEntryAdaptor;
my $ftype_adaptor = $self->db->get_FeatureTypeAdaptor;
my $dummy_analysis = new Bio::EnsEMBL::Analysis(-logic_name => 'CisREDProjection');
my ($motif_file) = grep(/motif/, @$files);
my ($search_file) = grep(/search/, @$files);
my $species = $self->db->species;
if(! $species){
throw('Must define a species to define the external_db');
}
($species = lc($species)) =~ s/ /_/;
$self->log_header("Parsing cisRED motifs from $motif_file");
my $skipped = 0;
my $skipped_xref = 0;
my $cnt = 0;
open (FILE, "<$motif_file") || die "Can't open $motif_file";
<FILE>;
while (<FILE>) {
next if ($_ =~ /^\s*\#/o || $_ =~ /^\s*$/o);
chomp;
my ($motif_name, $chromosome, $start, $end, $strand, $groups, $gene_id) = split/\t/o;
my @group_names = split/,/, $groups;
$strand = ($strand eq '-') ? -1 : 1;
if(! exists $slice_cache{$chromosome}){
if($old_assembly){
$slice_cache{$chromosome} = $self->slice_adaptor->fetch_by_region('chromosome',
$chromosome,
undef,
undef,
undef,
$old_assembly);
}else{
$slice_cache{$chromosome} = $self->slice_adaptor->fetch_by_region('chromosome', $chromosome);
}
}
if(! defined $slice_cache{$chromosome}){
warn "Can't get slice $chromosome for motif $motif_name\n";
$skipped++;
next;
}
foreach my $group(@group_names){
next if exists $groups{$group};
($group) = @{$ftype_adaptor->store(Bio::EnsEMBL::Funcgen::FeatureType->new
(
-name => $group,
-class => 'Regulatory Motif',
-description => 'cisRED group',
))};
}
my $feature = Bio::EnsEMBL::Funcgen::ExternalFeature->new
(
-display_label => $motif_name,
-start => $start,
-end => $end,
-strand => $strand,
-associated_feature_types =>\@ group_names,
-feature_set => $self->{'feature_sets'}{'cisRED motifs'},
-slice => $slice_cache{$chromosome},
);
if ($new_assembly) {
$feature = $self->project_feature($feature, $new_assembly);
if(! defined $feature){
$skipped ++;
next;
}
}
($feature) = @{$extf_adaptor->store($feature)};
$cnt++;
if (! $gene_id) {
warn("No xref available for motif $motif_name\n");
$skipped_xref++;
next;
}
my $display_name = $self->get_core_display_name_by_stable_id($self->db->dnadb, $gene_id, 'gene');
my $dbentry = Bio::EnsEMBL::DBEntry->new(
-dbname => $species.'_core_Gene',
-status => 'KNOWNXREF',
- -db_display_name => 'EnsemblGene',
-type => 'MISC', -primary_id => $gene_id,
-display_id => $display_name,
-info_type => 'MISC',
-info_text => 'GENE',
-linkage_annotation => 'cisRED motif gene',
);
$dbentry_adaptor->store($dbentry, $feature->dbID, 'ExternalFeature', 1); }
close FILE;
$self->log("Stored $cnt cisRED ExternalFeature motif");
$self->log("Skipped $skipped cisRED ExternalFeature motif imports");
$self->log("Skipped an additional $skipped_xref DBEntry imports");
$skipped = 0;
$cnt = 0;
$skipped_xref = 0;
$self->log_header("Parsing cisRED search regions from $search_file");
open (SEARCH_REGIONS, "<$search_file") || die "Can't open $search_file";
<SEARCH_REGIONS>;
while (<SEARCH_REGIONS>) {
chomp;
my ($id, $chromosome, $start, $end, $strand, $gene_id) = split;
my $display_id = $self->get_core_display_name_by_stable_id($self->db->dnadb, $gene_id, 'gene');
my $name = "CisRed_Search_$id";
if(! exists $slice_cache{$chromosome}){
if($old_assembly){
$slice_cache{$chromosome} = $self->slice_adaptor->fetch_by_region('chromosome',
$chromosome,
undef,
undef,
undef,
$old_assembly);
}else{
$slice_cache{$chromosome} = $self->slice_adaptor->fetch_by_region('chromosome', $chromosome);
}
}
if(! defined $slice_cache{$chromosome}){
warn "Can't get slice $chromosome for search region $name\n";
next;
}
my $search_feature = Bio::EnsEMBL::Funcgen::ExternalFeature->new
(
-display_label => $name,
-start => $start,
-end => $end,
-strand => $strand,
-feature_type => $self->{'feature_sets'}{'cisRED search regions'}->feature_type,
-feature_set => $self->{'feature_sets'}{'cisRED search regions'},
-slice => $slice_cache{$chromosome},
);
if ($new_assembly) {
$search_feature = $self->project_feature($search_feature);
if(! defined $search_feature){
$skipped ++;
next;
}
}
$extf_adaptor->store($search_feature);
$cnt++;
if (! $gene_id) {
warn("Can't get internal ID for $gene_id\n");
$skipped_xref++;
next;
}
my $display_name = $self->get_core_display_name_by_stable_id($self->db->dnadb, $gene_id, 'gene');
my $dbentry = Bio::EnsEMBL::DBEntry->new(
-dbname => $species.'_core_Gene',
-status => 'KNOWNXREF',
-db_display_name => 'EnsemblGene',
-type => 'MISC',
-primary_id => $gene_id,
-display_id => $display_name,
-info_type => 'MISC',
-info_text => 'GENE',
-linkage_annotation => 'cisRED search region gene', );
$dbentry_adaptor->store($dbentry, $search_feature->dbID, 'ExternalFeature', 1); }
close(SEARCH_REGIONS);
$self->log("Stored $cnt cisRED search region ExternalFeatures");
$self->log("Skipped $skipped cisRED search region ExternalFeatures");
$self->log("Skipped an additional $skipped_xref cisRED search region DBEntry imports");
return;
}
1; } |