[Bio] / DomReg / scripts / add_RegulatorInstance_to_FIGRegulons.pl Repository:
ViewVC logotype

View of /DomReg/scripts/add_RegulatorInstance_to_FIGRegulons.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (as text) (annotate)
Thu Apr 19 20:28:39 2007 UTC (12 years, 10 months ago) by mkubal
Branch: MAIN
CVS Tags: HEAD
v1

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

#use strict;
#use warnings;

use lib '/home/mkubal/PPO/';
use lib '/home/mkubal/DomReg/';

use DBMaster;

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

#$DataSource_name = shift(@ARGV);
#$DataSource_version = shift(@ARGV);

$DataSource_name = "RegTransbase";
$DataSource_version = "20060209_1006";

my $source_objs;
my $source_obj;

$source_objs =  $dbmaster->DataSource->get_objects( { 'name' => $DataSource_name,
						     'version' => $DataSource_version
						   } );
if(!scalar(@$source_objs)){
    $source_obj = $dbmaster->DataSource->create( { 'name'    => $DataSource_name,
						   'version' => $DataSource_version
						   } );
}
else{
    $source_obj = $source_objs->[0];
}   

open(IN,"/home/mkubal/DomReg/data/regulator_table.txt");
while($_ = <IN>){
    my $name,$figid,$action;
    chomp($_);
    @parts = split("\t",$_);
    $name  = $parts[1];
    $peg  = $parts[2];
    $action  = $parts[3];
    $family = $parts[4];
    if($peg){
	my $regulator_instance_obj, $regulator_obj, $regfam_obj, $regfam, $regulator;
	
#checking for existence of family, adding if not already created
	
	if($family =~/\w/){
	    $regfam_obj =  $dbmaster->RegFam->get_objects( { 'name' => $family } );
	    if(scalar(@$regfam_obj == 0)){
		$regfam_obj = $dbmaster->RegFam->create( { 'name'    => $family } );
		$regfam = $regfam_obj;
	    }
	    else{
		$regfam = $regfam_obj->[0];
	    }
	}
	
       
#checking for existence of regulator, adding if not already created

	if($name =~/\w/){
	    $regulator_obj =  $dbmaster->Regulator->get_objects( { 'name' => $name } );
            $temp = scalar(@$regulator_obj);
	    if(scalar(@$regulator_obj) == 0){
	   	$regulator_obj = $dbmaster->Regulator->create( { 'name'    => $name,
								 'RegFam' => $regfam
								 } );
                $regulator = $regulator_obj;
	    }
	    else{
		$regulator = $regulator_obj->[0];
	    }
	}

#checking for existence of regulator instance, adding if not already there       
	$regulator_instance_obj =  $dbmaster->RegulatorInstance->get_objects( { 'figid' => $peg } );
	if(scalar(@$regulator_instance_obj) == 0){
	    $regulator_instance_obj = $dbmaster->RegulatorInstance->create( { 'name'    => $name,
									      'action'  => $action,
									      'figid'   => $peg,
									      'Regulator' => $regulator,
									      'DataSource' => $source_obj
									      } );
	    print "$peg\n";
       }
    }
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3