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

View of /FigKernelScripts/make_fam_tabs.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (download) (as text) (annotate)
Mon Aug 1 18:52:58 2005 UTC (14 years, 11 months ago) by overbeek
Branch: MAIN
CVS Tags: caBIG-dataload-0, caBIG-00-00-00
Changes since 1.1: +8 -1 lines
update stuff relating to protein families

$usage = "usage: make_fam_tabs Sources Synonyms Dir";

(
 ($sources = shift @ARGV) &&
 ($syn     = shift @ARGV) &&
 ($dir     = shift @ARGV)
)
    || die $usage;

open(TAB1,">$dir/localid_cid")       || die "could not open $dir/localid_cid";
open(TAB2,">$dir/localfam_cid")      || die "could not open $dir/localfam_cid";
open(TAB3,">$dir/localfam_function") || die "could not open $dir/localfam_function";

opendir(SOURCES,$sources) || die "could not open $sources";
@specific = grep { $_ !~ /^\./ } readdir(SOURCES);
closedir(SOURCES);

open(SYN,"<$syn") || die "could not open $syn";
$cid = 1;
while (defined($_ = <SYN>))
{
    chop;
    @prots = split(/\t/,$_);
    foreach $prot (@prots)
    {
	print TAB1 "$prot\t$cid\n";
	$to_cid{$prot} = $cid;
    }
    $cid++;
}
close(TAB1);


foreach $source (@specific)
{
    open(IDMAP,"<$sources/$source/id.map") || die "could not open $sources/$source/id.map";
    while (defined($_ = <IDMAP>))
    {
	chop;
	($fam,$lid) = split(/\t/,$_);
	if ($cid = $to_cid{$lid})
	{
	    print TAB2 "$fam\t$cid\n";
	}
	else
	{
	    print STDERR "could not handle $_\n";
	}
    }
    close(IDMAP);

    if (open(FAMFUNC,"<$sources/$source/family.funcs"))
    {
	while (defined($_ = <FAMFUNC>))
	{
	    if (($_ =~ /^(\S+)\t(\S[^\t]*\S)$/) && (length($2) < 256))
	    {
		print TAB3 $_;
	    }
	    else
	    {
		print STDERR "BAD: $_";
	    }
	}
	close(FAMFUNC);
    }
}

close(TAB1);
close(TAB2);
close(TAB3);

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3