[Bio] / MGRASTBackend / compute_ff_sims.pl Repository:
ViewVC logotype

View of /MGRASTBackend/compute_ff_sims.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (download) (as text) (annotate)
Wed Jul 22 18:16:46 2009 UTC (10 years, 3 months ago) by arodri7
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +1 -1 lines
corrected errors

#
# Create the sims files for FF server output
#

use DB_File;
use Data::Dumper;

use strict;
use FIG;
use FIG_Config;
use File::Basename;
use FigFams;
use FigFam;
use FF;
use FFs;

my $fig = new FIG;

my $jobdir = shift;
my $fasta = shift;
my $ffoutput = shift;
my $simsoutput = shift;
my $fam_data = shift @ARGV;

die "$0: missing necessary input\n" if (!$jobdir || !$fasta || !$ffoutput || !$simsoutput || !$fam_data);

open (FASTA, "$fasta");
my $fasta={};
my $line = <FASTA>;
while ($line && ($line =~ /^>(\S+)/))
{
    my $id = $1;
    my @seq = ();
    while (defined($line = <FASTA>) && ($line !~ /^>/))
    {
	$line =~ s/\s//g;
	push(@seq,$line);
    }
    my $seq = join("",@seq);
    $fasta->{$id}= ">$id\n$seq";
}
close FASTA;

my $job_id = "tmpid";
my $tmpfile = "$FIG_Config::temp/$job_id.$$.fasta";

#my $simsoutput = "$jobdir/raw_ff.sims";
open (FFOUT, $ffoutput);
open (SIMSOUT, ">$simsoutput");

#$fam_data = $fig->get_figfams_data($fam_data);
my $ffs = new FFs($fam_data,$fig);



while (my $line = <FFOUT>)
{
    chomp ($line);
    my ($id,$numHits,$contig,$role,$otu) = split (/\t/, $line);

    my @fams_with_funcs = $ffs->families_with_function($role);
    my @db_paths=();
    next if (scalar @fams_with_funcs > 20);
    foreach my $fam (@fams_with_funcs)
    {
	my ($sub) = $fam =~ /FIG\d\d\d(\d\d\d)/;
	push @db_paths, "$fam_data/FIGFAMS/$sub/$fam/PEGs.fasta";
    }
    
    # run the blast against all dbs
    open (TMP,">$tmpfile");
    print TMP $fasta->{$contig};
    #print TMP $fasta->{$id};
    close TMP;
    
    my @cmd = ("$FIG_Config::ext_bin/blastall",
	       '-i', $tmpfile,
	       '-d', '"'.join(" ", @db_paths).'"',
	       '-m', 8,
	       '-FF',
	       '-p', 'blastx',
	       '-g T');
    my $cmd = join " ", @cmd;
	       
    my @tmp = `$cmd` || die "could not open blast";
    print SIMSOUT @tmp;

}
close SIMSOUT;
close FFOUT;
unlink($tmpfile);

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3