Skip to content
Snippets Groups Projects
Commit 9356042c authored by Glenn Proctor's avatar Glenn Proctor
Browse files

Change regulatory_search_region to have an analysis_id rather than a type.

parent 7b1e325d
No related branches found
No related tags found
No related merge requests found
...@@ -35,9 +35,14 @@ sub delete_existing { ...@@ -35,9 +35,14 @@ sub delete_existing {
$sth = $db_adaptor->dbc->prepare("DELETE rfeat FROM regulatory_feature rfeat, analysis a WHERE a.analysis_id=rfeat.analysis_id AND LOWER(a.analysis_id)=?"); $sth = $db_adaptor->dbc->prepare("DELETE rfeat FROM regulatory_feature rfeat, analysis a WHERE a.analysis_id=rfeat.analysis_id AND LOWER(a.analysis_id)=?");
$sth->execute($t); $sth->execute($t);
# delete search regions of this type # Delete search regions; they have a different analysis_id
$sth = $db_adaptor->dbc->prepare("DELETE FROM regulatory_search_region WHERE type=?"); my $sr_type = $type . "_search";
$sth->execute($t); die "Can't find analysis for $sr_type " unless validate_type($db_adaptor, $sr_type);
my $anal_sth = $db_adaptor->dbc->prepare("SELECT analysis_id FROM analysis WHERE LOWER(logic_name)=?");
$anal_sth->execute($sr_type);
my $anal = ($anal_sth->fetchrow_array())[0];
$sth = $db_adaptor->dbc->prepare("DELETE FROM regulatory_search_region WHERE analysis_id=?");
$sth->execute($anal);
} }
...@@ -127,7 +132,7 @@ sub upload_features_and_factors { ...@@ -127,7 +132,7 @@ sub upload_features_and_factors {
my $factor_sth = $dbc->prepare("INSERT INTO regulatory_factor (regulatory_factor_id, name, type) VALUES(?,?,?)"); my $factor_sth = $dbc->prepare("INSERT INTO regulatory_factor (regulatory_factor_id, name, type) VALUES(?,?,?)");
my $feature_object_sth = $dbc->prepare("INSERT INTO regulatory_feature_object (regulatory_feature_id, ensembl_object_type, ensembl_object_id, influence, evidence) VALUES(?,?,?,?,?)"); my $feature_object_sth = $dbc->prepare("INSERT INTO regulatory_feature_object (regulatory_feature_id, ensembl_object_type, ensembl_object_id, influence, evidence) VALUES(?,?,?,?,?)");
my $sr_sth = $dbc->prepare("INSERT INTO regulatory_search_region (name, seq_region_id, seq_region_start, seq_region_end, seq_region_strand, ensembl_object_type, ensembl_object_id, type ) VALUES(?,?,?,?,?,?,?,?)"); my $sr_sth = $dbc->prepare("INSERT INTO regulatory_search_region (name, seq_region_id, seq_region_start, seq_region_end, seq_region_strand, ensembl_object_type, ensembl_object_id, analysis_id ) VALUES(?,?,?,?,?,?,?,?)");
print "Uploading " . scalar(@{$objects->{FEATURES}}) . " features ...\n"; print "Uploading " . scalar(@{$objects->{FEATURES}}) . " features ...\n";
...@@ -171,7 +176,7 @@ sub upload_features_and_factors { ...@@ -171,7 +176,7 @@ sub upload_features_and_factors {
$search_region->{STRAND}, $search_region->{STRAND},
$search_region->{ENSEMBL_OBJECT_TYPE}, $search_region->{ENSEMBL_OBJECT_TYPE},
$search_region->{ENSEMBL_OBJECT_ID}, $search_region->{ENSEMBL_OBJECT_ID},
$search_region->{TYPE}); $search_region->{ANALYSIS_ID});
} }
......
...@@ -103,16 +103,19 @@ sub parse { ...@@ -103,16 +103,19 @@ sub parse {
close(GROUP_SIZES); close(GROUP_SIZES);
# ---------------------------------------- # ----------------------------------------
# Analysis # Analysis - need one for each type of feature
my %analysis;
my $analysis = $analysis_adaptor->fetch_by_logic_name("cisRed"); foreach my $anal ("cisRed", "cisred_search") { # TODO - add other types as necessary
if (!$analysis) { my $analysis_obj = $analysis_adaptor->fetch_by_logic_name($anal);
print STDERR "Can't get analysis for cisRed, skipping\n";
next; die "Can't get analysis for $anal, skipping" if (!$analysis_obj);
}
my $analysis_id = $analysis->dbID(); $analysis{$anal} = $analysis_obj->dbID();
print "Analysis ID for $anal is " . $analysis{$anal} . "\n";
}
# ---------------------------------------- # ----------------------------------------
# Parse motifs.txt file # Parse motifs.txt file
...@@ -136,7 +139,7 @@ sub parse { ...@@ -136,7 +139,7 @@ sub parse {
$feature{NAME} = "craHsap" . $motif_id; $feature{NAME} = "craHsap" . $motif_id;
$feature{INFLUENCE} = "unknown"; # TODO - what does cisRed store? $feature{INFLUENCE} = "unknown"; # TODO - what does cisRed store?
$feature{ANALYSIS_ID} = $analysis_id; $feature{ANALYSIS_ID} = $analysis{cisRed};
# ---------------------------------------- # ----------------------------------------
# Factor # Factor
...@@ -224,7 +227,7 @@ sub parse { ...@@ -224,7 +227,7 @@ sub parse {
close FILE; close FILE;
# ---------------------------------------- # ----------------------------------------
# Search regions # Search regions
# read search_regions.txt from same location as $file # read search_regions.txt from same location as $file
my $search_regions_file = dirname($file) . "/search_regions.txt"; my $search_regions_file = dirname($file) . "/search_regions.txt";
...@@ -258,7 +261,7 @@ sub parse { ...@@ -258,7 +261,7 @@ sub parse {
$search_region{STRAND} = ($strand =~ /\+/ ? 1 : -1); $search_region{STRAND} = ($strand =~ /\+/ ? 1 : -1);
$search_region{ENSEMBL_OBJECT_TYPE} = 'Gene'; $search_region{ENSEMBL_OBJECT_TYPE} = 'Gene';
$search_region{ENSEMBL_OBJECT_ID} = $gene_id; $search_region{ENSEMBL_OBJECT_ID} = $gene_id;
$search_region{TYPE} = 'cisred'; $search_region{ANALYSIS_ID} = $analysis{cisred_search};
push @search_regions, \%search_region; push @search_regions, \%search_region;
} }
......
...@@ -1310,7 +1310,7 @@ CREATE TABLE regulatory_search_region ( ...@@ -1310,7 +1310,7 @@ CREATE TABLE regulatory_search_region (
seq_region_strand TINYINT NOT NULL, seq_region_strand TINYINT NOT NULL,
ensembl_object_type ENUM( 'Transcript', 'Translation', 'Gene') NOT NULL, ensembl_object_type ENUM( 'Transcript', 'Translation', 'Gene') NOT NULL,
ensembl_object_id INT, # FK to gene/transcript/translation ensembl_object_id INT, # FK to gene/transcript/translation
type ENUM('cisred_search', 'cisred_mask', 'unknown'), analysis_id INT NOT NULL, # FK to analysis
PRIMARY KEY (regulatory_search_region_id), PRIMARY KEY (regulatory_search_region_id),
KEY rsr_idx (regulatory_search_region_id), KEY rsr_idx (regulatory_search_region_id),
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment