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

View of /FigKernelScripts/FFB2_make_FF_index.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (as text) (annotate)
Thu Jun 10 19:27:55 2010 UTC (9 years, 9 months ago) by overbeek
Branch: MAIN
build Blast directory for FRs

use FIG_Config;
use FIG;
my $fig = new FIG;
use strict;

my $usage = "usage: make_FF_index FigfamRelDir IndexFile BlastDir";
my($ff_dir,$indexF,$blastDir);

(
 ($ff_dir = shift @ARGV) && (-s "$ff_dir/families.2c") && (-s "$ff_dir/family.functions") &&
 ($indexF = shift @ARGV) &&
 ($blastDir = shift @ARGV)
)
    || die $usage;

if (-d $blastDir) 
{
    die "You have a version of $blastDir; delete it before trying to rebuild it";
}

my %funcH;
open(FUNCS,"<$ff_dir/family.functions") || die "could not open $ff_dir/family.functions";
open(PEGS,"<$ff_dir/families.2c")       || die "could not open $ff_dir/families.2c";
open(INDEX,">$indexF")                  || die "could not open $indexF";

my %ff_to_pegs;
while (defined($_ = <PEGS>))
{
    chomp;
    my($ff,$peg) = split(/\t/,$_);
    push(@{$ff_to_pegs{$ff}},$peg);
}
close(PEGS);

while (defined($_ = <FUNCS>))
{
    chomp;
    my($ff,$func) = split(/\t/,$_);
    push(@{$funcH{$func}},$ff);
}
close(FUNCS);

my $indexI = 1;
foreach my $func (sort { @{$funcH{$b}} <=> @{$funcH{$a}} } keys(%funcH))
{
    my $subI = $indexI % 1000;
    &FIG::verify_dir("$blastDir/$subI");
    open(FASTA,">$blastDir/$subI/$indexI.fasta") || die "could not open $blastDir/$subI/$indexI.fasta";
    my @ffs = sort @{$funcH{$func}};
    foreach my $ff (@ffs)
    {
	print INDEX join("\t",($indexI,$ff,$func)),"\n";
	foreach my $peg (sort { &FIG::by_fig_id($a,$b) } @{$ff_to_pegs{$ff}})
	{
	    my $seq = $fig->get_translation($peg);
	    if ($seq)
	    {
		print FASTA ">$peg\n$seq\n";
	    }
	}
    }
    close(FASTA);
    &FIG::run("$FIG_Config::ext_bin/formatdb -pT -i $blastDir/$subI/$indexI.fasta");
    $indexI++;
}
close(INDEX);

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3