[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.563, Tue Jan 30 00:26:33 2007 UTC revision 1.564, Sat Feb 3 02:50:49 2007 UTC
# Line 16461  Line 16461 
16461  =cut  =cut
16462    
16463  sub add_feature {  sub add_feature {
16464      my( $self, $user, $genome, $type, $location, $aliases, $translation, $fid ) = @_;      my( $self, $user, $genome, $type, $location, $aliases, $sequence, $fid ) = @_;
16465    
16466      my $dbh = $self->db_handle();      my $dbh = $self->db_handle();
16467    
# Line 16530  Line 16530 
16530                          grep { $_ && ( ! $seen{ $_ }++ ) }                          grep { $_ && ( ! $seen{ $_ }++ ) }
16531                          map  { $_->[0] }                          map  { $_->[0] }
16532                          @loc2;                          @loc2;
16533          $fid = $self->fid_from_clearinghouse( $genome, $type, $location, \@checksums, $translation );          $fid = $self->fid_from_clearinghouse( $genome, $type, $location, \@checksums, $sequence );
16534    
16535          if ( ! $fid )          if ( ! $fid )
16536          {          {
# Line 16547  Line 16547 
16547          return undef;          return undef;
16548      }      }
16549    
16550      $translation ||= "";      $sequence ||= "";
16551      $aliases ||= "";      $aliases ||= "";
16552      my $aliasesT = $aliases;      my $aliasesT = $aliases;
16553      $aliasesT =~ s/,\s*/\t/g;      $aliasesT =~ s/,\s*/\t/g;
# Line 16565  Line 16565 
16565                     . "   minloc   = $beg\n"                     . "   minloc   = $beg\n"
16566                     . "   maxloc   = $end\n"                     . "   maxloc   = $end\n"
16567                     . "   aliases  = $aliases\n"                     . "   aliases  = $aliases\n"
16568                     . "   translation = $translation\n";                     . "   sequence = $sequence\n";
16569      }      }
16570    
16571      if ($self->is_deleted_fid($fid))      if ($self->is_deleted_fid($fid))
# Line 16578  Line 16578 
16578      $self->log_update($user,$genome,$self->genus_species($genome),"Added Feature $fid at $contig\_$beg\_$end");      $self->log_update($user,$genome,$self->genus_species($genome),"Added Feature $fid at $contig\_$beg\_$end");
16579      &add_tbl_entry( $fid, $location, $aliasesT );      &add_tbl_entry( $fid, $location, $aliasesT );
16580    
16581      if ( ( $type eq "peg" ) and $translation )      if ($sequence)
16582        {
16583            $self->add_sequence( $fid, $sequence );
16584        }
16585        if ( ( $type eq "peg" ) and $sequence )
16586      {      {
         $self->add_translation( $fid, $translation );  
16587          $self->enqueue_similarities([$fid]);          $self->enqueue_similarities([$fid]);
16588      }      }
16589    
# Line 17024  Line 17027 
17027    
17028          if (($type eq "peg") && defined($translation))          if (($type eq "peg") && defined($translation))
17029          {          {
17030              $self->add_translation($fid,$translation);              $self->add_sequence($fid,$translation);
17031          }          }
17032          $got = 1          $got = 1
17033      }      }
# Line 17034  Line 17037 
17037  sub add_tbl_entry {  sub add_tbl_entry {
17038      my($fid,$location,$aliasesT) = @_;      my($fid,$location,$aliasesT) = @_;
17039    
17040        my $type;
17041        if ($fid =~ /^fig\|\d+\.\d+\.([a-zA-Z0-9_-]+)/)
17042        {
17043            $type = $1;
17044        }
17045        else
17046        {
17047            return "";
17048        }
17049      my $genome = &genome_of($fid);      my $genome = &genome_of($fid);
17050      my $file   = "$FIG_Config::organisms/$genome/Features/peg/tbl";      &verify_dir("$FIG_Config::organisms/$genome/Features/$type");
17051        my $file   = "$FIG_Config::organisms/$genome/Features/$type/tbl";
17052      open(TMP,">>$file")      open(TMP,">>$file")
17053          || die "could not open $file";          || die "could not open $file";
17054      flock(TMP,LOCK_EX) || confess "cannot lock $file";      flock(TMP,LOCK_EX) || confess "cannot lock $file";
# Line 17045  Line 17058 
17058  }  }
17059    
17060    
17061  sub add_translation {  sub add_sequence {
17062      my($self,$fid,$translation) = @_;      my($self,$fid,$seq) = @_;
17063    
17064        my $type;
17065        if ($fid =~ /^fig\|\d+\.\d+\.([a-zA-Z0-9_-]+)/)
17066        {
17067            $type = $1;
17068        }
17069        else
17070        {
17071            return "";
17072        }
17073      my $genome = &genome_of($fid);      my $genome = &genome_of($fid);
17074      my $file   = "$FIG_Config::organisms/$genome/Features/peg/fasta";      &verify_dir("$FIG_Config::organisms/$genome/Features/$type");
17075        my $file   = "$FIG_Config::organisms/$genome/Features/$type/fasta";
17076      if (open(TMP,">>$file"))      if (open(TMP,">>$file"))
17077      {      {
17078          flock(TMP,LOCK_EX) || confess "cannot lock $file";          flock(TMP,LOCK_EX) || confess "cannot lock $file";
17079          print TMP ">$fid\n";          print TMP ">$fid\n";
17080          my $seek = tell TMP;          my $seek = tell TMP;
17081          my $ln   = length($translation);          my $ln   = length($seq);
17082          print TMP "$translation\n";          print TMP "$seq\n";
17083          close(TMP);          close(TMP);
17084          chmod 0777, $file;          chmod 0777, $file;
17085          my $fileno = $self->file2N($file);          my $fileno = $self->file2N($file);
17086    
17087            if ($type eq "peg")
17088            {
17089          my $dbh = $self->db_handle();          my $dbh = $self->db_handle();
17090          $dbh->SQL("DELETE FROM protein_sequence_seeks where id = '$fid'");          $dbh->SQL("DELETE FROM protein_sequence_seeks where id = '$fid'");
17091          $dbh->SQL("INSERT INTO protein_sequence_seeks (id,fileno,seek,len,slen)          $dbh->SQL("INSERT INTO protein_sequence_seeks (id,fileno,seek,len,slen)
17092                            VALUES ('$fid',$fileno,$seek,$ln+1,$ln)");                            VALUES ('$fid',$fileno,$seek,$ln+1,$ln)");
17093      }      }
17094  }  }
17095    }
17096    
17097  sub peg_in_gendb  sub peg_in_gendb
17098  {  {

Legend:
Removed from v.1.563  
changed lines
  Added in v.1.564

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3