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

View of /FigKernelScripts/load_peg_mapping.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.12 - (download) (as text) (annotate)
Thu Dec 23 18:03:19 2010 UTC (8 years, 10 months ago) by olson
Branch: MAIN
CVS Tags: mgrast_dev_08112011, mgrast_dev_08022011, rast_rel_2014_0912, myrast_rel40, mgrast_dev_05262011, mgrast_dev_04082011, mgrast_version_3_2, mgrast_dev_12152011, mgrast_dev_06072011, rast_rel_2014_0729, mgrast_dev_02212011, 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, HEAD
Changes since 1.11: +1 -1 lines
Caching / FCGI speedup modifications.

# -*- perl -*-
#
# 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.
#


###########################################
use strict;
use FIG;
use DBrtns;
use Tracer;

my $fig = new FIG;

my $temp_dir = "$FIG_Config::temp";
my($organisms_dir) = "$FIG_Config::organisms";

my( $peg, $syns, $peg_id, $peg_ln, $syn_id, $syn_ln, $syn, $line );

my $usage = "load_peg_mapping [-table tablename] [-file pegsyn-file]";



my $table = "peg_synonyms";
my $file = "$FIG_Config::global/peg.synonyms";

while ((@ARGV > 0) && ($ARGV[0] =~ /^-/))
{
    my $arg = shift @ARGV;
    if ($arg =~ /^-table/i) 
    { 
	$table = shift(@ARGV);
    }
    elsif ($arg =~ /^-file/i) 
    { 
	$file = shift(@ARGV);
    }
    else
    { 
	die $usage;
    }
}


Trace("Parsing peg synonyms.") if T(2);
Open(\*REL, "| sort $FIG_Config::sort_options -T $temp_dir >$temp_dir/tmpfeat$$");
Open(\*SYN, "<$file");
while (defined($line = <SYN>))
{
    chomp $line;
    ($peg,$syns) = split(/\t/,$line);
    ($peg_id,$peg_ln) = split(/,/,$peg);

    #  Removed this test from inner loop for twice the speed -- GJO
    if ( (! $peg_id) || ($peg_ln !~ /^[123456789]\d*/) )
    {
        Trace("Invalid peg in peg.synonyms: $line") if T(0);
        next;
    }

    foreach $syn ( split( /;/, $syns ) )
    {
        #  Delay split on comma; avoid building intermediate arrays -- GJO
        ( $syn_id, $syn_ln ) = split( /,/, $syn );
        if ( ( ! $syn_id) || ( $syn_ln !~ /^[123456789]\d*/ ) )
        {
            Trace("Invalid synonym in peg.synonyms: $peg => $syn") if T(0);
        }
        else
        {
            print REL join( "\t", $peg_id, $peg_ln, $syn_id, $syn_ln ) . "\n";
        }
    }
}
close(REL);

$fig->reload_table('all', $table,
					"maps_to varchar(64), maps_to_ln INTEGER, syn_id varchar(64), syn_ln INTEGER",
					{ peg_ids_ix => "syn_id", peg_maps_to_ix => "maps_to" },
					"$temp_dir/tmpfeat$$" );
unlink("$temp_dir/tmpfeat$$");
Trace("Peg mappings loaded.") if T(2);

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3