Skip to content
Snippets Groups Projects
Commit e6a50432 authored by Magali Ruffier's avatar Magali Ruffier
Browse files

check length before coord_system

for coord_system, check rank and name
parent 545d3b05
No related branches found
No related tags found
No related merge requests found
...@@ -188,22 +188,30 @@ foreach my $h ($host,$host2) { ...@@ -188,22 +188,30 @@ foreach my $h ($host,$host2) {
if (!defined $current_name_hash) { if (!defined $current_name_hash) {
next; next;
} }
foreach my $coord_system_id (keys %{$old_name_hash}){ foreach my $length (keys %{$old_name_hash}){
my $current_cs_hash = $current_name_hash->{$coord_system_id}; my $current_length_hash = $current_name_hash->{$length};
my $old_cs_hash = $old_name_hash->{$coord_system_id}; my $old_length_hash = $old_name_hash->{$length};
# The coord_system might have been removed in the current database # The seq_region might have a different length
if (!defined $current_cs_hash) { if (!defined $current_length_hash) {
next; next;
} }
foreach my $length (keys %{$old_cs_hash}) { foreach my $cs (keys %{$old_length_hash}) {
my $current_id = $current_cs_hash->{$length}; my $current_cs_hash = $current_length_hash->{$cs};
my $old_id = $old_cs_hash->{$length}; my $old_cs_hash = $old_length_hash->{$cs};
# If no change, no need to write out # The coord system might have changed
if (!defined $current_id || $old_id == $current_id) { if (!defined $current_cs_hash) {
next; next;
} }
$sth_seq_mapping->execute($old_id, $current_id, $mapping_set_id) unless $dry_run; foreach my $id (keys %{$old_cs_hash}) {
$count++; my $current_id = $current_cs_hash->{$id};
my $old_id = $old_cs_hash->{$id};
# If no change, no need to write out
if (!defined $current_id || $old_id == $current_id) {
next;
}
$sth_seq_mapping->execute($old_id, $current_id, $mapping_set_id) unless $dry_run;
$count++;
}
} }
} }
} }
...@@ -216,15 +224,16 @@ sub read_seq_region{ ...@@ -216,15 +224,16 @@ sub read_seq_region{
my $dbh = shift; my $dbh = shift;
my $dbname = shift; my $dbname = shift;
my %seq_region_hash; my %seq_region_hash;
my ($seq_region_id, $seq_region_name, $coord_system_id, $length, $cs_name); my ($seq_region_id, $seq_region_name, $coord_system_id, $length, $cs_name, $cs_rank);
my $sth = $dbh->prepare("SELECT seq_region_id, name, length, coord_system_id FROM $dbname.seq_region"); my $sth = $dbh->prepare("SELECT seq_region_id, s.name, length, cs.name, cs.rank FROM $dbname.seq_region s, $dbname.coord_system cs WHERE cs.coord_system_id = s.coord_system_id");
$sth->execute(); $sth->execute();
$sth->bind_col(1,\$seq_region_id); $sth->bind_col(1,\$seq_region_id);
$sth->bind_col(2,\$seq_region_name); $sth->bind_col(2,\$seq_region_name);
$sth->bind_col(3,\$length); $sth->bind_col(3,\$length);
$sth->bind_col(4,\$coord_system_id); $sth->bind_col(4,\$cs_name);
$sth->bind_col(5,\$cs_rank);
while ($sth->fetch){ while ($sth->fetch){
$seq_region_hash{$seq_region_name}{$coord_system_id}{$length} = $seq_region_id; $seq_region_hash{$seq_region_name}{$length}{$cs_name}{$cs_rank} = $seq_region_id;
} }
return \%seq_region_hash; return \%seq_region_hash;
} }
......
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