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

View of /FigKernelScripts/make_CDD_attributes.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (as text) (annotate)
Tue Feb 20 23:03:00 2007 UTC (13 years, 4 months ago) by mkubal
Branch: MAIN
creates attribute text file in /vol/seed-attributes/

$genome = shift(@ARGV);
open(IN,"/vol/seed-attributes/computation_results/CDD/$genome/rpsblast_results.txt");
open(OUT,">/vol/seed-attributes/CDD/CDD_attributes_for_$genome.txt");

my $peg, $id, $score, %id_score, %id_start,%id_stop,$record, $record_start,$start,$stop;
while ($_ = <IN>){
    chomp($_);
    if($_ =~/Query=\s(fig\|\d+.\d+.peg.\d+)/){
	$new_peg = $1;
	if($peg){
	    foreach $key (keys(%id_score)){
		$string = "$peg\tCDD::$key\t$id_score{$key};$id_start{$key}-$id_stop{$key}\n";
		if($string =~/(\d+-\d+)$/){print OUT "$string"}
	    }
	}
	$peg = $new_peg;
	foreach $key (keys(%id_score)){delete($id_score{$key})}
	foreach $key (keys(%id_start)){delete($id_start{$key})}
	foreach $key (keys(%id_stop)){delete($id_stop{$key})}
	$record = 0;
    }
    
    #handle last peg in file
    if($_ =~/\Database:\sCDD/){
	if($peg){
	    foreach $key (keys(%id_score)){
		print OUT "$peg\tCDD::$key\t$id_score{$key};$id_start{$key}-$id_stop{$key}\n";
	    }
	}
    }
    
    if($_ =~/\|CDD\|(\d+).*\s+(\d+e-\d+)$/){
	$id = $1;
	$score = $2;
	if($score =~/(\d+)e-(\d+)/){
	    $part1 = $1;
	    $part2 = $2;
	    if($part2 > 19){
		$part2 = (1000 - $part2);
		$part1 = $part1 * 10;
		$part1 = (1000 - $part1);
		$score = $part2.".".$part1;
		$id_score{$id} = $score;
	    }
	}
    }
    
    if($_ =~/>gnl\|CDD\|(\d+)\s/){
	$id = $1;
	if($id_score{$id}){$record = 1;$record_start =1;}
	else{$record = 0}
    }
	    
    if($record){
	if($record_start){
	    if($_ =~/Query:\s(\d+)/){
		$start = $1;
		$record_start = 0;
		$record_stop = 1;
		$id_start{$id} = $start;
	    }
	}
	if($_ =~/Query:\s\d+.*\s(\d+)$/){
	    $stop = $1;
	    $id_stop{$id} = $stop;
	}
    }
}



MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3