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

View of /FigKernelScripts/seed2ptt.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (download) (as text) (annotate)
Fri May 3 17:30:09 2013 UTC (6 years, 6 months ago) by redwards
Branch: MAIN
CVS Tags: rast_rel_2014_0729, rast_rel_2014_0912, HEAD
Changes since 1.1: +12 -0 lines
adding alternate genome selections

#__perl__

=pod

=head1 seed2ptt

ptt is a simple tab separated flat file format that genbank uses very rarely and some other tools use now and then

This is a really simple script that just dumps the seed data in tab separated format with the columns in (hopefully) the right order.

Written by Rob Edwards, January 2012.

=cut


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

my $genome= shift || die "Organism to write ptt file for?";

if (!$fig->is_genome($genome)) {
	my $taxid=$genome;
	$taxid =~ s/\.\d+$//;
	my @alts =  (grep {m/^$taxid/} $fig->genomes);
	if (@alts) {
	die "$genome is not a valid genome (it was probably deleted). Try one of these genomes as an alternative: @alts\n";
	} else {
		die "$genome is not a valid genome (it was probably deleted) but we couldn't suggest an alternative just based on tax id. Sorry\n";
	}
}


my $locations;
foreach my $peg ($fig->pegs_of($genome)) {
	my @locs = $fig->feature_location($peg);
	my $fn = scalar($fig->function_of($peg));
	foreach my $tple (@locs) {
		$tple =~ m/^(.*)\_(\d+)\_(\d+)$/;
		my ($contig, $start, $stop)=($1, $2, $3);
		die "Bad feature location: $tple for $peg" unless ($contig && $start && $stop);
		push @{$locations->{$contig}}, [$peg, $start, $stop, $fn];
	}
}
open(PTT, ">$genome.ptt") || die "can't open $genome.ptt";
foreach my $contig (keys %$locations) {
	my $len = $fig->contig_ln($genome, $contig);
	map {
		print PTT join("\t", $contig, $len, @{$_}), "\n";
	} sort {$a->[0] <=> $b->[0]} @{$locations->{$contig}};
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3