[Bio] / FortyEight / check_rast_genome.pl Repository:
ViewVC logotype

View of /FortyEight/check_rast_genome.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (download) (as text) (annotate)
Thu Mar 20 19:18:56 2008 UTC (11 years, 8 months ago) by wilke
Branch: MAIN
CVS Tags: mgrast_dev_08112011, rast_rel_2009_05_18, mgrast_dev_08022011, rast_rel_2014_0912, rast_rel_2008_06_18, rast_rel_2008_06_16, mgrast_dev_05262011, rast_rel_2008_12_18, mgrast_dev_04082011, rast_rel_2008_07_21, rast_rel_2010_0928, rast_2008_0924, mgrast_version_3_2, mgrast_dev_12152011, rast_rel_2008_04_23, mgrast_dev_06072011, rast_rel_2008_09_30, rast_rel_2009_0925, rast_rel_2010_0526, rast_rel_2014_0729, mgrast_dev_02212011, rast_rel_2010_1206, mgrast_release_3_0, mgrast_dev_03252011, rast_rel_2010_0118, mgrast_rel_2008_0924, mgrast_rel_2008_1110_v2, rast_rel_2009_02_05, rast_rel_2011_0119, mgrast_rel_2008_0625, mgrast_release_3_0_4, mgrast_release_3_0_2, mgrast_release_3_0_3, mgrast_release_3_0_1, mgrast_dev_03312011, mgrast_release_3_1_2, mgrast_release_3_1_1, mgrast_release_3_1_0, mgrast_dev_04132011, rast_rel_2008_10_09, mgrast_dev_04012011, rast_release_2008_09_29, mgrast_rel_2008_0806, mgrast_rel_2008_0923, mgrast_rel_2008_0919, rast_rel_2009_07_09, rast_rel_2010_0827, mgrast_rel_2008_1110, myrast_33, rast_rel_2011_0928, rast_rel_2008_09_29, mgrast_rel_2008_0917, rast_rel_2008_10_29, mgrast_dev_04052011, mgrast_dev_02222011, rast_rel_2009_03_26, mgrast_dev_10262011, rast_rel_2008_11_24, rast_rel_2008_08_07, HEAD
Changes since 1.1: +0 -2 lines
*** empty log message ***

# computes some comparision data for rast genomes 
# look up NCBI and SEED

use strict;
use warnings;
use vars qw($opt_d $opt_u $opt_o $opt_h $opt_v);
use Getopt::Std;
use DBI;
use FIG;
use GenomeMeta;
use ContigMD5;
use LWP::Simple;

#use TraceLog qw(TL_WARNING TL_ERROR TL_VERBOSE);

use constant META_FILE => "meta.xml";


my ($dir,$verbose,$update_meta, $overwrite_submit_candidate) = check_opts();

unless (-d $dir) {
  print STDERR "No directory \n";
  &help;
  exit;
}

# $data->{job_directory}
# $data->{sequences}
# $data->{name} 
# $data->{message} 
# $data->{error} 
# $data->{taxonomy_id}
# $data->{ fig_id_for_name } 
# $data->{ fig_ids_for_tax_id }
# $data->{ seed_contigs_for_name }
# $data->{ seed_contigs_for_taxonomy }
# $data->{contig_in_seed}->{ $contig } = { checksum => $cksum,
# 					 fig_id   => $gen,
# 				       };


my $data = {};
my $fig = new FIG;

$data->{job_directory} = $dir;

my $error                                  = check_organism_dir($dir);
$data->{sequences}                         = get_sequences_from_organism_dir($dir) if ($dir);
my ($genomes , $ids)                       = get_seed_genomes($fig);

($data->{ name }, 
 $data->{ taxonomy_id }, 
 $data->{ fig_id } )                       = get_organism_and_tax_id_from_organism_dir($dir);

$data->{ fig_id_for_name }                 = check_organism_name( $data->{name} , $genomes); 
$data->{ fig_ids_for_tax_id }              = check_tax_id( $data->{ taxonomy_id } , $ids );
$data->{ nr_matched_contigs }              = check_checksums($data);

print "check ncbi contigs\n";
check_nr_contigs_at_ncbi( $data );
print "checked\n";
get_contig_info_from_seed( $data );
create_output( $data ) if ( $verbose );
make_decision( $data );
write_statistic_to_file( $data );

print STDERR "next update_meta_file\n";
update_meta_file( $dir, $data , $overwrite_submit_candidate) if ( $update_meta);




#print STDERR "END \n";
exit;

sub check_nr_contigs_at_ncbi{
  my ($data) = @_;

  my $url = "http://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?id=";
  my $search_result = get($url.$data->{ taxonomy_id });


  my @lines = split ( "\n" , $search_result);
  
  my $nr_seq = 0;
  my $nr_proj = 0;
  my $url_seq = "";
  my $url_proj = "";
  my $genome_name = "";
  
  my $next = "";
  foreach my $line ( @lines ){

    if ( $next eq "Sequences"){
      ($url_seq)   = $line =~ m/href="([^"]*)"/;
      ($nr_seq) = $line =~ m/>(\d*)<\/font/;
      
      print "Genome Sequences: $nr_seq\n";
      
      
      $next = "";
    }
    elsif ( $next eq "Projects"){
      ($url_proj) = $line =~ m/href="([^"]*)"/;
      ($nr_proj) = $line =~ m/>(\d*)<\/font/;
      
      print "Genome Projects: $nr_proj \n";
      
      
      $next = "";
    }
    
    if ( $line =~ /<title>Taxonomy browser/ ){
      print $line,"\n";
    }
    if ( $line =~ m/<title>Taxonomy browser/){
      print $line,"\n";

    }
    if ( $line =~ /<title>Taxonomy browser\s*\(([^()]+)\)\<\/title\>/ ) {
      $genome_name = $1;
      print "Genome Name = $1\n";
    }
    
    if ($line =~ m/(Genome[\w;&]+Sequence)/){
      $next = "Sequences";
  } 
    elsif ($line =~ m/(Genome[\w;&]+Projects)/){
      $next = "Projects";
    }
    
}

  print $genome_name,"\n";
 

  $data->{ ncbi_genome } = $genome_name;
  $data->{ ncbi_nr_projects } = $nr_proj;
  $data->{ ncbi_nr_seq } = $nr_seq;
}


sub get_contig_info_from_seed{
  my ( $data ) = @_;

  # get contigs for orgaism name
  if ( $data->{ fig_id_for_name } ) {
    my @contig_ids = $fig->all_contigs($data->{fig_id_for_name} );
    $data->{ seed_contigs_for_name } = \@contig_ids;
  }

  # get contigs for taxonomy
  if ( $data->{ fig_ids_for_tax_id } ) {
    
    foreach my $id   (@{$data->{ fig_ids_for_tax_id } } ) {
      my @contig_ids = $fig->all_contigs($id);
      $data->{ seed_contigs_for_taxonomy }->{ $id } =  \@contig_ids;
    }
  }
  return $data;
}


sub check_checksums{
  my ($data) = @_;
  my $matched_contigs = 0;
  
  foreach my $sq (@{$data->{sequences}}){
    
    my $c = new ContigMD5;
    $c->add( $sq );
    my $cksum = $c->checksum();
    #print $cksum,"\n";
    my ($contig, $gen , $error) = $fig->md5sum_to_contig_genome( $cksum );
    
    if ($contig){
      #print "Contig is in the SEED\n";
      $data->{contig_in_seed}->{ $contig } = { checksum => $cksum,
					       fig_id   => $gen,
					     };
      $matched_contigs++;
      #print $cksum,"\t",$contig,"\t",$gen,"\n";
    }
    if ( $error ){
      $data->{ error } = $error;
      $data->{ message } .= $error;
    }
  }
  return $matched_contigs;
}
 

sub get_seed_genomes{
  my ($fig) = @_;
  my $genomes = {};
  my $ids = {};

  my @gs = $fig->genomes();
  foreach my $g ( @gs ) {
    my $name = $fig->genus_species( $g );
    $genomes->{ $name } = $g;
    my ($id) = $g =~/(\d+)\.\d+/;
    
    if ( $ids->{ $id } ){
      push @{$ids->{ $id }} , $g ;
    }
    else{
      $ids->{ $id } = [$g];  
    }
  }

  return ($genomes, $ids);
}

sub help{
  print "check_rast_genome.pl -d organism_directory \n";
  exit;
}

sub check_opts{
  # initialise
  my ( $dir , $verbose , $update_meta) = ("","0","0");
  getopts('d:uvoh');
  
  help if ($opt_h);
 
  if (($opt_d) && (-d $opt_d)){
    $dir = $opt_d;;
  }
  else{
    print STDERR "No directory!\n";
    help;
  }

  $verbose = 1 if ($opt_v);
  $update_meta = 1 if ( $opt_u );
  my $overwrite_submit_candidate = 0;
  $overwrite_submit_candidate = 1 if ( $opt_o);

  return ( $dir, $verbose, $update_meta, $overwrite_submit_candidate);
}

sub check_organism_dir{
  my ( $dir ) = @_;
  my $error = 0;
  unless ( -f $dir."/DONE" ) {
  }
  if ( -f $dir."/ERROR" ) {
    $error = "\nCheck job directory, there has been an error!\nDon't process $dir.\n\n";
    print STDERR $error;
    exit;
  }

  return $error;
}

sub get_organism_and_tax_id_from_organism_dir{
  my ($dir) = @_;

  my $id;
  my $name;

  my @id_files = `find $dir -name GENOME_ID`;
  my @genome_files = `find $dir -name GENOME`;

  if ( scalar @id_files ){
    open (FILE, $id_files[0] ) or die "Can't open $id_files[0]\n";
    $id = <FILE>;
    close(FILE);
  }
  else{
    print STDERR "No GENOME_ID file in $dir!\n";
    exit;
  }

  if ( scalar @genome_files ){
    open (FILE, $genome_files[0] ) or die "Can't open $genome_files[0]\n";
    $name = <FILE>;
    close(FILE);
  }
  else{
    print STDERR "No GENOME file in $dir!\n";
    exit;
  }
  
  my ($seed_tax) = $id =~ /(\d+)\.\d+/;
  chomp $name;
  chomp $id;
  return ( $name ,  $seed_tax,  $id);

}



# exctract sequences from contigs file
sub get_sequences_from_organism_dir{
  my ($dir) = @_;
  my @sequences;

  $dir = $dir."/raw" if (-d $dir."/raw");
  my @files = `find $dir -name contigs`;

  foreach my $file (@files) {
    print STDERR "Use contig file: $file\n" if $verbose;
    open (FILE , $file) or die "Can't open file $file\n";

    my $seq = "";
    while (my $line = <FILE>) {
      if ($line =~ /^>/){
	push @sequences, $seq if ($seq);
	$seq = "";
      }
      else{
	chomp $line;
	$seq .= $line;
      }

    }
    push @sequences, $seq if ($seq); # get the last entry too
    close(FILE);

  }
  return \@sequences;
}


sub check_organism_name{
  my ( $org , $list ) = @_;

  # simple check
  
  my $fig_id = $list->{ $org };

  return $fig_id;
}

sub check_tax_id{
  my ( $id , $list ) = @_;

  #simple check

  my $fig_versions = $list->{ $id };

  return $fig_versions;

}

sub create_output{
  my ($data) = @_;

  # for organism name
  if ( $data->{ fig_id_for_name } ) {
    print "SEED id found for organism  ".$data->{ name }." : ".$data->{ fig_id_for_name }."\n";
  
   my $contig_ids = $data->{ seed_contigs_for_name };
   print scalar @$contig_ids," contigs in the seed for ". $data->{ fig_id_for_name } ."\n";
 }

  # for taxonomy 
  print "\nFound following ids for given taxonomy: " if ( $data->{ fig_ids_for_tax_id }  );
  print join " ",@{ $data->{ fig_ids_for_tax_id } },"\n" if ($data->{ fig_ids_for_tax_id }  );
  
  foreach my $id   (@{$data->{ fig_ids_for_tax_id } } ) {
    print scalar @{ $data->{ seed_contigs_for_taxonomy }->{ $id } }," contigs in the seed for $id\n";
  }

  # from organism dir
  print "\n";
  print scalar @{$data->{sequences}} , " contigs in organism dir\n\n";

  # for compared contigs
  if (keys %{ $data->{ contig_in_seed } } ){

    
    print "Contig is in the SEED:\n";
    foreach my $contig ( keys %{ $data->{ contig_in_seed } } ) {
      
      print $data->{contig_in_seed}->{ $contig }->{ checksum },"\t",
	$contig,"\t",$data->{contig_in_seed}->{ $contig }->{ fig_id },"\n";
    }
  }

  if ( $data->{ message }  ){
    print $data->{ message },"\n";
  }
  if  ( $data->{ error }  ){
    print "\nThere has been an error:\n",$data->{ error },"\n";
  }
 
}


sub write_statistic_to_file{
  my ($data) = @_;

  my $job_dir = $data->{ job_directory };
  open (FILE , ">$job_dir/import_info.txt");
  
  # for organism name
  my $seed_id = $data->{ fig_id_for_name } || '';
  print FILE "SEED_ID\t".$seed_id."\n";
    
  my $contig_ids = $data->{ seed_contigs_for_name } || [];
  print FILE "NR_SEED_CONTIGS\t" . scalar @$contig_ids ,"\n"; 


  # for taxonomy 
  if ($data->{ fig_ids_for_tax_id }  ) {
    foreach my $id   (@{$data->{ fig_ids_for_tax_id } } ) {
      print FILE "TAX_ID_TO_FIG_IDS\t" . join " ",@{ $data->{ fig_ids_for_tax_id } },"\t",scalar @{ $data->{ seed_contigs_for_taxonomy }->{ $id } },"\n" ;
    }
     print FILE "TAX_ID_TO_FIG_IDS\tnone\t\n"  unless scalar @{$data->{ fig_ids_for_tax_id }} ; 
  }
  else{
     print FILE "TAX_ID_TO_FIG_IDS\tnone\t\n"; 
  }

 

  # from organism dir
  print "\n";
  print FILE "NR_RAST_CONTIGS\t" . scalar @{$data->{sequences}} , "\n";

  # for compared contigs
  my $matched_contigs = 0;
  if (keys %{ $data->{ contig_in_seed } } ){ 
    $matched_contigs = scalar keys %{ $data->{ contig_in_seed } } ; 
  }
  print FILE "NR_MATCHED_CONTIGS\t$matched_contigs\n";

  if ( $data->{ message }  ){
    $data->{ message } =~ s/\n/<br>/g; 
    $data->{ message } =~ s/\t/ - /g;
    print FILE "NOTE\t".$data->{ message } ."\n";
  }
  if  ( $data->{ error }  ){
    print FILE "ERROR\t" . $data->{ error } ."\n";
  }

  my $ncbi_genome = $data->{ ncbi_genome } || "none";
  print FILE "TAX_ID_TO_NCBI_GENOME\t$ncbi_genome\n";
  print FILE "NR_NCBI_GENOME_PROJECTS\t" . $data->{ ncbi_nr_projects } ."\n";
  print FILE "NR_NCBI_CONTIGS\t" . $data->{ ncbi_nr_seq } ."\n";
 
  close (FILE)
}


sub update_meta_file{
  my ($job_dir,$data,$overwrite_submit_candidate) = @_;
 
  my $var = '';
 
  unless ( -f $job_dir."/".META_FILE ){
    print STDERR  "No ".$job_dir."/".META_FILE,"\n";
    exit;
  }

  print STDERR "Get meta.xml file\n";
  #print STDERR "Overwriting: $overwrite_submit_candidate\n";

  my $meta = new GenomeMeta($data->{ fig_id }, $job_dir."/".META_FILE);

  
  
  if ( $data->{ fig_id_for_name } and 
       ($meta->get_metadata("v2c2.fig_id_for_name") ne $data->{ fig_id_for_name }) 
     ){
    $meta->set_metadata("v2c2.fig_id_for_name",$data->{ fig_id_for_name });
  }


  if ( $data->{ seed_contigs_for_name } ){
    $var = scalar @{ $data->{ seed_contigs_for_name } };  
  }
  else{    
    $var = 0;
  }
  if ($meta->get_metadata("v2c2.nr_contigs_for_name") ne $var) {
    $meta->set_metadata("v2c2.nr_contigs_for_name", $var) ;
  }
  $var = '';


  if ( $data->{ fig_ids_for_tax_id } ) {
   $var =  join ";" , @{ $data->{ fig_ids_for_tax_id } } ;
  }
  if  ($meta->get_metadata("v2c2.fig_ids_for_tax_id") ne $var ) {
    $meta->set_metadata("v2c2.fig_ids_for_tax_id", $var);
  }
  $var = '';
  

  if  ( $data->{ seed_contigs_for_taxonomy } ) {

    my $nr_contig = 0;
    foreach my $id ( keys %{ $data->{ seed_contigs_for_taxonomy } } ) {
      
      ( $nr_contig ) ?  $nr_contig .= ":".scalar @{ $data->{ seed_contigs_for_taxonomy }->{ $id } } : $nr_contig = scalar @{ $data->{ seed_contigs_for_taxonomy }->{ $id } } ;
    }

    $meta->set_metadata("v2c2.nr_contigs_for_tax_id", $nr_contig) if ($meta->get_metadata("v2c2.nr_contigs_for_tax_id") ne $nr_contig);
  }
  
  $meta->set_metadata("v2c2.nr_contigs_in_org_dir", scalar @{ $data->{ sequences } } )if ( $meta->get_metadata("v2c2.nr_contigs_in_org_dir") ne (scalar @{ $data->{ sequences } } ) );


  # count matched contigs
  my $matched_contigs = "";
  my $nr_matched_contigs = 0;
  if (keys %{ $data->{ contig_in_seed } } ){
 
    foreach my $contig ( keys %{ $data->{ contig_in_seed } } ) {
      $nr_matched_contigs++;
      $matched_contigs .=  $contig."\t".$data->{contig_in_seed}->{ $contig }->{ fig_id }."\n";
    }
  }

  if ($meta->get_metadata("v2c2.matched_contigs") ne $matched_contigs){
    $meta->set_metadata("v2c2.matched_contigs", $matched_contigs );
  }
  if ($meta->get_metadata("v2c2.nr_matched_contigs") ne $nr_matched_contigs){
    $meta->set_metadata("v2c2.nr_matched_contigs", $nr_matched_contigs );
  }



  # set submit candidate
  my $info_submit_candidate = $meta->get_metadata("submit.candidate");

  if ( $data->{ remove_candidate} and $overwrite_submit_candidate ){
    print STDERR "Set submit.candidate\n";
    $meta->set_metadata("submit.candidate", 0 ) if ($meta->get_metadata("submit.candidate") ne  "0" );
  }

  if ( (defined $data->{ replace_seedID}) and ( $meta->get_metadata("replace.seedID") ne $data->{ replace_seedID }) ) {
    $meta->set_metadata("replace.seedID", $data->{ replace_seedID }) if ( (defined $data->{ replace_seedID}) and $overwrite_submit_candidate );
  }
  if  ( $meta->get_metadata("v2c2.message") ne $data->{ message }) {
    $meta->set_metadata("v2c2.message", $data->{ message });
  }
  

  return 1;
}

sub make_decision {
  my ( $data ) = @_;
  my $meta;
  
  my $msg = "";
  # 1. name , tax , contigs match -> same genome
  # 2. name , tax  match same number of contigs but checksum does not match -> different/new version 
  # 3. name , tax  match different number of contigs -> different/new version
  # 4. name matches , tax differs
  # 5. name differs, tax matches
  # 6, name , tax differs contigs matches -> problem
  # 7. name , tax , contigs differ -> new genome
  

  if ( $data->{ replace_seedID } ) {
    print STDERR "Replace ID submitted : ".$data->{ replace_seedID },"\n";
    exit;
  }

  # get matched contigs
  my $matched_contigs = "";
  my $nr_matched_contigs = 0;

  if (keys %{ $data->{ contig_in_seed } } ){  
    foreach my $contig ( keys %{ $data->{ contig_in_seed } } ) {
      $nr_matched_contigs++;
      $matched_contigs .=  $contig."\t".$data->{contig_in_seed}->{ $contig }->{ fig_id }."\n";
    }
  }
  $data->{ matched_contigs } = $matched_contigs;
  $data->{ nr_matched_contigs } = $nr_matched_contigs;

  # name is matching
  if  ( $data->{ fig_id_for_name } ) {

    # check for taxonomy 
    if (scalar @{$data->{ fig_ids_for_tax_id }} == 1){
      my $fig_id = $data->{ fig_ids_for_tax_id }->[0];
      
      # name and taxonomy matches
      if ( $fig_id eq $data->{ fig_id_for_name } ){
	# set ID for replacement
	$data->{ replace_seedID } = $fig_id;
	
	if (  @{ $data->{ sequences } } < @{ $data->{ seed_contigs_for_name } } ) {
	  $msg .= "less contigs than seed contigs, probably new version\n";
	}
	elsif (  @{ $data->{ sequences } } > @{ $data->{ seed_contigs_for_name } } ) {
	  $msg .= "more contigs than seed contigs, either older version or new genome project\n";
	}
	else{
	 
	  if  (scalar @{ $data->{ seed_contigs_for_name } } == $data->{ nr_matched_contigs } ){
	    $msg .= "same version, don't import\n";
	    
	    $data->{ remove_candidate } = 1;
	  }
	  else{
	    
	    $msg .= "same number of contigs but not same contigs\n";
	  }
	}
	
      }
      # different id for taxonomy and org name
      else{
	$msg .= "ID for taxonomy doesn't match id for organism name: $fig_id and ". $data->{ fig_id_for_name }."\n";
      }
      
    }
    elsif (scalar @{$data->{ fig_ids_for_tax_id }} > 1){ 
      $msg .= "Geome exists in different versions: ". join (" ", @{$data->{ fig_ids_for_tax_id }} )."\n";
    }
    else{
      # no match for name and taxonomy
      # check for contigs
      
      if ( $data->{ nr_matched_contigs} ){
	$msg .= "Contigs found in the SEED, but no match for name and taxonomy\n";
	$msg .= $data->{ matched_contigs };
      }
      else{
	$msg .= "probably new genome\n";
      }

    }
    
  } 
  # name is not matching
  else{

    # check taxonomy
    if ( ref $data->{ fig_ids_for_tax_id } and scalar ( @{$data->{ fig_ids_for_tax_id }} ) == 1){
      
      my $fig_id_for_taxonomy = $data->{ fig_ids_for_tax_id }->[0];
      
      $msg .= "Seems to be an existing genome ( $fig_id_for_taxonomy ) but name is not correct. Please check organism name.\n";
      

      if (  @{ $data->{ sequences } } < @{ $data->{ seed_contigs_for_taxonomy }->{ $fig_id_for_taxonomy } } ) {
	$msg .= "less contigs than seed contigs, probably new version\n";
      }
      elsif (  @{ $data->{ sequences } } > @{ $data->{ seed_contigs_for_taxonomy }->{ $fig_id_for_taxonomy } } ) {
	$msg .= "more contigs than seed contigs, either older version or new genome project\n";
      }
      else{
	if  ( $data->{ seed_contigs_for_name } and scalar @{ $data->{ seed_contigs_for_name } } == $data->{ nr_matched_contigs } ){
	  $msg .= "same version, don't import\n";
	  $data->{ remove_candidate } = 1;
	}
      }
      
    }
    elsif (ref $data->{ fig_ids_for_tax_id } and scalar @{$data->{ fig_ids_for_tax_id }} > 1){ 
      $msg .= "Geome exists in different versions: ". join (" ", @{$data->{ fig_ids_for_tax_id }} )."\n";
    }
    else{
      # no match for name and taxonomy
      # check for contigs
      
      if ( $data->{ nr_matched_contigs} ){
	$msg .= "Contigs found in the SEED, but no match for name and taxonomy\n";
	$msg .= $data->{ matched_contigs };
      }
      else{
	$msg .= "probably new genome\n";
      }
    }
  }
  if ( $data->{ ncbi_nr_seq} ne  @{ $data->{ sequences } } ){
    my $ncbi_tag = $data->{ ncbi_genome} || $data->{ taxonomy_id } ;
    $msg .= "NCBI has ".$data->{ ncbi_nr_seq}." sequences and " . $data->{ ncbi_nr_projects} . " projects for ".$ncbi_tag." in the Taxonomy Browser!<hr>";
  
  my $user = get_user_from_job( $data );
    if ( $user eq "batch"){
       $data->{ remove_candidate } = 1;
    }

  }
  if (  $data->{ ncbi_genome } and $data->{ ncbi_genome } ne $data->{ name } ){
    $msg .= "Different genome name at the NCBI for this taxonmy id: <b> ".$data->{ ncbi_genome }."</b>\n"; 
    
    my $user = get_user_from_job( $data );
    if ( $user eq "batch"){
       $data->{ remove_candidate } = 1;
    }

  } 

  $data->{ message } = $msg;
  return $data;
}


sub get_user_from_job{
  my ( $data ) = @_;
  my $user = "";
  
  if ( -f $dir."/USER" ) {
    open (FILE , "$dir/USER") or die "Can't open $dir/USER\n";
    $user = <FILE>;
    close FILE;
    chomp $user;
  }

  return $user;
}


sub _unspace{
  my ($line) =@_;
  my @words = split (/\s+/ , $line );
  $line = join( " ", @words);
  return $line;
}




MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3