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

View of /FigKernelScripts/update_phage_annotations.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (as text) (annotate)
Fri May 3 17:29:19 2013 UTC (6 years, 6 months ago) by redwards
Branch: MAIN
CVS Tags: rast_rel_2014_0729, rast_rel_2014_0912, HEAD
 a set of scripts for adding phage genomes to the seed

#__perl__

use strict;
use Data::Dumper;
use FIG;
my $fig = new FIG;
use Getopt::Std;
my %opts;
getopts('sg:a', \%opts);

die <<EOF unless ($opts{g});
$0
-g genome id
-a make the annotations (otherwise just print them out)
-s don't print things out - just make the annotations

EOF


foreach my $peg ($fig->pegs_of($opts{g})) {
	my @tuples = $fig->subsystems_for_peg($peg);
	next if (scalar(@tuples)); # ignore any protein aleady in a subsystem

	my $ss; my $count;
	foreach my $sim ($fig->sims($peg, 500, 1e-3, 'figx')) {
		my $opeg = $sim->[0];
		($opeg eq $peg) ? ($opeg = $sim->[1]) : 1;
		foreach my $tuple ($fig->subsystems_for_peg($opeg)) {
			my ($subsys, $fn, $vc)=@$tuple;
			push @{$ss->{$fn}}, $subsys if ($fig->usable_subsystem($subsys, 1));
			$count->{$fn}++;
		}
	}

	next unless (scalar(keys %$ss));

	my $thisfn = scalar($fig->function_of($peg));
	if ($ss->{$thisfn}) {
		(!$opts{s}) && map {print join("\t", $peg, $thisfn, $thisfn, $_), "\n"} @{$ss->{$thisfn}};
	}
	else {
		my @abundant = sort {$count->{$b} <=> $count->{$a}} keys %$count;
		(!$opts{s}) && map {print join("\t", $peg, $thisfn, $abundant[0], $_), "\n"} @{$ss->{$abundant[0]}};
		if ($opts{a}) {
			$fig->assign_function($peg, "AutoUpdate", $abundant[0]);
		}
	}
}




MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3