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

View of /FigKernelScripts/install_partitions.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (download) (as text) (annotate)
Thu Nov 11 17:38:01 2010 UTC (9 years, 3 months ago) by disz
Branch: MAIN
CVS Tags: mgrast_dev_08112011, mgrast_dev_08022011, rast_rel_2014_0912, myrast_rel40, mgrast_dev_05262011, mgrast_dev_04082011, mgrast_version_3_2, mgrast_dev_12152011, mgrast_dev_06072011, rast_rel_2014_0729, mgrast_dev_02212011, rast_rel_2010_1206, mgrast_release_3_0, mgrast_dev_03252011, rast_rel_2011_0119, mgrast_release_3_0_4, mgrast_release_3_0_2, mgrast_release_3_0_3, mgrast_release_3_0_1, mgrast_dev_03312011, mgrast_release_3_1_2, mgrast_release_3_1_1, mgrast_release_3_1_0, mgrast_dev_04132011, mgrast_dev_04012011, myrast_33, rast_rel_2011_0928, mgrast_dev_04052011, mgrast_dev_02222011, mgrast_dev_10262011, HEAD
Changes since 1.4: +1 -1 lines
FigFam 6 digit problem

use FIG;
my $fig = new FIG;

my $usage = "usage: install_partitions FigFamsData < partitions";

my $figfams_data;

(
 ($figfams_data = shift @ARGV) && (-d $figfams_data)
)
    || die $usage;

if (-d "$figfams_data/Partitions") { die "$figfams_data/Partitions exists; delete it before continuing" }
mkdir("$figfams_data/Partitions",0777) || die "could not make $figfams/Partitions";

open(PART,">$figfams_data/partitions.input") || die "could not open $figfams_data/partitions";

my %seen;
my $next_partition = 1;
while (defined($_ = <STDIN>))
{
    my @set = ();
    while ($_ && ($_ !~ /^\/\//))
    {
	if ($_ =~ /^(fig\|\d+\.\d+\.peg\.\d+)/)
	{
	    push(@set,$1);
	}
	$_ = <STDIN>;
    }

    if ((@set > 1) && ($_ =~ /^\/\/\s+(\S.*\S)/))
    {
	my @ff = sort { $a->[0] cmp $b->[0] } map { ($_ =~ /^(FIG\d+),(\S+)/) ? [$1,$2] : () } split(/\s+/,$1);
	if (@ff > 0)
	{
	    my $key = join(",",map { $_->[0] } @ff);
	    if (! $seen{$key})
	    {
		print STDERR "$key\t$next_partition\n";
		$seen{$key} = 1;
		foreach my $peg (@set)
		{
		    print PART "$peg\n";
		}
		print PART "// ",join(" ", map { join(",",@$_) } @ff),"\t$next_partition\n";
		
		my $mod = $next_partition % 1000;
		&FIG::verify_dir("$figfams_data/Partitions/$mod/$next_partition");
		open(FASTA,">$figfams_data/Partitions/$mod/$next_partition/fasta")
		    || die "could not make $figfams_data/Partitions/$mod/$next_partition/fasta";
		foreach my $peg (@set)
		{
		    my $pseq;
		    if ($pseq = $fig->get_translation($peg))
		    {
			print FASTA ">$peg\n$pseq\n";
		    }
		}
		close(FASTA);
		&FIG::run("$FIG_Config::ext_bin/formatdb -i $figfams_data/Partitions/$mod/$next_partition/fasta -p T");
		&process_set($figfams_data,\@ff,$next_partition);
		$next_partition++;
	    }
	}
	else
	{
	    print STDERR &Dumper(\@ff,$_);
	}
    }
    else
    {
	warn "BAD: $_";
    }
}

sub process_set {
    my($figfams_data,$fams,$partition) = @_;

#   print STDERR &Dumper($fams);
    foreach $tuple (@$fams)
    {
	my($fam,$min_bsc) = @$tuple;
	if (! $min_bsc) { $min_bsc = 1000 }
	$fam =~ /(\d{3})$/;
	my $dir = "$figfams_data/FIGFAMS/$1/$fam";
	&FIG::verify_dir($dir);
	open(TMP,">$dir/decision.procedure.blast") || die "could not open $dir/partition";
	print TMP "blast_vote\t$partition\t$min_bsc\n";
	close(TMP);

	open(TMP,">$dir/blast.partition") || die "could not open $dir/blast.partition";
        print TMP "$partition\n";
        close(TMP);

	if (open(TMP,"<$dir/decision.procedure") && (defined($_ = <TMP>)) && ($_ =~ /^blast_vote/))
	{
	    system "cp $dir/decision.procedure.blast $dir/decision.procedure";
	    close(TMP);
	}
    }
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3