[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.5 - (download) (as text) (annotate)
Wed Dec 21 19:14:13 2005 UTC (14 years, 6 months ago) by overbeek
Branch: MAIN
CVS Tags: mgrast_dev_08112011, rast_rel_2009_05_18, mgrast_dev_08022011, rast_rel_2014_0912, rast_rel_2008_06_18, myrast_rel40, rast_rel_2008_06_16, mgrast_dev_05262011, rast_rel_2008_12_18, mgrast_dev_04082011, rast_rel_2008_07_21, rast_rel_2010_0928, rast_2008_0924, mgrast_version_3_2, mgrast_dev_12152011, rast_rel_2008_04_23, mgrast_dev_06072011, rast_rel_2008_09_30, rast_rel_2009_0925, rast_rel_2010_0526, rast_rel_2014_0729, mgrast_dev_02212011, rast_rel_2010_1206, caBIG-05Apr06-00, mgrast_release_3_0, mgrast_dev_03252011, rast_rel_2010_0118, mgrast_rel_2008_0924, mgrast_rel_2008_1110_v2, rast_rel_2009_02_05, rast_rel_2011_0119, mgrast_rel_2008_0625, 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, rast_rel_2008_10_09, mgrast_dev_04012011, rast_release_2008_09_29, mgrast_rel_2008_0806, mgrast_rel_2008_0923, mgrast_rel_2008_0919, rast_rel_2009_07_09, rast_rel_2010_0827, mgrast_rel_2008_1110, myrast_33, rast_rel_2011_0928, rast_rel_2008_09_29, mgrast_rel_2008_0917, rast_rel_2008_10_29, mgrast_dev_04052011, mgrast_dev_02222011, caBIG-13Feb06-00, rast_rel_2009_03_26, mgrast_dev_10262011, rast_rel_2008_11_24, rast_rel_2008_08_07, HEAD
Changes since 1.4: +4 -2 lines
RAE: Protein Families interface and construction

# Copyright (c) 2003-2006 University of Chicago and Fellowship
# for Interpretations of Genomes. All Rights Reserved.
# This file is part of the SEED Toolkit.
# The SEED Toolkit is free software. You can redistribute
# it and/or modify it under the terms of the SEED Toolkit
# Public License. 
# You should have received a copy of the SEED Toolkit Public License
# along with this program; if not write to the University of Chicago
# at info@ci.uchicago.edu or the Fellowship for Interpretation of
# Genomes at veronika@thefig.info or download a copy from
# http://www.theseed.org/LICENSE.TXT.

$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);

open(SYN,"<$syn") || die "could not open $syn";
$cid = 1;
while (defined($_ = <SYN>))
    @prots = split(/\t/,$_);
    foreach $prot (@prots)
        unless ($prot) {print STDERR "No protein id (|$prot|) in $syn at $_\n"; next}
	print TAB1 "$prot\t$cid\n";
	$to_cid{$prot} = $cid;

foreach $source (@specific)
    next unless (-d "$sources/$source"); # don't try and process it if it is not a directory!
    open(IDMAP,"<$sources/$source/id.map") || die "could not open $sources/$source/id.map";
    while (defined($_ = <IDMAP>))
	($fam,$lid) = split(/\t/,$_);
	if (!$to_cid{$lid}) 
	 # we don't have a synonym for this protein
	 # we can either ignore it or just give it a unique id. Lets do that.
	 # and write it to the file
         unless ($lid) {print STDERR "No protein id (|$lid|) in $syn at $_\n"; next}
	 print TAB1 "$lid\t$cid\n";
	print TAB2 "$fam\t$to_cid{$lid}\n";

    if (open(FAMFUNC,"<$sources/$source/family.funcs"))
	while (defined($_ = <FAMFUNC>))
	    # ignore things that begin with a # or things that are just white space
	    # some files also have the last line with just a | on it. This should just be skipped
	    next if (/^\s+$/ || /^\s*\#/ || /^\|/);
	    # this was originally written with this regexp
	    # but there were problems when the function was not defined and also with some functions
	    # that had leading or trailing spaces. These are removed now.
	    #if (($_ =~ /^(\S+)\t(\S[^\t]*\S)$/) && (length($2) < 256))
	    if ($_ !~ /\t/) {print STDERR "Not enough columns in $sources/$source/family.funcs at $_\n"; next}
	    my @line=split /\t/;
	    if ($#line > 1) {print STDERR "Too many columns in $sources/$source/family.funcs at $_\n"; next}
	    # trim leading and trailing spaces
	    $line[1] =~ s/^\s+//; $line[1] =~ s/\s*$//; 
	    $line[0] =~ s/^\s+//; $line[0] =~ s/\s*$//; 

	    # define the function if it is unknown
            unless (defined $line[1]) {$line[1] = "unknown"}
	    print TAB3 join("\t", @line), "\n";


MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3