[Bio] / FigKernelPackages / Phage.pm Repository:
ViewVC logotype

View of /FigKernelPackages/Phage.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (download) (as text) (annotate)
Fri Oct 22 04:16:18 2010 UTC (9 years, 1 month ago) by redwards
Branch: MAIN
CVS Tags: mgrast_dev_08112011, mgrast_dev_08022011, myrast_rel40, mgrast_dev_05262011, mgrast_dev_04082011, mgrast_version_3_2, mgrast_dev_12152011, mgrast_dev_06072011, 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
Changes since 1.2: +1 -1 lines
minor correction

#_perl_

=pod

=head1 

Methods used by Rob and others to access the phage genomes.

=cut

package Phage;
use strict;
use Data::Dumper;
use FIG;

=head2 Methods

=head3 new

Just instantiate the object and return $self
Can also provide a fig object to the class.

=cut

sub new {
	my ($class, $fig)=@_;
	my $self={};
	if (defined $fig) {
		$self->{'fig'}=$fig;
	}
	else {
		$self->{'fig'}=new FIG;
	}
	return bless $self, $class;
}


=head3 phages

Get a list of all the phage genome IDs.

   my @phages = Phage->phages();

=cut

sub phages {
	my $self=shift;
	my %seen;
	return grep {!$seen{$_}++} grep { $self->{'fig'}->is_genome($_) } map {$_->[0]} $self->{'fig'}->get_attributes(undef, 'virus_type', 'Phage');
}


=head3 is_phage_function

Is the function a phage function.
	my $bool = $phage->is_phage_function($fn);

=cut

sub is_phage_function {
	my ($self, $fn)=@_;
	if (
		$fn =~ /\bphage\b/i       || 
		$fn =~ /integrase/i       ||
		$fn =~ /tail protein/i    ||
		$fn =~ /minor structural protein/i ||
		$fn =~ /major structural protein/i ||
		$fn =~ /tail fiber/i ||
		$fn =~ /baseplate/i ||
		$fn =~ /tape measure/i
	) {
		return 1;
	}
	return 0;
}

=head3 prophages_in_genome

Get the ids of all the known prophages in the genome

	my @prophage_ids = $phage->prophages_in_genome($genome);

=cut

sub prophages_in_genome {
	my ($self, $genome) = @_;
	return $self->{'fig'}->all_features($genome, "pp");
}


=head3 prophage_pegs

Get all the pegs in the prophages in a genome

	my @pegs = $phage->prophage_pegs($genome);

=cut

sub prophage_pegs {
	my ($self, $genome) = @_;
	my @pegs = ();
	foreach my $pp ($self->prophages_in_genome($genome)) {
		my ($contig, $beg, $end)=$self->{'fig'}->boundaries_of($self->{'fig'}->feature_location($pp));
		my ($temp, $rstart, $rend) = $self->{'fig'}->genes_in_region($genome, $contig, $beg, $end);
		push @pegs, grep {m/\.peg\./} @$temp;
	}
	return @pegs;
}



1;


MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3