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

View of /FigKernelScripts/make_pdb_ontology.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (download) (as text) (annotate)
Wed Dec 12 22:52:36 2007 UTC (12 years, 6 months ago) by mkubal
Branch: MAIN
CVS Tags: rast_rel_2008_06_18, rast_rel_2008_06_16, rast_rel_2008_04_23
Changes since 1.1: +2 -2 lines
specify database as argument

use FIG;
use lib PPO;
use lib Ontology;
use DBMaster;

my $sqlite_db = shift(@ARGV);
my $dbmaster = DBMaster->new(-database => $sqlite_db, -backend => 'SQLite');

opendir(DIR,"/vol/biodb/pdb/data/structures/all/uncompressed");
my @files = readdir(DIR);
foreach my $file (@files){
    if($file =~/^pdb(.*)\.ent/){
	my $id = $1;
	open(IN,"/vol/drugtargets/PDB/PDB-U/$file");
	my $find_ligand_on_next_line = 0;
	my $find_source_on_next_line = 0;
	my $record_source = 1;
	my ($description,$ligand, $source,$keywords);
	my $source = "NONE";
	while($_ = <IN>){
	    chomp($_);
	    if($_ =~/^HEADER\s+(.*)\d+-\w+-\d+\s+.*\d\w{3}\s+\d+$/){
		$description = $1;
		$description =~s/(\s+)$//;
	    }
	    
	    if($find_ligand_on_next_line){
		if($_ =~/^COMPND\s+(.*)\d\w{3}\s+\d+$/){
		    $ligand = $1;
		    $ligand =~s/(\s+)$//;
		}
		$find_ligand_on_next_line = 0;
	    }
	    
	    if($_ =~/^COMPND\s+.*COMPLEX\sWITH\s(.*)\d\w{3}\s+\d+$/){
		$ligand = $1;
		$ligand =~s/(\s+)$//;
		if(($ligand !~/\w+/) || ($ligand =~/^THE$/)){
		    $find_ligand_on_next_line = 1;
		}
	    }
	    
	    if($record_source){
		if($find_source_on_next_line){
		    if($_ =~/^SOURCE\s+(.*)/){
			my $temp = $1;
			if($source !~/(EXPRESSION_SYSTEM|MOL_ID)/){
			    $source = $temp;
			    $record_source = 0;
			    $find_source_on_next_line = 0;
			}
		    }
		}
	    }
	    
	    if($record_source){
		if($_ =~/^SOURCE\s+(.*)/){
		    $source = $1;
		    if($source =~/(MOL_ID|EXPRESSION_SYSTEM)/){
			$find_source_on_next_line = 1;
			$source = "NONE";
		    }
		    else{$record_source = 0;}
		    
		}
	    }
	    if($_ =~/^KEYWDS\s+(.*)/){
		$keywords = $1;
		my ($dt_objs,$dt_obj);
		$dt_objs =  $dbmaster->pdb->get_objects( { 'id' => $id } );
		if(scalar(@$dt_objs) == 0){ 
		    $dt_obj = $dbmaster->pdb->create( { 'id'    => $id,
						       'description' => $keywords,
						       'ligand' => $ligand,
						       'source' => $source
						       } );
		}
		last;
	    }
	       
	       
	    if($_ =~/^REMARK/){
		my ($dt_objs,$dt_obj);
		$dt_objs =  $dbmaster->pdb->get_objects( { 'id' => $id } );
		if(scalar(@$dt_objs) == 0){ 
		    $dt_obj = $dbmaster->pdb->create( { 'id'    => $id,
						       'description' => $description,
						       'ligand' => $ligand,
						       'source' => $source
						       } );
		}
		last;
	    }
	    
	}
	close(IN);
    }
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3