[Bio] / GBBergeyDB / checkGenomeNamesForAliases.pl Repository:
ViewVC logotype

View of /GBBergeyDB/checkGenomeNamesForAliases.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (as text) (annotate)
Thu Apr 5 15:15:28 2007 UTC (12 years, 8 months ago) by bartels
Branch: MAIN
CVS Tags: HEAD
*** empty log message ***

#!/usr/bin/env /home/bartels/FIGdisk/env/cee/bin/perl

use strict;
use warnings;
use lib "../PPO/";
use DBMaster;
use GenomeParser;
use GenomeMapper;

my $dbmaster = DBMaster->new( 'GBBergeyDB' );

print STDERR "getting all species\n";

my $speciesArr = $dbmaster->Species->get_objects();

print STDERR "going through species\n";

my $counter = 0;
my $allnum = scalar @$speciesArr;

my $counthash = { 'phylac'  => 0,
		  'classc'  => 0,
		  'orderc'  => 0,
		  'familyc' => 0,
		  'genusc'  => 0 };

foreach my $species ( @$speciesArr ) {
  
  $counter++;
  if( ( $counter % 100 ) == 0 ) {
    print STDERR "$counter of $allnum \r";
  }

  my $name = $species->name;

  my $nameArr = $dbmaster->GenomeAlias->get_objects( { 'name' => $name } );

  if ( defined( $nameArr->[0] ) && ( $nameArr->[0]->ident == 0 ) ) {
    print $name ."\tshould be\t" .$nameArr->[0]->scientificName ."\t";
    my $speciesArr2 = $dbmaster->Species->get_objects( { 'name' => $nameArr->[0]->scientificName } );
    if ( defined( $speciesArr2->[0] )  ) {
      print "ISIN: ".$speciesArr2->[0]->_id."\t";
      $species->ScientificSpecies( $speciesArr2->[0] );
      my $textmeet = getMeetingPoint( $species, $speciesArr2->[0], $counthash );
      print $textmeet;
    }
    else {
      print "NOTIN\n";
    }
  }
}

print "\n\nSTATISTICS\n----------\n\n";

foreach my $k ( keys %$counthash ) {
  print $k."\t". $counthash->{ $k }."\n";
}


sub getMeetingPoint {

  my ( $genome1, $genome2, $counthash ) = @_;
  
  if ( $genome1->Genus->_id == $genome2->Genus->_id ) {
    $counthash->{ 'genusc' } ++;
    return "Genus: " . $genome1->Genus->name."\n";
  }
  if ( $genome1->Genus->Family->_id == $genome2->Genus->Family->_id ) {
    $counthash->{ 'familyc' } ++;
    return "Family: " . $genome1->Genus->Family->name."\n";
  }
  if ( $genome1->Genus->Family->GOrder->_id == $genome2->Genus->Family->GOrder->_id ) {
    $counthash->{ 'orderc' } ++;
    return "Order: " . $genome1->Genus->Family->GOrder->name."\n";
  }
  if ( $genome1->Genus->Family->GOrder->Class->_id == $genome2->Genus->Family->GOrder->Class->_id ) {
    $counthash->{ 'classc' } ++;
    return "Class: " . $genome1->Genus->Family->GOrder->Class->name."\n";
  }
  if ( $genome1->Genus->Family->GOrder->Class->Phyla->_id == $genome2->Genus->Family->GOrder->Class->Phyla->_id ) {
    $counthash->{ 'phylac' } ++;
    return "Phyla: " . $genome1->Genus->Family->GOrder->Class->Phyla->name."\n";
  }

}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3