[Bio] / FigKernelPackages / FIG.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/FIG.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.550, Sun Dec 10 20:30:01 2006 UTC revision 1.551, Wed Dec 13 23:36:00 2006 UTC
# Line 16212  Line 16212 
16212              return undef;              return undef;
16213          }          }
16214      }      }
16215        elsif ($self->is_real_feature($fid))  { return $fid }
16216    
16217      my ( $fidN ) = $fid =~ m/^fig\|\d+\.\d+\.[0-9A-Za-z_]+\.(\d+)$/;      my ( $fidN ) = $fid =~ m/^fig\|\d+\.\d+\.[0-9A-Za-z_]+\.(\d+)$/;
16218      if ( ! $fidN || length( $fid ) > 32 )      if ( ! $fidN || length( $fid ) > 32 )
# Line 16241  Line 16242 
16242                     . "   translation = $translation\n";                     . "   translation = $translation\n";
16243      }      }
16244    
16245      $self->log_update($user,$genome,$self->genus_species($genome),"Added Feature $fid at $contig\_$beg\_$end");      if ($self->is_deleted_fid($fid))
16246        {
16247            $self->undelete_feature($user,$fid);
16248            $self->log_update($user,$genome,$self->genus_species($genome),"Undeleted Feature $fid");
16249            return $fid;
16250        }
16251    
16252        $self->log_update($user,$genome,$self->genus_species($genome),"Added Feature $fid at $contig\_$beg\_$end");
16253      &add_tbl_entry( $fid, $location, $aliasesT );      &add_tbl_entry( $fid, $location, $aliasesT );
16254    
16255      if ( ( $type eq "peg" ) and $translation )      if ( ( $type eq "peg" ) and $translation )
# Line 16313  Line 16320 
16320      return "fig\|$genome\.$type\.$fidN";      return "fig\|$genome\.$type\.$fidN";
16321  }  }
16322    
16323  sub replace_feature_with {  sub replace_features_with {
16324      my($self,$user,$from_fid,$to_fid) = @_;      my($self,%args) = @_;
16325    
16326      my $genome = &genome_of($from_fid);        my( $old_fids,  $user,   $genome,   $type,   $location,   $translation,   $function,  $fid) =
16327      $self->log_update($user,$genome,$self->genus_species($genome),"Replaced Feature $from_fid with $to_fid");      @args{'old_fids', 'user',  'genome',  'type',  'location',  'translation',  'function', 'fid'};
16328    
16329      my $type   = &ftype($from_fid);      if ($old_fids =~ /^fig\|\d+\.\d+/) { $old_fids = [$old_fids] }
16330      if (($genome ne &genome_of($to_fid)) || ($type ne &ftype($to_fid))) { return undef }      if ((ref($old_fids) ne "ARRAY") || (@$old_fids < 1))  { return undef }
16331    
16332      my $dbh = $self->db_handle();      if (! $user)     { return undef }
16333      my $file = "$FIG_Config::global/replaced.features";      if (! $genome)   { $genome = &FIG::genome_of($old_fids->[0]) }
16334      if (open(TMP,">>$file"))      if (! $type  )   { $old_fids->[0] =~ /^fig\|\d+\.\d+\.([^\.]+)/; $type = $1 }
16335        if (! $location) { return undef }
16336        if (! $function) { $function = $self->function_of($old_fids->[0]) }
16337    
16338        my %aliases;
16339        foreach my $old_fid (@$old_fids)
16340      {      {
16341          flock(TMP,LOCK_EX) || confess "cannot lock deleted.features";          if (($genome ne &genome_of($old_fid)) || ($type ne &ftype($old_fid))) { return undef }
16342          print TMP "$from_fid\t$to_fid\n";          my @aliases = $self->feature_aliases($old_fid);
16343          close(TMP);          foreach my $alias (@aliases)
16344          chmod 0777, $file;          {
16345                $aliases{$alias} = 1;
16346      }      }
     self->delete_feature($from_fid);  
     my $rc = $dbh->SQL("INSERT INTO replaced_fids (genome,from_fid,to_fid) VALUES ('$genome','$from_fid','$to_fid')");  
16347  }  }
16348        my $all_aliases = join(",",sort keys(%aliases));
16349    
16350  sub fid_replaced_by {      my $new_fid = $self->add_feature($user,$genome,$type,$location,$all_aliases,$translation,$fid);
     my($self,$fid) = @_;  
16351    
16352      my $dbh = $self->db_handle();      if ($new_fid)
16353      my $res = $dbh->SQL("SELECT to_fid FROM replaced_fids WHERE from_fid = '$fid'");      {
16354      if (@$res > 0)          print "function=$function\n";
16355            if ($function)
16356      {      {
16357          return $res->[0]->[0];              $self->assign_function($new_fid,$user,$function);
16358      }      }
16359      else          foreach my $old_fid (@$old_fids)
16360      {      {
16361          return undef;              next if ($new_fid eq $old_fid);
16362                $self->inherit_annnotations($old_fid,$new_fid);
16363                $self->add_annotation($old_fid,$user,"Replaced by $new_fid");
16364                $self->delete_feature($user,$old_fid);
16365            }
16366            my $all_old = join(",",@$old_fids);
16367            $self->log_update($user,$genome,$self->genus_species($genome),"Replaced Features $all_old with $new_fid");
16368        }
16369        return $new_fid;
16370    }
16371    
16372    sub inherit_annnotations {
16373        my($self,$old_fid,$new_fid) = @_;
16374    
16375        my @annotations = $self->feature_annotations($old_fid,"rawtime");
16376        foreach my $ann (@annotations)
16377        {
16378            my(undef, $timeStamp, $user, $annotation) = @$ann;
16379            $self->add_annotation($new_fid,$user,"Inherited from $old_fid\n\n$annotation",$timeStamp);
16380      }      }
16381  }  }
16382    

Legend:
Removed from v.1.550  
changed lines
  Added in v.1.551

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3