From 32e8c5b6e8856d0759337fa6236749d3cb11a5c2 Mon Sep 17 00:00:00 2001 From: Amonida Zadissa <amonida@ebi.ac.uk> Date: Thu, 27 Sep 2012 14:33:05 +0000 Subject: [PATCH] * Columns are tab-separated, split the rows accordingly and then there's no need to start the index at '1'. * Don't check the assembly_exception table if this is the first set of patches to be added. --- .../assembly_patches/assembly_patch_load.pl | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/misc-scripts/assembly_patches/assembly_patch_load.pl b/misc-scripts/assembly_patches/assembly_patch_load.pl index 7d8c3f0891..9b045c7d02 100644 --- a/misc-scripts/assembly_patches/assembly_patch_load.pl +++ b/misc-scripts/assembly_patches/assembly_patch_load.pl @@ -65,14 +65,19 @@ $sth->finish; $sth = $dba->dbc->prepare("select max(assembly_exception_id) from assembly_exception") || die "Could not get max assembly_exception_id"; -$sth->execute || die "problem executing get max sassembly_exception_id"; +$sth->execute || die "problem executing get max assembly_exception_id"; my $max_assembly_exception_id; $sth->bind_columns(\$max_assembly_exception_id) || die "problem binding"; $sth->fetch() || die "problem fetching"; $sth->finish; print "starting new seq_region at seq_region_id of $max_seq_region_id\n"; -print "\nTo reset\ndelete from dna where seq_region_id > $max_seq_region_id\ndelete from seq_region where seq_region_id > $max_seq_region_id\ndelete from assembly_exception where assembly_exception_id > $max_assembly_exception_id\n\n"; + +if (defined( $max_assembly_exception_id ) ) { + print "\nTo reset\ndelete from dna where seq_region_id > $max_seq_region_id\ndelete from seq_region where seq_region_id > $max_seq_region_id\ndelete from assembly_exception where assembly_exception_id > $max_assembly_exception_id\n\n"; +} else { + print "\nNOTE! assembly_exception table is not populated, probably the first patch release.\n\n"; +} $max_seq_region_id++; $max_assembly_exception_id++; @@ -178,8 +183,8 @@ while (<TYPE>) { SCAF: while(<TXT>){ if(/^#/){ chomp; - my @arr = split; - my $i = 1;#work around primary and assembly being two words - first three cols never used + my @arr = split(/\t/,$_); + my $i = 0; foreach my $name (@arr){ $key_to_index{$name} = $i; $i++; @@ -194,7 +199,8 @@ SCAF: while(<TXT>){ } } else{ - my @arr = split; + my @arr = split(/\t/,$_); + my $alt_acc = $arr[$key_to_index{'alt_scaf_acc'}]; my $alt_name = $arr[$key_to_index{'alt_scaf_name'}]; -- GitLab