[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.9 - (download) (as text) (annotate)
Thu Oct 4 20:13:34 2007 UTC (12 years, 6 months ago) by olson
Branch: MAIN
CVS Tags: rast_rel_2008_06_18, rast_rel_2008_06_16, rast_rel_2008_12_18, rast_rel_2008_07_21, rast_2008_0924, rast_rel_2008_04_23, rast_rel_2008_09_30, mgrast_rel_2008_0924, mgrast_rel_2008_1110_v2, mgrast_rel_2008_0625, rast_rel_2008_10_09, rast_release_2008_09_29, mgrast_rel_2008_0806, mgrast_rel_2008_0923, mgrast_rel_2008_0919, mgrast_rel_2008_1110, rast_rel_2008_09_29, mgrast_rel_2008_0917, rast_rel_2008_10_29, rast_rel_2008_11_24, rast_rel_2008_08_07
Changes since 1.8: +1 -1 lines
bah. it's all fine to ask for a table name on the command line, but it helps if you
use that table name in the SQL.

# -*- 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, @syns, $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 -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);
    @syns = map { [ split(/,/,$_) ] } split( /;/, $syns );
    foreach $syn (@syns)
    {
        ($syn_id,$syn_ln) = @$syn;
        if ((! $peg_id) || ($peg_ln !~ /^[123456789]\d*/) || (! $syn_id) || ($syn_ln !~ /^[123456789]\d*/))
        {
            Trace("Invalid line in peg.synonyms: $line") if T(0);
        }
        else
        {
            my $record = join("\t", ($peg_id,$peg_ln,$syn_id,$syn_ln));
            print REL "$record\n";
        }
    }
}
close(REL);

$fig->reload_table('all', $table,
					"maps_to varchar(32), maps_to_ln INTEGER, syn_id varchar(32), 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