[Bio] / FigKernelScripts / p3x-write-family-defs.pl Repository:
ViewVC logotype

View of /FigKernelScripts/p3x-write-family-defs.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (as text) (annotate)
Tue Jun 6 21:19:55 2017 UTC (2 years, 5 months ago) by olson
Branch: MAIN
CVS Tags: HEAD
Extract local and global family definition files from full family data.

#
# Write family definition files using the merged all-families file.
#

use PerlIO::via::Blockwise;
use Getopt::Long::Descriptive;

my($opt, $usage) = describe_options("%c %o fams-file genus-map output-local-fams output-global-fams",
				    ["help|h", "Show this help message"]);

print($usage->text), exit (0) if $opt->help;
die($usage->text) if @ARGV != 4;

my $fams = shift;
my $genus_map = shift;
my $out_local = shift;
my $out_global = shift;

my %genus_id;
open(G, "<", $genus_map) or die "Cannot open genus map $genus_map: $!\n";
while (<G>)
{
    chomp;
    my($gname, $gid) = split(/\t/);
    $genus_id{$gname} = $gid;
}
close(G);

open(F, "<:via(Blockwise)", $fams) or die "Cannot open families file $fams: $!\n";
#open(F, "<", $fams) or die "Cannot open families file $fams: $!\n";

open(L, ">", $out_local) or die "Cannot write $out_local: $!";
open(G, ">", $out_global) or die "Cannot write $out_global: $!";

my %local;
my %global;

while (<F>)
{
    my($gf, undef, undef, $fid, undef, $func, $lfnum, $genus) = split(/\t/);
    if (!$global{$gf}++)
    {
	$gf =~ s/^GF/PGF_/;
	print G "$gf\t$func\n";
    }

    my $gnum = $genus_id{$genus};
    
    if (!$local{$gnum,$lfnum}++)
    {
	my $lf = sprintf("PLF_%d_%08d", $gnum, $lfnum);
	print L "$lf\t$func\n";
    }
}
close(F);
close(L);
close(G);

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3