[Bio] / FigKernelScripts / update_lineage.pl Repository:
ViewVC logotype

View of /FigKernelScripts/update_lineage.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (download) (as text) (annotate)
Thu Dec 6 16:50:46 2007 UTC (12 years, 5 months ago) by wilke
Branch: MAIN
Changes since 1.1: +23 -8 lines
*** empty log message ***

use FIG;
use strict;
use warnings;

use vars qw( $opt_d $opt_g $opt_h );
use Getopt::Std;


getopts('d:g:o:');

my $success;
my $usage = "update_lineage -d DIR\n";

unless ($opt_d and -d $opt_d) {
  print $usage;
  exit;
}

my $org_dir = $opt_d;

my $fig = new FIG;

my $counter = 0;

my @genomes = $fig->genomes;
print scalar @genomes , " genomes are currently in SEED\n";

foreach my $genome (@genomes) {

  my ( $tax_id ) = $genome =~ /(\d+)\.\d+/ ;
  unless ( $tax_id ){
    print STDERR "No taxonomy id for $genome\n";
  }

  my ( $overview ) = $fig->get_organism_info_from_ncbi($tax_id);
  print $genome , "\n";
  print $overview->{lineage} , "; ".$fig->genus_species($genome), "\n";
  
  #$success= update_organism_dir( $fig , $dir, $genome , $overview);
  #{ exit } unless $success;
  
  $counter ++;
  exit if ($counter > 10);
  sleep 10 ;
}

sub update_organism_dir{
  my ( $fig , $dir , $org , $overview) = @_;
  
  return 0 unless (-d "$dir/$org");

  #update TAXONOMY file
  #open(TMP,">$dir/$org/TAXONOMY") || die "could not open $dir/$org/TAXONOMY";
  #print TMP $overview->{lineage}."; ".$fig->genus_species($org)."\n";
  #close(TMP);

  open(TMP,">$dir/$org/TAXONOMY_ID") || die "could not open $dir/$org/TAXONOMY";
  print TMP $overview->{taxonomy_id}."\n";
  close(TMP);

  chmod(0777,"$dir/$org/TAXONOMY_ID");

  #update database entry

  my $old_lineage = $fig->taxonomy_of($org);
  
  return 1;
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3